Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Recommendation Engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
URBANITE
Open
Recommendation Engine
Commits
8aaaa363
Commit
8aaaa363
authored
1 year ago
by
Campos Cordobes, Sergio
Browse files
Options
Downloads
Patches
Plain Diff
Update ddbb scripts/recommender_popularity_detailed.sql
parent
f6db824d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ddbb scripts/recommender_popularity_detailed.sql
+100
-0
100 additions, 0 deletions
ddbb scripts/recommender_popularity_detailed.sql
with
100 additions
and
0 deletions
ddbb scripts/recommender_popularity_detailed.sql
0 → 100644
+
100
−
0
View file @
8aaaa363
-- Created on: 16/01/2023
-- @author: Andoni Aranguren Ubierna
-- Adaptations: 02/2023 @author: Sergio Campos
drop
procedure
`recommender_popularity_detailed`
;
DELIMITER
$$
CREATE
DEFINER
=
`root`
@
`localhost`
PROCEDURE
`recommender_popularity_detailed`
(
IN
kpi
INT
,
IN
action
INT
)
BEGIN
IF
((
kpi
is
null
)
and
(
action
is
NULL
))
THEN
SELECT
t_p_list
.
plan_id
,
p
.
action_id
,
p
.
action_name
,
p
.
lat
,
p
.
lon
,
-- This lines are so we can get the list of kpis vvvvvvvvvv
GROUP_CONCAT
(
distinct
t_p_list
.
plan_id
)
as
plan_id_list
,
GROUP_CONCAT
(
distinct
t_p_list
.
kpi_id
)
as
kpi_id_list
,
GROUP_CONCAT
(
distinct
t_p_list
.
kpi_name
)
as
kpi_name_list
,
GROUP_CONCAT
(
t_p_list
.
absolute
)
as
kpi_absolute_list
,
GROUP_CONCAT
(
t_p_list
.
relative
)
as
kpi_relative_list
,
GROUP_CONCAT
(
t_p_list
.
geographical
)
as
kpi_geographical_list
,
-- This lines are so we can get the list of kpis ^^^^^^^^^^
p
.
popularity
as
popularity
,
p
.
category
as
category
FROM
action
p
-- This lines are so we can get the list of kpis vvvvvvvvvv
INNER
JOIN
chosen_action
t_list
ON
t_list
.
action_id
=
p
.
action_id
INNER
JOIN
kpi_action_plan_detail
t_p_list
ON
t_list
.
plan_id
=
t_p_list
.
plan_id
INNER
JOIN
action
a
ON
a
.
action_id
=
t_p_list
.
action_id
-- This lines are so we can get the list of kpis ^^^^^^^^^^
GROUP
BY
p
.
action_id
ORDER
BY
popularity
DESC
LIMIT
100
;
ELSEIF
(
not
(
kpi
is
null
))
THEN
SELECT
t_p_list
.
plan_id
,
p
.
action_id
,
p
.
action_name
,
p
.
lat
,
p
.
lon
,
-- This lines are so we can get the list of kpis vvvvvvvvvv
GROUP_CONCAT
(
distinct
t_p_list
.
plan_id
)
as
plan_id_list
,
GROUP_CONCAT
(
distinct
t_p_list
.
kpi_id
)
as
kpi_id_list
,
GROUP_CONCAT
(
distinct
t_p_list
.
kpi_name
)
as
kpi_name_list
,
GROUP_CONCAT
(
t_p_list
.
absolute
)
as
kpi_absolute_list
,
GROUP_CONCAT
(
t_p_list
.
relative
)
as
kpi_relative_list
,
GROUP_CONCAT
(
t_p_list
.
geographical
)
as
kpi_geographical_list
,
-- This lines are so we can get the list of kpis ^^^^^^^^^^
p
.
popularity
as
popularity
,
p
.
category
as
category
FROM
action
p
-- This lines are so we can get the list of kpis vvvvvvvvvv
INNER
JOIN
chosen_action
t_list
ON
t_list
.
action_id
=
p
.
action_id
INNER
JOIN
kpi_action_plan_detail
t_p_list
ON
t_list
.
plan_id
=
t_p_list
.
plan_id
INNER
JOIN
action
a
ON
a
.
action_id
=
t_p_list
.
action_id
-- This lines are so we can get the list of kpis ^^^^^^^^^^
WHERE
t_p_list
.
kpi_id
=
kpi
GROUP
BY
p
.
action_id
ORDER
BY
popularity
DESC
LIMIT
100
;
ELSEIF
(
not
(
action
is
NULL
))
THEN
SELECT
t_p_list
.
plan_id
,
p
.
action_id
,
p
.
action_name
,
p
.
lat
,
p
.
lon
,
-- This lines are so we can get the list of kpis vvvvvvvvvv
GROUP_CONCAT
(
distinct
t_p_list
.
plan_id
)
as
plan_id_list
,
GROUP_CONCAT
(
distinct
t_p_list
.
kpi_id
)
as
kpi_id_list
,
GROUP_CONCAT
(
distinct
t_p_list
.
kpi_name
)
as
kpi_name_list
,
GROUP_CONCAT
(
t_p_list
.
absolute
)
as
kpi_absolute_list
,
GROUP_CONCAT
(
t_p_list
.
relative
)
as
kpi_relative_list
,
GROUP_CONCAT
(
t_p_list
.
geographical
)
as
kpi_geographical_list
,
-- This lines are so we can get the list of kpis ^^^^^^^^^^
p
.
popularity
as
popularity
,
p
.
category
as
category
FROM
action
p
-- This lines are so we can get the list of kpis vvvvvvvvvv
INNER
JOIN
chosen_action
t_list
ON
t_list
.
action_id
=
p
.
action_id
INNER
JOIN
kpi_action_plan_detail
t_p_list
ON
t_list
.
plan_id
=
t_p_list
.
plan_id
INNER
JOIN
action
a
ON
a
.
action_id
=
t_p_list
.
action_id
-- This lines are so we can get the list of kpis ^^^^^^^^^^
WHERE
t_list
.
action_id
=
action
GROUP
BY
p
.
action_id
ORDER
BY
popularity
DESC
LIMIT
100
;
ELSE
SELECT
t_p_list
.
plan_id
,
p
.
action_id
,
p
.
action_name
,
p
.
lat
,
p
.
lon
,
-- This lines are so we can get the list of kpis vvvvvvvvvv
GROUP_CONCAT
(
distinct
t_p_list
.
plan_id
)
as
plan_id_list
,
GROUP_CONCAT
(
distinct
t_p_list
.
kpi_id
)
as
kpi_id_list
,
GROUP_CONCAT
(
distinct
t_p_list
.
kpi_name
)
as
kpi_name_list
,
GROUP_CONCAT
(
t_p_list
.
absolute
)
as
kpi_absolute_list
,
GROUP_CONCAT
(
t_p_list
.
relative
)
as
kpi_relative_list
,
GROUP_CONCAT
(
t_p_list
.
geographical
)
as
kpi_geographical_list
,
-- This lines are so we can get the list of kpis ^^^^^^^^^^
p
.
popularity
as
popularity
,
p
.
category
as
category
FROM
action
p
-- This lines are so we can get the list of kpis vvvvvvvvvv
INNER
JOIN
chosen_action
t_list
ON
t_list
.
action_id
=
p
.
action_id
INNER
JOIN
kpi_action_plan_detail
t_p_list
ON
t_list
.
plan_id
=
t_p_list
.
plan_id
INNER
JOIN
action
a
ON
a
.
action_id
=
t_p_list
.
action_id
WHERE
t_list
.
action_id
=
action
AND
t_p_list
.
kpi_id
=
kpi
GROUP
BY
p
.
action_id
ORDER
BY
popularity
DESC
LIMIT
100
;
END
IF
;
END
$$
DELIMITER
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment