File tree Expand file tree Collapse file tree 1 file changed +64
-0
lines changed
Expand file tree Collapse file tree 1 file changed +64
-0
lines changed Original file line number Diff line number Diff line change 1+ -- https://docs.google.com/spreadsheets/d/1g92Rj02LVqvYBFmdnf5CBs8IwuD0GjXP0b1A-H9SvQY/edit#gid=0
2+
3+ WITH
4+ -- Collect user_group_id
5+ cq_user_group_ids as (
6+ SELECT
7+ user_groups .user_group_id
8+ FROM user_groups
9+ WHERE user_groups .name in (
10+ ' Amazon' ,
11+ ' Cisco' ,
12+ ' Grainger' ,
13+ ' Hewlett Packard Enterprise' ,
14+ ' HP Inc.' ,
15+ ' Intel' ,
16+ ' Lenovo' ,
17+ ' Mastercard' ,
18+ ' PwC' ,
19+ ' Assurant' ,
20+ ' Microsoft' ,
21+ ' Paramount Global' ,
22+ ' Flex' ,
23+ ' Rodan + Fields' ,
24+ ' Pitney Bowes' ,
25+ ' Lockheed Martin Corporation' ,
26+ ' Fanatics' ,
27+ ' Zurich NA' ,
28+ ' Triumph Group' ,
29+ ' Leonardo DRS' ,
30+ ' McKinsey & Co.' ,
31+ ' Pyramid Systems'
32+ )
33+ ),
34+ -- Collect user_group_id+user_id
35+ cq_user_group_ids_and_user_ids as (
36+ SELECT
37+ user_group_id,
38+ user_id
39+ FROM user_groups_user_memberships
40+ WHERE
41+ user_group_id in (SELECT * FROM cq_user_group_ids)
42+ AND is_active is True
43+ )
44+ -- Insert all user_id mapping session (Year: 2022+) to user_group_id
45+ INSERT INTO mapping_sessions_user_groups(
46+ mapping_session_id,
47+ user_group_id
48+ )
49+ (
50+ SELECT
51+ MS .mapping_session_id ,
52+ CQ_UG_IDS .user_group_id
53+ FROM mapping_sessions MS
54+ JOIN cq_user_group_ids_and_user_ids CQ_UG_IDS USING (user_id)
55+ WHERE MS .end_time >= ' 2022-01-01'
56+ ) ON CONFLICT (mapping_session_id, user_group_id) DO NOTHING;
57+
58+ -- This table is maintaned using django
59+ -- type = 1 = USER_GROUP
60+ -- value = date from when the data is calculated >= 2022-01-01
61+ -- To update aggregated data: docker-compose exec django ./manage.py update_aggregated_data.py
62+ UPDATE aggregated_aggregatedtracking
63+ SET " value" = ' 2022-01-01'
64+ WHERE " type" = 1 ;
You can’t perform that action at this time.
0 commit comments