· 8 years ago · Apr 11, 2018, 03:28 PM
1(153.8ms) SET NAMES utf8, @@SESSION.sql_mode = 'NO_ENGINE_SUBSTITUTION', @@SESSION.collation_connection = 'utf8_unicode_ci', @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
2 Client Load (156.1ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
3 CalendarSchedule Load (153.1ms) SELECT `calendar_schedules`.* FROM `calendar_schedules` WHERE `calendar_schedules`.`client_id` = 6 AND `calendar_schedules`.`id` = 6 ORDER BY `calendar_schedules`.`position` ASC LIMIT 1
4 CallType Load (154.9ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` IN (46, 47, 48, 49, 51)
5 CalendarSchedule Load (153.5ms) SELECT `calendar_schedules`.* FROM `calendar_schedules` WHERE `calendar_schedules`.`client_id` = 6 AND `calendar_schedules`.`id` = 6 ORDER BY `calendar_schedules`.`position` ASC LIMIT 1
6 Block Load (156.9ms) SELECT `blocks`.* FROM `blocks` INNER JOIN `block_schedules` ON `blocks`.`block_schedule_id` = `block_schedules`.`id` WHERE `block_schedules`.`id` = 6 AND `blocks`.`id` = 17087 ORDER BY start_date asc, end_date asc LIMIT 1
7 BlockSchedule Load (153.0ms) SELECT `block_schedules`.* FROM `block_schedules` WHERE `block_schedules`.`id` = 6 LIMIT 1
8 PopulationTimeframe Load (152.7ms) SELECT `population_timeframes`.* FROM `population_timeframes` WHERE `population_timeframes`.`client_id` = 6 AND `population_timeframes`.`timeframe_type` = 1 ORDER BY `population_timeframes`.`id` ASC LIMIT 1
9 RuleSet Load (153.8ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
10 Block Load (153.5ms) SELECT `blocks`.* FROM `blocks` INNER JOIN `block_schedules` ON `blocks`.`block_schedule_id` = `block_schedules`.`id` WHERE `block_schedules`.`id` = 6 AND (blocks.start_date >= '2017-10-01' AND blocks.end_date <= '2017-10-31') ORDER BY start_date asc, end_date asc
11INFO : (04-03 14:40:23) phase: Scheduler::Base
12INFO : (04-03 14:40:23) from: 2017-10-01 to: 2017-10-31
13 Rule Load (155.3ms) SELECT `rules`.* FROM `rules` WHERE `rules`.`rule_set_id` = 1528 ORDER BY applied desc, weight desc
14INFO : (04-03 14:40:23) rule configurations: TARGET FIXES TESTING
15 - 'Cumulative Assignment Targets' applied {"opt1"=>{"applied"=>"1"}, "round_targets"=>"false"} weight:5
16 - 'Cumulative Combined Assignment Targets' applied {"opt1"=>{"applied"=>"1"}, "round_targets"=>"false"} weight:5
17 - 'Cumulative Daily Assignment Targets' applied {"opt1"=>{"applied"=>"1"}, "opt2"=>{"applied"=>"1"}, "opt3"=>{"applied"=>"1"}, "opt4"=>{"applied"=>"1"}, "opt5"=>{"applied"=>"1"}, "opt6"=>{"applied"=>"1"}, "opt7"=>{"applied"=>"1"}, "round_targets"=>"false"} weight:5
18 - 'Cumulative Day of Week Targets' applied {"opt1"=>{"applied"=>"1"}, "opt2"=>{"applied"=>"1"}, "opt3"=>{"applied"=>"1"}, "opt4"=>{"applied"=>"1"}, "opt5"=>{"applied"=>"1"}, "opt6"=>{"applied"=>"1"}, "opt7"=>{"applied"=>"1"}, "round_targets"=>"true"} weight:5
19 - 'Cumulative Hour Targets' applied {"opt1"=>{"applied"=>"1"}, "threshold"=>"15"} weight:5
20 - 'Cumulative Point Targets' applied {"opt1"=>{"applied"=>"1"}, "threshold"=>"10"} weight:5
21 - 'Cumulative Weekend / Weekday Assignment Targets' applied {"opt1"=>{"applied"=>"1"}, "opt2"=>{"applied"=>"1"}, "round_targets"=>"true"} weight:5
22 - 'Cumulative Weekend / Weekday Combined Assignment Targets' applied {"opt1"=>{"applied"=>"1"}, "opt2"=>{"applied"=>"1"}, "round_targets"=>"true"} weight:5
23 - 'Cumulative Weekend / Weekday Hour Targets' applied {"opt1"=>{"applied"=>"1"}, "opt2"=>{"applied"=>"1"}, "threshold"=>"0"} weight:5
24 - 'Cumulative Weekend / Weekday Point Targets' applied {"opt1"=>{"applied"=>"1"}, "opt2"=>{"applied"=>"1"}, "threshold"=>"0"} weight:5
25 - 'Current Assignment Targets' applied {"opt1"=>{"applied"=>"1"}, "round_targets"=>"true"} weight:5
26 - 'Current Combined Assignment Targets' applied {"opt1"=>{"applied"=>"1"}, "round_targets"=>"false"} weight:5
27 - 'Current Daily Assignment Targets' applied {"opt1"=>{"applied"=>"1"}, "opt2"=>{"applied"=>"1"}, "opt3"=>{"applied"=>"1"}, "opt4"=>{"applied"=>"1"}, "opt5"=>{"applied"=>"1"}, "opt6"=>{"applied"=>"1"}, "opt7"=>{"applied"=>"1"}, "round_targets"=>"true"} weight:5
28 - 'Current Day of Week Targets' applied {"opt1"=>{"applied"=>"1"}, "opt2"=>{"applied"=>"1"}, "opt3"=>{"applied"=>"1"}, "opt4"=>{"applied"=>"1"}, "opt5"=>{"applied"=>"1"}, "opt6"=>{"applied"=>"1"}, "opt7"=>{"applied"=>"1"}, "round_targets"=>"false"} weight:5
29 - 'Current Hour Targets' applied {"opt1"=>{"applied"=>"1"}, "threshold"=>"5"} weight:5
30 - 'Current Point Targets' applied {"opt1"=>{"applied"=>"1"}, "threshold"=>"0"} weight:5
31 - 'Current Weekend / Weekday Assignment Targets' applied {"opt1"=>{"applied"=>"1"}, "opt2"=>{"applied"=>"1"}, "round_targets"=>"false"} weight:5
32 - 'Current Weekend / Weekday Combined Assignment Targets' applied {"opt1"=>{"applied"=>"1"}, "opt2"=>{"applied"=>"1"}, "round_targets"=>"true"} weight:5
33 - 'Current Weekend / Weekday Hour Targets' applied {"opt1"=>{"applied"=>"1"}, "opt2"=>{"applied"=>"1"}, "threshold"=>"10"} weight:5
34 - 'Current Weekend / Weekday Point Targets' applied {"opt1"=>{"applied"=>"1"}, "opt2"=>{"applied"=>"1"}, "threshold"=>"10"} weight:5
35 - 'Pending Call Requests' not applied
36 - 'Pending No-call Requests' not applied
37 - 'Assignments Per Day' not applied
38 - 'Days Between Assignments' not applied
39 - 'Days Between Same Assignment' not applied
40 - 'Unassigned Days' not applied
41 - 'Weeks Between Same Assignment On Same Day Of Week' not applied
42 - 'Weeks Between Same Day Of Week' not applied
43INFO : (04-03 14:40:23) started: Scheduler::Cache::Collector.collect_all
44INFO : (04-03 14:40:23) collect_staffs
45 Staff Load (156.0ms) SELECT DISTINCT `staffs`.* FROM `staffs` INNER JOIN `assign_staff_types` ON `assign_staff_types`.`staff_id` = `staffs`.`id` INNER JOIN `staff_types` ON `staff_types`.`id` = `assign_staff_types`.`staff_type_id` WHERE `staffs`.`client_id` = 6 AND `staffs`.`take_call` = 1 AND `staffs`.`active` = 1 ORDER BY `staffs`.`display_order` ASC, last_name, first_name
46 Client Load (156.5ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6
47 StaffSpecialization Load (153.5ms) SELECT `staff_specializations`.* FROM `staff_specializations` WHERE `staff_specializations`.`staff_id` IN (66, 77, 68, 74, 72, 3351, 79, 80, 6913, 81, 65, 18125, 70, 6960, 71, 73, 20694, 75, 18127, 78, 8510)
48 Specialization Load (153.3ms) SELECT `specializations`.* FROM `specializations` WHERE `specializations`.`id` = 7 ORDER BY `specializations`.`priority` ASC
49 StaffCallType Load (307.7ms) SELECT `staff_call_types`.* FROM `staff_call_types` WHERE `staff_call_types`.`staff_id` IN (66, 77, 68, 74, 72, 3351, 79, 80, 6913, 81, 65, 18125, 70, 6960, 71, 73, 20694, 75, 18127, 78, 8510)
50INFO : (04-03 14:40:26) initial eligibles: [66,77,68,74,72,3351,79,80,6913,81,65,18125,70,6960,71,73,20694,75,18127,78,8510]
51INFO : (04-03 14:40:26) collect_call_types
52 CallType Load (155.1ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`client_id` = 6 AND `call_types`.`active` = 1 ORDER BY `call_types`.`display_order` ASC
53INFO : (04-03 14:40:26) initial call types: [46,47,48,49,51,2716,397,1343,1344]
54INFO : (04-03 14:40:26) collect_chain_links
55 ChainLink Load (153.0ms) SELECT `chain_links`.* FROM `chain_links` WHERE `chain_links`.`client_id` = 6
56INFO : (04-03 14:40:27) collect_linkages
57INFO : (04-03 14:40:27) collect_schedules
58 Schedule Load (153.8ms) SELECT `schedules`.* FROM `schedules` WHERE `schedules`.`client_id` = 6 AND (`schedules`.`schedule_on` BETWEEN '2017-10-01' AND '2017-10-31')
59INFO : (04-03 14:40:27) collect_slots
60INFO : (04-03 14:40:27) collect_approved_call_requests
61 Request Load (156.0ms) SELECT `requests`.* FROM `requests` INNER JOIN `staffs` ON `staffs`.`id` = `requests`.`staff_id` WHERE `requests`.`client_id` = 6 AND `requests`.`request_type` = 1 AND `requests`.`status` = 1 AND (`requests`.`schedule_on` BETWEEN '2017-10-01' AND '2017-10-31') ORDER BY requests.schedule_on ASC, staffs.request_priority ASC, requests.created_at ASC
62INFO : (04-03 14:40:27) collect_approved_no_call_requests
63 Request Load (153.7ms) SELECT `requests`.* FROM `requests` WHERE `requests`.`client_id` = 6 AND `requests`.`request_type` = 0 AND `requests`.`status` = 1 AND (`requests`.`schedule_on` BETWEEN '2017-10-01' AND '2017-10-31') ORDER BY requests.schedule_on asc, requests.created_at asc
64INFO : (04-03 14:40:27) finished: Scheduler::Cache::Collector.collect_all
65INFO : (04-03 14:40:27) begin to process requests
66 CallType Load (155.3ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`calendar_schedule_id` = 6 AND `call_types`.`active` = 1
67 (159.2ms) SELECT MAX(blocks.end_date) FROM `published_blocks` INNER JOIN `blocks` ON `blocks`.`id` = `published_blocks`.`block_id` WHERE `published_blocks`.`calendar_schedule_id` = 6 AND ((published_blocks.assignment_ids IS NULL) AND (published_blocks.days_of_week_mask = 127))
68 Request Load (153.7ms) SELECT distinct requests.* FROM `requests` INNER JOIN `request_call_types` ON `request_call_types`.`request_id` = `requests`.`id` WHERE `requests`.`client_id` = 6 AND `requests`.`status` = 1 AND `requests`.`request_type` = 1 AND `request_call_types`.`call_type_id` IN (46, 47, 48, 49, 51, 397, 1343, 1344, 2716) AND (requests.schedule_on > '2017-09-30')
69 SQL (173.7ms) UPDATE `schedules` SET `schedules`.`populate_method` = 'auto_approved_request', `schedules`.`creator_id` = 166 WHERE `schedules`.`client_id` = 6 AND 1=0
70INFO : (04-03 14:40:29) end of requests processing
71 Block Load (162.1ms) SELECT `blocks`.* FROM `blocks` INNER JOIN `block_schedules` ON `blocks`.`block_schedule_id` = `block_schedules`.`id` WHERE `block_schedules`.`id` = 6 AND (blocks.start_date <= '2017-10-31' AND blocks.end_date >= '2017-10-31') ORDER BY start_date asc, end_date asc LIMIT 1
72 Client Load (156.0ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
73 NegativeLink Load (153.5ms) SELECT `negative_links`.* FROM `negative_links` WHERE `negative_links`.`client_id` = 6
74INFO : (04-03 14:40:30) <-- clear: 0 - Scheduler::AutoPopulate::Queries::CreateTables
75INFO : (04-03 14:40:30) <-- clear: 1 - Scheduler::AutoPopulate::Queries::AutoPopulateSlots
76INFO : (04-03 14:40:30) <-- clear: 2 - Scheduler::AutoPopulate::Queries::Query003
77INFO : (04-03 14:40:30) <-- clear: 3 - Scheduler::AutoPopulate::Queries::Query005
78INFO : (04-03 14:40:30) <-- clear: 4 - Scheduler::AutoPopulate::Queries::Query01
79INFO : (04-03 14:40:30) <-- clear: 5 - Scheduler::AutoPopulate::Queries::Query012
80INFO : (04-03 14:40:30) <-- clear: 6 - Scheduler::AutoPopulate::Queries::QueryTargets
81INFO : (04-03 14:40:30) <-- clear: 7 - Scheduler::AutoPopulate::Queries::Query013
82INFO : (04-03 14:40:30) <-- clear: 8 - Scheduler::AutoPopulate::Queries::Query014
83INFO : (04-03 14:40:30) <-- clear: 9 - Scheduler::AutoPopulate::Queries::Query015
84INFO : (04-03 14:40:30) <-- clear: 10 - Scheduler::AutoPopulate::Queries::Query02
85INFO : (04-03 14:40:30) <-- clear: 11 - Scheduler::AutoPopulate::Queries::Query03
86INFO : (04-03 14:40:30) <-- clear: 12 - Scheduler::AutoPopulate::Queries::Query04
87INFO : (04-03 14:40:30) <-- clear: 13 - Scheduler::AutoPopulate::Queries::Query045
88INFO : (04-03 14:40:30) <-- clear: 14 - Scheduler::AutoPopulate::Queries::QueryA
89INFO : (04-03 14:40:30) <-- clear: 15 - Scheduler::AutoPopulate::Queries::QueryB
90INFO : (04-03 14:40:30) <-- clear: 16 - Scheduler::AutoPopulate::Queries::Query05
91INFO : (04-03 14:40:30) <-- clear: 17 - Scheduler::AutoPopulate::Queries::Query06
92INFO : (04-03 14:40:30) <-- clear: 18 - Scheduler::AutoPopulate::Queries::Query07
93INFO : (04-03 14:40:30) <-- clear: 19 - Scheduler::AutoPopulate::Queries::Query0702
94INFO : (04-03 14:40:30) <-- clear: 20 - Scheduler::AutoPopulate::Queries::Query0705
95INFO : (04-03 14:40:30) <-- clear: 21 - Scheduler::AutoPopulate::Queries::Query0706
96INFO : (04-03 14:40:30) <-- clear: 22 - Scheduler::AutoPopulate::Queries::Query0707
97INFO : (04-03 14:40:30) <-- clear: 23 - Scheduler::AutoPopulate::Queries::Query0708
98INFO : (04-03 14:40:30) <-- clear: 24 - Scheduler::AutoPopulate::Queries::Query0709
99INFO : (04-03 14:40:30) <-- clear: 25 - Scheduler::AutoPopulate::Queries::Query07_10_AL
100INFO : (04-03 14:40:30) <-- clear: 26 - Scheduler::AutoPopulate::Queries::Query07_10_AL_01
101INFO : (04-03 14:40:30) <-- clear: 27 - Scheduler::AutoPopulate::Queries::Query07_10_AL_02
102INFO : (04-03 14:40:30) <-- clear: 28 - Scheduler::AutoPopulate::Queries::Query07_10_AL_03
103INFO : (04-03 14:40:30) <-- clear: 29 - Scheduler::AutoPopulate::Queries::Query07_10_AL_04
104INFO : (04-03 14:40:30) <-- clear: 30 - Scheduler::AutoPopulate::Queries::Query08
105INFO : (04-03 14:40:30) <-- clear: 31 - Scheduler::AutoPopulate::Queries::Query085
106INFO : (04-03 14:40:30) <-- clear: 32 - Scheduler::AutoPopulate::Queries::Query09
107INFO : (04-03 14:40:30) <-- clear: 33 - Scheduler::AutoPopulate::Queries::Query092
108INFO : (04-03 14:40:30) <-- clear: 34 - Scheduler::AutoPopulate::Queries::Query093
109INFO : (04-03 14:40:30) <-- clear: 35 - Scheduler::AutoPopulate::Queries::Query095
110INFO : (04-03 14:40:30) <-- clear: 36 - Scheduler::AutoPopulate::Queries::Query097
111INFO : (04-03 14:40:30) <-- clear: 37 - Scheduler::AutoPopulate::Queries::Query098
112INFO : (04-03 14:40:30) <-- clear: 38 - Scheduler::AutoPopulate::Queries::Query09_09_AL_01
113INFO : (04-03 14:40:30) <-- clear: 39 - Scheduler::AutoPopulate::Queries::Query09_09_AL_02
114INFO : (04-03 14:40:30) <-- clear: 40 - Scheduler::AutoPopulate::Queries::Query09_09_AL_03
115INFO : (04-03 14:40:30) <-- clear: 41 - Scheduler::AutoPopulate::Queries::Query09_09_AL_04
116INFO : (04-03 14:40:30) <-- clear: 42 - Scheduler::AutoPopulate::Queries::Query09_12_Points
117INFO : (04-03 14:40:30) <-- clear: 43 - Scheduler::AutoPopulate::Queries::Query09_12_Hours
118INFO : (04-03 14:40:30) <-- clear: 44 - Scheduler::AutoPopulate::Queries::Query10
119INFO : (04-03 14:40:30) <-- clear: 45 - Scheduler::AutoPopulate::Queries::QueryScore02
120INFO : (04-03 14:40:30) <-- clear: 46 - Scheduler::AutoPopulate::Queries::QueryScore03
121INFO : (04-03 14:40:30) <-- clear: 47 - Scheduler::AutoPopulate::Queries::QueryScore04
122INFO : (04-03 14:40:30) <-- clear: 48 - Scheduler::AutoPopulate::Queries::Query11
123INFO : (04-03 14:40:30) <-- clear: 49 - Scheduler::AutoPopulate::Queries::DropTables
124 (156.9ms) DROP TABLE IF EXISTS buffer_annual_hour_targets_824879560
125 (154.9ms) DROP TABLE IF EXISTS buffer_annual_point_targets_824879560
126 (154.9ms) DROP TABLE IF EXISTS buffer_annual_targets_staff_totals_824879560
127 (154.6ms) DROP TABLE IF EXISTS buffer_auto_populate_slots_824879560
128 (155.0ms) DROP TABLE IF EXISTS buffer_call_days_targets_824879560
129 (154.5ms) DROP TABLE IF EXISTS buffer_call_type_targets_824879560
130 (154.7ms) DROP TABLE IF EXISTS buffer_cumulative_cd_targets_824879560
131 (154.7ms) DROP TABLE IF EXISTS buffer_cumulative_ct_targets_824879560
132 (154.6ms) DROP TABLE IF EXISTS buffer_cumulative_dow_targets_824879560
133 (154.5ms) DROP TABLE IF EXISTS buffer_cumulative_hour_targets_824879560
134 (154.5ms) DROP TABLE IF EXISTS buffer_cumulative_oa_targets_824879560
135 (162.0ms) DROP TABLE IF EXISTS buffer_cumulative_point_targets_824879560
136 (154.5ms) DROP TABLE IF EXISTS buffer_current_cd_targets_824879560
137 (154.5ms) DROP TABLE IF EXISTS buffer_current_ct_targets_824879560
138 (154.8ms) DROP TABLE IF EXISTS buffer_current_dow_targets_824879560
139 (166.7ms) DROP TABLE IF EXISTS buffer_current_hour_targets_824879560
140 (155.2ms) DROP TABLE IF EXISTS buffer_current_oa_targets_824879560
141 (155.0ms) DROP TABLE IF EXISTS buffer_current_point_targets_824879560
142 (154.9ms) DROP TABLE IF EXISTS buffer_day_of_week_targets_824879560
143 (155.9ms) DROP TABLE IF EXISTS buffer_hour_targets_824879560
144 (154.5ms) DROP TABLE IF EXISTS buffer_linkage_call_days_targets_824879560
145 (154.9ms) DROP TABLE IF EXISTS buffer_linkage_call_type_targets_824879560
146 (154.7ms) DROP TABLE IF EXISTS buffer_linkage_targets_824879560
147 (154.3ms) DROP TABLE IF EXISTS buffer_linkage_hour_targets_824879560
148 (154.6ms) DROP TABLE IF EXISTS buffer_linkage_point_targets_824879560
149 (301.0ms) DROP TABLE IF EXISTS buffer_location_privileges_824879560
150 (154.8ms) DROP TABLE IF EXISTS buffer_periods_824879560
151 (154.4ms) DROP TABLE IF EXISTS buffer_point_targets_824879560
152 (156.1ms) DROP TABLE IF EXISTS buffer_schedules_824879560
153 (154.8ms) DROP TABLE IF EXISTS buffer_target_call_types_824879560
154 (155.0ms) DROP TABLE IF EXISTS buffer_target_daily_points_824879560
155 (155.0ms) DROP TABLE IF EXISTS buffer_target_dates_list_824879560
156 (154.4ms) DROP TABLE IF EXISTS buffer_target_primary_availabilities_824879560
157 (154.8ms) DROP TABLE IF EXISTS buffer_targets_824879560
158 (154.8ms) DROP TABLE IF EXISTS buffer_tmp_targets_availabilities_824879560
159 (154.2ms) DROP TABLE IF EXISTS buffer_tmp_targets_availabilities_exclusions_824879560
160 (154.5ms) DROP TABLE IF EXISTS buffer_tmp_targets_client_totals_824879560
161 (155.4ms) DROP TABLE IF EXISTS buffer_tmp_targets_scheduled_824879560
162 (154.6ms) DROP TABLE IF EXISTS buffer_tmp_targets_staff_totals_824879560
163 (154.7ms) DROP TABLE IF EXISTS buffer_assignment_limit_call_types_824879560
164 (154.6ms) DROP TABLE IF EXISTS buffer_assignment_limit_periods_824879560
165 (155.1ms) DROP TABLE IF EXISTS buffer_assignment_limit_staff_types_824879560
166 (162.3ms) DROP TABLE IF EXISTS buffer_auto_populate_slots_824879560
167 (156.3ms) DROP TABLE IF EXISTS buffer_call_type_assignments_824879560
168 (154.5ms) DROP TABLE IF EXISTS buffer_combined_availabilities_824879560
169 (154.4ms) DROP TABLE IF EXISTS buffer_combined_availability_linkages_824879560
170 (154.5ms) DROP TABLE IF EXISTS buffer_counter_increments_824879560
171 (163.6ms) DROP TABLE IF EXISTS buffer_linkage_assigned_days_824879560
172 (154.6ms) DROP TABLE IF EXISTS buffer_linkage_assignments_count_consecutive_824879560
173 (154.5ms) DROP TABLE IF EXISTS buffer_linkage_assignments_count_periods_824879560
174 (157.5ms) DROP TABLE IF EXISTS buffer_linkage_assignments_count_rolling_824879560
175 (154.4ms) DROP TABLE IF EXISTS buffer_linkage_assignments_count_weeks_824879560
176 (154.3ms) DROP TABLE IF EXISTS buffer_linkage_call_type_assignments_824879560
177 (154.4ms) DROP TABLE IF EXISTS buffer_linkage_dow_targets_824879560
178 (154.8ms) DROP TABLE IF EXISTS buffer_linkage_patterns_824879560
179 (154.7ms) DROP TABLE IF EXISTS buffer_linkages_824879560
180 (154.5ms) DROP TABLE IF EXISTS buffer_location_privileges_824879560
181 (154.2ms) DROP TABLE IF EXISTS buffer_min_distances_824879560
182 (154.5ms) DROP TABLE IF EXISTS buffer_negative_relations_824879560
183 (154.8ms) DROP TABLE IF EXISTS buffer_rule_calc_filters_824879560
184 (154.3ms) DROP TABLE IF EXISTS buffer_rule_calc_schedules_824879560
185 (154.1ms) DROP TABLE IF EXISTS buffer_rule_scores_824879560
186 (155.6ms) DROP TABLE IF EXISTS buffer_rule_scores_with_corrections_824879560
187 (155.1ms) DROP TABLE IF EXISTS buffer_schedule_linkages_824879560
188 (154.6ms) DROP TABLE IF EXISTS buffer_schedules_linkage_patterns_824879560
189 (154.8ms) DROP TABLE IF EXISTS buffer_specialization_daily_counts_824879560
190 (156.9ms) DROP TABLE IF EXISTS buffer_staff_assigned_days_824879560
191 (154.8ms) DROP TABLE IF EXISTS buffer_staff_assignments_count_periods_824879560
192 (154.8ms) DROP TABLE IF EXISTS buffer_staff_assignments_count_rolling_824879560
193 (154.4ms) DROP TABLE IF EXISTS buffer_staff_assignments_count_weeks_824879560
194 (155.1ms) DROP TABLE IF EXISTS buffer_staff_assignments_count_consecutive_824879560
195 (155.1ms) DROP TABLE IF EXISTS buffer_staff_daily_counts_824879560
196 (154.7ms) DROP TABLE IF EXISTS buffer_staff_specializations_824879560
197 (154.9ms) DROP TABLE IF EXISTS buffer_static_availabilities_824879560
198 (154.4ms) DROP TABLE IF EXISTS buffer_target_assignments_824879560
199 (153.0ms) delete from buffer_target_dates
200 where session_id = 824879560
201 and client_id = 6
202
203INFO : (04-03 14:40:42) --> fill: 0 - Scheduler::AutoPopulate::Queries::CreateTables
204 (161.0ms) CREATE TABLE IF NOT EXISTS buffer_assignment_limit_call_types_824879560 LIKE buffer_assignment_limit_call_types
205 (158.9ms) CREATE TABLE IF NOT EXISTS buffer_assignment_limit_periods_824879560 LIKE buffer_assignment_limit_periods
206 (158.2ms) CREATE TABLE IF NOT EXISTS buffer_assignment_limit_staff_types_824879560 LIKE buffer_assignment_limit_staff_types
207 (157.7ms) CREATE TABLE IF NOT EXISTS buffer_auto_populate_slots_824879560 LIKE buffer_auto_populate_slots
208 (165.1ms) CREATE TABLE IF NOT EXISTS buffer_call_type_assignments_824879560 LIKE buffer_call_type_assignments
209 (158.4ms) CREATE TABLE IF NOT EXISTS buffer_combined_availabilities_824879560 LIKE buffer_combined_availabilities
210 (157.6ms) CREATE TABLE IF NOT EXISTS buffer_combined_availability_linkages_824879560 LIKE buffer_combined_availability_linkages
211 (157.3ms) CREATE TABLE IF NOT EXISTS buffer_counter_increments_824879560 LIKE buffer_counter_increments
212 (170.4ms) CREATE TABLE IF NOT EXISTS buffer_linkage_assigned_days_824879560 LIKE buffer_linkage_assigned_days
213 (157.6ms) CREATE TABLE IF NOT EXISTS buffer_linkage_assignments_count_consecutive_824879560 LIKE buffer_linkage_assignments_count_consecutive
214 (157.9ms) CREATE TABLE IF NOT EXISTS buffer_linkage_assignments_count_periods_824879560 LIKE buffer_linkage_assignments_count_periods
215 (157.1ms) CREATE TABLE IF NOT EXISTS buffer_linkage_assignments_count_rolling_824879560 LIKE buffer_linkage_assignments_count_rolling
216 (170.5ms) CREATE TABLE IF NOT EXISTS buffer_linkage_assignments_count_weeks_824879560 LIKE buffer_linkage_assignments_count_weeks
217 (157.5ms) CREATE TABLE IF NOT EXISTS buffer_linkage_call_type_assignments_824879560 LIKE buffer_linkage_call_type_assignments
218 (157.5ms) CREATE TABLE IF NOT EXISTS buffer_linkage_dow_targets_824879560 LIKE buffer_linkage_dow_targets
219 (157.7ms) CREATE TABLE IF NOT EXISTS buffer_linkage_patterns_824879560 LIKE buffer_linkage_patterns
220 (159.2ms) CREATE TABLE IF NOT EXISTS buffer_linkages_824879560 LIKE buffer_linkages
221 (157.3ms) CREATE TABLE IF NOT EXISTS buffer_location_privileges_824879560 LIKE buffer_location_privileges
222 (157.9ms) CREATE TABLE IF NOT EXISTS buffer_min_distances_824879560 LIKE buffer_min_distances
223 (157.0ms) CREATE TABLE IF NOT EXISTS buffer_negative_relations_824879560 LIKE buffer_negative_relations
224 (172.8ms) CREATE TABLE IF NOT EXISTS buffer_rule_calc_filters_824879560 LIKE buffer_rule_calc_filters
225 (158.7ms) CREATE TABLE IF NOT EXISTS buffer_rule_calc_schedules_824879560 LIKE buffer_rule_calc_schedules
226 (157.4ms) CREATE TABLE IF NOT EXISTS buffer_rule_scores_824879560 LIKE buffer_rule_scores
227 (157.8ms) CREATE TABLE IF NOT EXISTS buffer_rule_scores_with_corrections_824879560 LIKE buffer_rule_scores_with_corrections
228 (160.4ms) CREATE TABLE IF NOT EXISTS buffer_schedule_linkages_824879560 LIKE buffer_schedule_linkages
229 (157.8ms) CREATE TABLE IF NOT EXISTS buffer_schedules_linkage_patterns_824879560 LIKE buffer_schedules_linkage_patterns
230 (157.9ms) CREATE TABLE IF NOT EXISTS buffer_specialization_daily_counts_824879560 LIKE buffer_specialization_daily_counts
231 (163.4ms) CREATE TABLE IF NOT EXISTS buffer_staff_assigned_days_824879560 LIKE buffer_staff_assigned_days
232 (161.1ms) CREATE TABLE IF NOT EXISTS buffer_staff_assignments_count_periods_824879560 LIKE buffer_staff_assignments_count_periods
233 (157.9ms) CREATE TABLE IF NOT EXISTS buffer_staff_assignments_count_rolling_824879560 LIKE buffer_staff_assignments_count_rolling
234 (157.8ms) CREATE TABLE IF NOT EXISTS buffer_staff_assignments_count_weeks_824879560 LIKE buffer_staff_assignments_count_weeks
235 (158.8ms) CREATE TABLE IF NOT EXISTS buffer_staff_assignments_count_consecutive_824879560 LIKE buffer_staff_assignments_count_consecutive
236 (164.4ms) CREATE TABLE IF NOT EXISTS buffer_staff_daily_counts_824879560 LIKE buffer_staff_daily_counts
237 (158.1ms) CREATE TABLE IF NOT EXISTS buffer_staff_specializations_824879560 LIKE buffer_staff_specializations
238 (157.9ms) CREATE TABLE IF NOT EXISTS buffer_static_availabilities_824879560 LIKE buffer_static_availabilities
239 (170.0ms) CREATE TABLE IF NOT EXISTS buffer_target_assignments_824879560 LIKE buffer_target_assignments
240 (158.1ms) CREATE TABLE IF NOT EXISTS buffer_annual_hour_targets_824879560 LIKE buffer_annual_hour_targets
241 (157.7ms) CREATE TABLE IF NOT EXISTS buffer_annual_point_targets_824879560 LIKE buffer_annual_point_targets
242 (157.9ms) CREATE TABLE IF NOT EXISTS buffer_annual_targets_staff_totals_824879560 LIKE buffer_annual_targets_staff_totals
243 (154.7ms) CREATE TABLE IF NOT EXISTS buffer_auto_populate_slots_824879560 LIKE buffer_auto_populate_slots
244 (164.7ms) CREATE TABLE IF NOT EXISTS buffer_call_days_targets_824879560 LIKE buffer_call_days_targets
245 (157.8ms) CREATE TABLE IF NOT EXISTS buffer_call_type_targets_824879560 LIKE buffer_call_type_targets
246 (157.8ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_cd_targets_824879560 LIKE buffer_cumulative_cd_targets
247 (157.8ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_ct_targets_824879560 LIKE buffer_cumulative_ct_targets
248 (166.5ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_dow_targets_824879560 LIKE buffer_cumulative_dow_targets
249 (158.1ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_hour_targets_824879560 LIKE buffer_cumulative_hour_targets
250 (159.1ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_oa_targets_824879560 LIKE buffer_cumulative_oa_targets
251 (157.1ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_point_targets_824879560 LIKE buffer_cumulative_point_targets
252 (165.5ms) CREATE TABLE IF NOT EXISTS buffer_current_cd_targets_824879560 LIKE buffer_current_cd_targets
253 (157.1ms) CREATE TABLE IF NOT EXISTS buffer_current_ct_targets_824879560 LIKE buffer_current_ct_targets
254 (160.5ms) CREATE TABLE IF NOT EXISTS buffer_current_dow_targets_824879560 LIKE buffer_current_dow_targets
255 (158.7ms) CREATE TABLE IF NOT EXISTS buffer_current_hour_targets_824879560 LIKE buffer_current_hour_targets
256 (164.5ms) CREATE TABLE IF NOT EXISTS buffer_current_oa_targets_824879560 LIKE buffer_current_oa_targets
257 (158.2ms) CREATE TABLE IF NOT EXISTS buffer_current_point_targets_824879560 LIKE buffer_current_point_targets
258 (158.6ms) CREATE TABLE IF NOT EXISTS buffer_day_of_week_targets_824879560 LIKE buffer_day_of_week_targets
259 (157.7ms) CREATE TABLE IF NOT EXISTS buffer_hour_targets_824879560 LIKE buffer_hour_targets
260 (165.0ms) CREATE TABLE IF NOT EXISTS buffer_linkage_call_days_targets_824879560 LIKE buffer_linkage_call_days_targets
261 (160.3ms) CREATE TABLE IF NOT EXISTS buffer_linkage_call_type_targets_824879560 LIKE buffer_linkage_call_type_targets
262 (159.3ms) CREATE TABLE IF NOT EXISTS buffer_linkage_targets_824879560 LIKE buffer_linkage_targets
263 (157.5ms) CREATE TABLE IF NOT EXISTS buffer_linkage_hour_targets_824879560 LIKE buffer_linkage_hour_targets
264 (162.3ms) CREATE TABLE IF NOT EXISTS buffer_linkage_point_targets_824879560 LIKE buffer_linkage_point_targets
265 (282.2ms) CREATE TABLE IF NOT EXISTS buffer_location_privileges_824879560 LIKE buffer_location_privileges
266 (279.1ms) CREATE TABLE IF NOT EXISTS buffer_periods_824879560 LIKE buffer_periods
267 (204.4ms) CREATE TABLE IF NOT EXISTS buffer_point_targets_824879560 LIKE buffer_point_targets
268 (175.4ms) CREATE TABLE IF NOT EXISTS buffer_schedules_824879560 LIKE buffer_schedules
269 (158.1ms) CREATE TABLE IF NOT EXISTS buffer_target_call_types_824879560 LIKE buffer_target_call_types
270 (315.1ms) CREATE TABLE IF NOT EXISTS buffer_target_daily_points_824879560 LIKE buffer_target_daily_points
271 (168.6ms) CREATE TABLE IF NOT EXISTS buffer_target_dates_list_824879560 LIKE buffer_target_dates_list
272 (169.0ms) CREATE TABLE IF NOT EXISTS buffer_target_primary_availabilities_824879560 LIKE buffer_target_primary_availabilities
273 (170.9ms) CREATE TABLE IF NOT EXISTS buffer_targets_824879560 LIKE buffer_targets
274 (158.1ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_availabilities_824879560 LIKE buffer_tmp_targets_availabilities
275 (157.0ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_availabilities_exclusions_824879560 LIKE buffer_tmp_targets_availabilities_exclusions
276 (157.3ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_client_totals_824879560 LIKE buffer_tmp_targets_client_totals
277 (165.4ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_scheduled_824879560 LIKE buffer_tmp_targets_scheduled
278 (167.7ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_staff_totals_824879560 LIKE buffer_tmp_targets_staff_totals
279INFO : (04-03 14:40:54) --> fill: 1 - Scheduler::AutoPopulate::Queries::AutoPopulateSlots
280 (300.8ms) select
281 b.start_date,
282 b.end_date,
283 (pb.assignment_ids IS NULL) as fully_published,
284 concat(pbct.assignment_type, '#', pbct.assignment_id) as assignment_uid,
285 pbct.days_of_week_mask
286 from blocks as b
287 inner join published_blocks as pb
288 on pb.block_id = b.id
289 inner join published_block_call_types as pbct
290 on pbct.published_block_id = pb.id
291
292 where b.client_id = 6
293 and pb.calendar_schedule_id = 6
294 and b.end_date BETWEEN '2017-10-01' AND '2017-10-31'
295
296 AutopopulateExclusion Load (170.1ms) SELECT `autopopulate_exclusions`.* FROM `autopopulate_exclusions` WHERE `autopopulate_exclusions`.`client_id` = 6 AND `autopopulate_exclusions`.`schedule_on` IN ('2017-10-01', '2017-10-02', '2017-10-03', '2017-10-04', '2017-10-05', '2017-10-06', '2017-10-07', '2017-10-08', '2017-10-09', '2017-10-10', '2017-10-11', '2017-10-12', '2017-10-13', '2017-10-14', '2017-10-15', '2017-10-16', '2017-10-17', '2017-10-18', '2017-10-19', '2017-10-20', '2017-10-21', '2017-10-22', '2017-10-23', '2017-10-24', '2017-10-25', '2017-10-26', '2017-10-27', '2017-10-28', '2017-10-29', '2017-10-30', '2017-10-31')
297 (180.6ms) INSERT INTO buffer_auto_populate_slots_824879560
298 (schedule_on, day_of_week_mask, call_type_id, display_order, should_be_populated)
299 VALUES ('2017-10-01', '1', '46', '0', 1), ('2017-10-01', '1', '48', '3', 1), ('2017-10-02', '2', '46', '0', 1), ('2017-10-02', '2', '47', '2', 1), ('2017-10-02', '2', '48', '3', 1), ('2017-10-02', '2', '49', '4', 1), ('2017-10-02', '2', '51', '7', 1), ('2017-10-03', '4', '46', '0', 1), ('2017-10-03', '4', '47', '2', 1), ('2017-10-03', '4', '48', '3', 1), ('2017-10-03', '4', '49', '4', 1), ('2017-10-03', '4', '51', '7', 1), ('2017-10-04', '8', '46', '0', 1), ('2017-10-04', '8', '47', '2', 1), ('2017-10-04', '8', '48', '3', 1), ('2017-10-04', '8', '49', '4', 1), ('2017-10-04', '8', '51', '7', 1), ('2017-10-05', '16', '46', '0', 1), ('2017-10-05', '16', '47', '2', 1), ('2017-10-05', '16', '48', '3', 1), ('2017-10-05', '16', '49', '4', 1), ('2017-10-05', '16', '51', '7', 1), ('2017-10-06', '32', '46', '0', 1), ('2017-10-06', '32', '47', '2', 1), ('2017-10-06', '32', '48', '3', 1), ('2017-10-06', '32', '49', '4', 1), ('2017-10-06', '32', '51', '7', 1), ('2017-10-07', '64', '46', '0', 1), ('2017-10-07', '64', '48', '3', 1), ('2017-10-08', '1', '46', '0', 1), ('2017-10-08', '1', '48', '3', 1), ('2017-10-09', '2', '46', '0', 1), ('2017-10-09', '2', '47', '2', 1), ('2017-10-09', '2', '48', '3', 1), ('2017-10-09', '2', '49', '4', 1), ('2017-10-09', '2', '51', '7', 1), ('2017-10-10', '4', '46', '0', 1), ('2017-10-10', '4', '47', '2', 1), ('2017-10-10', '4', '48', '3', 1), ('2017-10-10', '4', '49', '4', 1), ('2017-10-10', '4', '51', '7', 1), ('2017-10-11', '8', '46', '0', 1), ('2017-10-11', '8', '47', '2', 1), ('2017-10-11', '8', '48', '3', 1), ('2017-10-11', '8', '49', '4', 1), ('2017-10-11', '8', '51', '7', 1), ('2017-10-12', '16', '46', '0', 1), ('2017-10-12', '16', '47', '2', 1), ('2017-10-12', '16', '48', '3', 1), ('2017-10-12', '16', '49', '4', 1), ('2017-10-12', '16', '51', '7', 1), ('2017-10-13', '32', '46', '0', 1), ('2017-10-13', '32', '47', '2', 1), ('2017-10-13', '32', '48', '3', 1), ('2017-10-13', '32', '49', '4', 1), ('2017-10-13', '32', '51', '7', 1), ('2017-10-14', '64', '46', '0', 1), ('2017-10-14', '64', '48', '3', 1), ('2017-10-15', '1', '46', '0', 1), ('2017-10-15', '1', '48', '3', 1), ('2017-10-16', '2', '46', '0', 1), ('2017-10-16', '2', '47', '2', 1), ('2017-10-16', '2', '48', '3', 1), ('2017-10-16', '2', '49', '4', 1), ('2017-10-16', '2', '51', '7', 1), ('2017-10-17', '4', '46', '0', 1), ('2017-10-17', '4', '47', '2', 1), ('2017-10-17', '4', '48', '3', 1), ('2017-10-17', '4', '49', '4', 1), ('2017-10-17', '4', '51', '7', 1), ('2017-10-18', '8', '46', '0', 1), ('2017-10-18', '8', '47', '2', 1), ('2017-10-18', '8', '48', '3', 1), ('2017-10-18', '8', '49', '4', 1), ('2017-10-18', '8', '51', '7', 1), ('2017-10-19', '16', '46', '0', 1), ('2017-10-19', '16', '47', '2', 1), ('2017-10-19', '16', '48', '3', 1), ('2017-10-19', '16', '49', '4', 1), ('2017-10-19', '16', '51', '7', 1), ('2017-10-20', '32', '46', '0', 1), ('2017-10-20', '32', '47', '2', 1), ('2017-10-20', '32', '48', '3', 1), ('2017-10-20', '32', '49', '4', 1), ('2017-10-20', '32', '51', '7', 1), ('2017-10-21', '64', '46', '0', 1), ('2017-10-21', '64', '48', '3', 1), ('2017-10-22', '1', '46', '0', 1), ('2017-10-22', '1', '48', '3', 1), ('2017-10-23', '2', '46', '0', 1), ('2017-10-23', '2', '47', '2', 1), ('2017-10-23', '2', '48', '3', 1), ('2017-10-23', '2', '49', '4', 1), ('2017-10-23', '2', '51', '7', 1), ('2017-10-24', '4', '46', '0', 1), ('2017-10-24', '4', '47', '2', 1), ('2017-10-24', '4', '48', '3', 1), ('2017-10-24', '4', '49', '4', 1), ('2017-10-24', '4', '51', '7', 1), ('2017-10-25', '8', '46', '0', 1), ('2017-10-25', '8', '47', '2', 1), ('2017-10-25', '8', '48', '3', 1), ('2017-10-25', '8', '49', '4', 1), ('2017-10-25', '8', '51', '7', 1), ('2017-10-26', '16', '46', '0', 1), ('2017-10-26', '16', '47', '2', 1), ('2017-10-26', '16', '48', '3', 1), ('2017-10-26', '16', '49', '4', 1), ('2017-10-26', '16', '51', '7', 1), ('2017-10-27', '32', '46', '0', 1), ('2017-10-27', '32', '47', '2', 1), ('2017-10-27', '32', '48', '3', 1), ('2017-10-27', '32', '49', '4', 1), ('2017-10-27', '32', '51', '7', 1), ('2017-10-28', '64', '46', '0', 1), ('2017-10-28', '64', '48', '3', 1), ('2017-10-29', '1', '46', '0', 1), ('2017-10-29', '1', '48', '3', 1), ('2017-10-30', '2', '46', '0', 1), ('2017-10-30', '2', '47', '2', 1), ('2017-10-30', '2', '48', '3', 1), ('2017-10-30', '2', '49', '4', 1), ('2017-10-30', '2', '51', '7', 1), ('2017-10-31', '4', '46', '0', 1), ('2017-10-31', '4', '47', '2', 1), ('2017-10-31', '4', '48', '3', 1), ('2017-10-31', '4', '49', '4', 1), ('2017-10-31', '4', '51', '7', 1)
300
301INFO : (04-03 14:40:55) --> fill: 2 - Scheduler::AutoPopulate::Queries::Query003
302 (154.9ms) insert into buffer_auto_populate_slots_824879560/* client_id */ (
303 schedule_on,
304 day_of_week_mask,
305 call_type_id,
306 display_order,
307 should_be_populated
308 )
309 select distinct
310 date_add(
311 auto_populate_slots.schedule_on,
312 interval soft_linkages.offset day
313 ) as schedule_on,
314 (1 << (
315 dayofweek(
316 date_add(
317 auto_populate_slots.schedule_on,
318 interval soft_linkages.offset day
319 )
320 ) - 1
321 )
322 ) as day_of_week_mask,
323 soft_linkages.linked_call_type_id as call_type_id,
324 call_types.display_order,
325 0 as should_be_populated
326 from
327 buffer_auto_populate_slots_824879560/* client_id */ as auto_populate_slots
328 inner join soft_linkages
329 on auto_populate_slots.call_type_id = soft_linkages.call_type_id
330 and auto_populate_slots.day_of_week_mask = soft_linkages.day_of_week_mask
331 left join buffer_auto_populate_slots_824879560/* client_id */ as auto_populate_slots_2
332 on date_add(
333 auto_populate_slots.schedule_on,
334 interval soft_linkages.offset day
335 ) = auto_populate_slots_2.schedule_on
336 and soft_linkages.linked_call_type_id = auto_populate_slots_2.call_type_id
337 inner join call_types
338 on soft_linkages.linked_call_type_id = call_types.id
339 where auto_populate_slots_2.id is null
340 order by null
341
342INFO : (04-03 14:40:55) --> fill: 3 - Scheduler::AutoPopulate::Queries::Query005
343 (170.3ms) insert into buffer_auto_populate_slots_824879560 (
344 schedule_on,
345 day_of_week_mask,
346 call_type_id,
347 display_order,
348 should_be_populated
349 )
350 select distinct
351 date_add(
352 auto_populate_slots.schedule_on,
353 interval linkage_relations.distance_in_days day
354 ) as schedule_on,
355 (1 << (
356 dayofweek(
357 date_add(
358 auto_populate_slots.schedule_on,
359 interval linkage_relations.distance_in_days day
360 )
361 ) - 1
362 )
363 ) as day_of_week_mask,
364 linkage_relations.linked_call_type_id as call_type_id,
365 call_types.display_order,
366 0 as should_be_populated
367 from
368 buffer_auto_populate_slots_824879560 as auto_populate_slots
369 inner join linkage_relations
370 on auto_populate_slots.call_type_id = linkage_relations.call_type_id
371 and auto_populate_slots.day_of_week_mask = linkage_relations.day_of_week_mask
372 left join buffer_auto_populate_slots_824879560 as auto_populate_slots_2
373 on date_add(
374 auto_populate_slots.schedule_on,
375 interval linkage_relations.distance_in_days day
376 ) = auto_populate_slots_2.schedule_on
377 and linkage_relations.linked_call_type_id = auto_populate_slots_2.call_type_id
378 inner join call_types
379 on linkage_relations.linked_call_type_id = call_types.id
380 where auto_populate_slots_2.id is null
381 order by null
382
383INFO : (04-03 14:40:55) --> fill: 4 - Scheduler::AutoPopulate::Queries::Query01
384 (154.5ms) insert into linkage_relations (
385 client_id,
386 call_type_id,
387 day_of_week_mask,
388 linked_call_type_id,
389 distance_in_days,
390 linkage_template_id
391 )
392 select distinct
393 6 /* client_id */ as client_id,
394 aps.call_type_id,
395 aps.day_of_week_mask,
396 aps.call_type_id as linked_call_type_id,
397 0 as distance_in_days,
398 coalesce(
399 lr.linkage_template_id,
400 @linkage_template_max := @linkage_template_max + 1
401 ) as linkage_template_id
402 from
403 buffer_auto_populate_slots_824879560/* client_id */ as aps
404 inner join (
405 select @linkage_template_max := count(distinct linkage_template_id) - 1
406 from linkage_relations
407 where client_id = 6 /* client_id */
408 order by null
409 ) as lt
410 on 1 = 1
411 left join linkage_relations as lr use index (ix_linkage_relations_composite1)
412 on aps.call_type_id = lr.call_type_id
413 and aps.day_of_week_mask = lr.day_of_week_mask
414 left join linkage_relations as lr_2 use index (ix_linkage_relations_composite1)
415 on aps.call_type_id = lr_2.call_type_id
416 and aps.day_of_week_mask = lr_2.day_of_week_mask
417 and aps.call_type_id = lr_2.linked_call_type_id
418 and lr_2.distance_in_days = 0
419 where lr_2.id is null
420 order by null
421
422 (165.3ms) insert into buffer_schedules_824879560 (
423 call_type_id,
424 staff_id,
425 schedule_on,
426 day_of_week_mask,
427 is_weekend,
428 display_order,
429 week_number,
430 should_be_evaluated,
431 should_be_populated,
432 linkage_instance_id
433 )
434 select
435 call_type_id,
436 staff_id,
437 schedule_on,
438 day_of_week_mask,
439 is_weekend,
440 display_order,
441 week_number,
442 max(should_be_evaluated) as should_be_evaluated,
443 max(should_be_populated) as should_be_populated,
444 min(linkage_instance_id) as linkage_instance_id
445 from (
446 select
447 auto_populate_slots_2.call_type_id,
448 schedules.staff_id,
449 auto_populate_slots_2.schedule_on,
450 auto_populate_slots_2.day_of_week_mask,
451 case
452 when (auto_populate_slots_2.day_of_week_mask & 62 > 0) then 0
453 else 1
454 end as is_weekend,
455 auto_populate_slots_2.display_order,
456 yearweek(
457 auto_populate_slots_2.schedule_on,
458 case
459 when (clients.start_of_week = 0) then 2
460 else 7
461 end
462 ) as week_number,
463 case
464 when (schedules.staff_id is null) then 1
465 else 0
466 end as should_be_evaluated,
467 (
468 case
469 when (
470 auto_populate_slots_2.should_be_populated = 1
471 and schedules.staff_id is null
472 ) then 1
473 else 0
474 end
475 ) as should_be_populated,
476 (
477 linkage_relations.linkage_template_id * 1000000 +
478 yearweek(
479 auto_populate_slots.schedule_on,
480 case
481 when (clients.start_of_week = 0) then 2
482 else 7
483 end
484 )
485 ) as linkage_instance_id
486 from
487 buffer_auto_populate_slots_824879560 as auto_populate_slots
488 inner join clients
489 on clients.id = 6 /* client_id */
490 inner join linkage_relations
491 on auto_populate_slots.call_type_id = linkage_relations.call_type_id
492 and auto_populate_slots.day_of_week_mask = linkage_relations.day_of_week_mask
493 inner join buffer_auto_populate_slots_824879560 as auto_populate_slots_2
494 on date_add(
495 auto_populate_slots.schedule_on,
496 interval linkage_relations.distance_in_days day
497 ) = auto_populate_slots_2.schedule_on
498 and linkage_relations.linked_call_type_id = auto_populate_slots_2.call_type_id
499 left join schedules
500 on auto_populate_slots_2.call_type_id = schedules.call_type_id
501 and auto_populate_slots_2.schedule_on = schedules.schedule_on
502 order by null
503 ) as t1
504 group by
505 call_type_id,
506 staff_id,
507 schedule_on,
508 day_of_week_mask,
509 display_order,
510 week_number
511 order by null
512
513INFO : (04-03 14:40:56) --> fill: 5 - Scheduler::AutoPopulate::Queries::Query012
514 (175.5ms) update
515 buffer_schedules_824879560 as sc
516 inner join call_types as ct
517 on sc.call_type_id = ct.id
518 inner join calendar_schedules as cs
519 on ct.calendar_schedule_id = cs.id
520 inner join blocks as b
521 on cs.block_schedule_id = b.block_schedule_id
522 and sc.schedule_on between b.start_date and b.end_date
523 set
524 sc.calendar_schedule_id = cs.id,
525 sc.block_id = b.id
526
527 BlockSchedule Load (152.8ms) SELECT `block_schedules`.* FROM `block_schedules` WHERE `block_schedules`.`id` = 6 LIMIT 1
528 (158.6ms) insert into buffer_periods_824879560 (
529 calendar_schedule_id,
530 block_schedule_id,
531 period_offset,
532 start_block_display_order,
533 end_block_display_order,
534 start_date,
535 end_date,
536 should_be_populated,
537 should_be_evaluated
538 )
539 select
540 t1.calendar_schedule_id,
541 t1.block_schedule_id,
542 t1.period_offset,
543 t2.start_block_display_order,
544 t2.end_block_display_order,
545 t2.start_date,
546 t2.end_date,
547 t1.should_be_populated,
548 t1.should_be_evaluated
549 from (
550 select
551 sc.calendar_schedule_id,
552 b.block_schedule_id,
553 case
554 when ((month(b.start_date) - pt.begin_period) >= 0)
555 then (year(b.start_date) * 100 + (month(b.start_date) - pt.begin_period) div pt.timeframe_type)
556 else
557 ((year(b.start_date) - 1) * 100 + (month(b.start_date) + 12 - pt.begin_period) div pt.timeframe_type)
558 end as period_offset,
559 max(sc.should_be_populated) as should_be_populated,
560 max(sc.should_be_evaluated) as should_be_evaluated
561 from (
562 select
563 sc.block_id,
564 sc.calendar_schedule_id,
565 max(ps.should_be_populated) as should_be_populated,
566 1 as should_be_evaluated
567 from
568 buffer_schedules_824879560 as sc
569 inner join buffer_auto_populate_slots_824879560 as ps
570 on sc.schedule_on = ps.schedule_on
571 and sc.call_type_id = ps.call_type_id
572 group by
573 sc.block_id,
574 sc.calendar_schedule_id
575 order by null
576 ) as sc
577 inner join blocks as b
578 on sc.block_id = b.id
579 inner join population_timeframes as pt
580 on pt.client_id = 6
581 and pt.timeframe_type = 1
582 group by
583 sc.calendar_schedule_id,
584 b.block_schedule_id,
585 period_offset
586 order by null
587 ) as t1
588 inner join (
589 select
590 b.block_schedule_id,
591 case
592 when ((month(b.start_date) - pt.begin_period) >= 0)
593 then (year(b.start_date) * 100 + (month(b.start_date) - pt.begin_period) div pt.timeframe_type)
594 else
595 ((year(b.start_date) - 1) * 100 + (month(b.start_date) + 12 - pt.begin_period) div pt.timeframe_type)
596 end as period_offset,
597 min(b.display_order) as start_block_display_order,
598 max(b.display_order) as end_block_display_order,
599 min(b.start_date) as start_date,
600 max(b.end_date) as end_date
601 from
602 blocks as b
603 inner join population_timeframes as pt
604 on pt.client_id = 6
605 and pt.timeframe_type = 1
606 where
607 b.client_id = 6
608 group by
609 b.block_schedule_id,
610 period_offset
611 order by null
612 ) as t2
613 on t1.block_schedule_id = t2.block_schedule_id
614 and t1.period_offset = t2.period_offset
615 order by null
616
617 (155.8ms) update
618 buffer_schedules_824879560 as sc
619 inner join buffer_periods_824879560 as p
620 on sc.calendar_schedule_id = p.calendar_schedule_id
621 and sc.schedule_on between p.start_date and p.end_date
622 set sc.period_offset = p.period_offset
623
624INFO : (04-03 14:40:56) --> fill: 6 - Scheduler::AutoPopulate::Queries::QueryTargets
625 (152.6ms) delete from buffer_target_dates
626 where session_id = 824879560
627
628 (152.6ms) select distinct calendar_schedule_id
629 from buffer_periods_824879560
630
631 (163.0ms) insert into buffer_target_dates (
632 session_id,
633 client_id,
634 calendar_schedule_id,
635 block_id,
636 start_date,
637 end_date,
638 block_display_order,
639 period_offset,
640 build_cd_targets,
641 cd_targets_source,
642 copy_cd_targets,
643 build_ct_targets,
644 ct_targets_source,
645 copy_ct_targets,
646 build_oa_targets,
647 oa_targets_source,
648 copy_oa_targets,
649 build_dow_targets,
650 dow_targets_source,
651 copy_dow_targets,
652 build_point_targets,
653 point_targets_source,
654 copy_point_targets,
655 build_hour_targets,
656 hour_targets_source,
657 copy_hour_targets,
658 is_published,
659 affected_by_populate,
660 within_cumulative_period
661 )
662 select
663 824879560 as session_id,
664 6 as client_id,
665 t1.calendar_schedule_id,
666 t1.block_id,
667 t1.start_date,
668 t1.end_date,
669 t1.block_display_order,
670 t1.period_offset,
671 case
672 when (
673 (
674 t1.affected_by_populate = 1 /* CurrentCallDaysTargetsRule */ OR t1.within_cumulative_period = 1 /* CumulativeCallDaysTargetsRule */
675 )
676 and t1.is_published = 0
677 and coalesce(pb.has_unpublished, 1) = 1
678 and cd_u.block_id is null
679 ) then 1
680 else 0
681 end as build_cd_targets,
682 case
683 when (
684 t1.is_published = 1
685 or (
686 pb.has_published = 1
687 and pb.has_unpublished = 0
688 )
689 ) then 'published'
690 when (
691 coalesce(pb.has_published, 0) = 0
692 and coalesce(pb.has_unpublished, 1) = 1
693 and cd_u.block_id is not null
694 ) then 'unpublished'
695 when (
696 pb.has_published = 1
697 and pb.has_unpublished = 1
698 and cd_u.block_id is not null
699 ) then 'both'
700 else ''
701 end as cd_targets_source,
702 0 as copy_cd_targets,
703 case
704 when (
705 (
706 t1.affected_by_populate = 1 /* MonthlyCallMixRule, CurrentWeeklyCallTypeTargetsRule */ OR t1.within_cumulative_period = 1 /* AnnualCallMixRule, CumulativeWeeklyCallTypeTargetsRule */
707 )
708 and t1.is_published = 0
709 and coalesce(pb.has_unpublished, 1) = 1
710 and ct_u.block_id is null
711 ) then 1
712 else 0
713 end as build_ct_targets,
714 case
715 when (
716 t1.is_published = 1
717 or (
718 pb.has_published = 1
719 and pb.has_unpublished = 0
720 )
721 ) then 'published'
722 when (
723 coalesce(pb.has_published, 0) = 0
724 and coalesce(pb.has_unpublished, 1) = 1
725 and ct_u.block_id is not null
726 ) then 'unpublished'
727 when (
728 pb.has_published = 1
729 and pb.has_unpublished = 1
730 and ct_u.block_id is not null
731 ) then 'both'
732 else ''
733 end as ct_targets_source,
734 0 as copy_ct_targets,
735 case
736 when (
737 (
738 t1.affected_by_populate = 1 /* StaffCapacityRule, CurrentWeeklyOverallTargetsRule */ OR t1.within_cumulative_period = 1 /* AnnualTargetsRule, CumulativeWeeklyOverallTargetsRule */
739 )
740 and t1.is_published = 0
741 and oa_u.block_id is null
742 ) then 1
743 else 0
744 end as build_oa_targets,
745 case
746 when (t1.is_published = 1) then 'published'
747 when (oa_u.block_id is not null) then 'unpublished'
748 else ''
749 end as oa_targets_source,
750 0 as copy_oa_targets,
751 case
752 when (
753 (
754 t1.affected_by_populate = 1 /* MonthlyDayOfWeekMixRule */ OR t1.within_cumulative_period = 1 /* AnnualDayOfWeekMixRule */
755 )
756 and t1.is_published = 0
757 and dow_u.block_id is null
758 ) then 1
759 else 0
760 end as build_dow_targets,
761 case
762 when (t1.is_published = 1) then 'published'
763 when (dow_u.block_id is not null) then 'unpublished'
764 else ''
765 end as dow_targets_source,
766 0 as copy_dow_targets,
767 case
768 when (
769 (
770 t1.affected_by_populate = 1 /* CurrentPointTargetsRule, CurrentWeeklyPointTargetsRule */ OR t1.within_cumulative_period = 1 /* CumulativePointTargetsRule, CumulativeWeeklyPointTargetsRule */
771 )
772 and t1.is_published = 0
773 and p_u.block_id is null
774 ) then 1
775 else 0
776 end as build_point_targets,
777 case
778 when (t1.is_published = 1) then 'published'
779 when (p_u.block_id is not null) then 'unpublished'
780 else ''
781 end as point_targets_source,
782 0 as copy_point_targets,
783 case
784 when (
785 (
786 t1.affected_by_populate = 1 /* CurrentHourTargetsRule, CurrentWeeklyHourTargetsRule */ OR t1.within_cumulative_period = 1 /* CumulativeHourTargetsRule, CumulativeWeeklyHourTargetsRule */
787 )
788 and t1.is_published = 0
789 and h_u.block_id is null
790 ) then 1
791 else 0
792 end as build_hour_targets,
793 case
794 when (t1.is_published = 1) then 'published'
795 when (h_u.block_id is not null) then 'unpublished'
796 else ''
797 end as hour_targets_source,
798 0 as copy_hour_targets,
799 t1.is_published,
800 t1.affected_by_populate,
801 t1.within_cumulative_period
802 from (
803 select
804 t1.calendar_schedule_id,
805 b.id as block_id,
806 b.start_date,
807 b.end_date,
808 t1.block_display_order,
809 p.period_offset,
810 case
811 when (t1.block_display_order between t1.start_block_display_order and t1.end_block_display_order) then 1
812 else 0
813 end as affected_by_populate,
814 case
815 when (t1.block_display_order between (t1.timeframe_ending - (4 - 1)) and t1.timeframe_ending) then 1
816 else 0
817 end as within_cumulative_period,
818 case
819 when (pb.id is not null) then 1
820 else 0
821 end as is_published
822 from (
823 select
824 t1.calendar_schedule_id,
825 t1.block_schedule_id,
826 (t1.end_block_display_order - ns.item_number) as block_display_order,
827 t1.start_block_display_order,
828 t1.end_block_display_order,
829 t1.timeframe_ending
830 from (
831 select
832 calendar_schedule_id,
833 block_schedule_id,
834 min(start_block_display_order) as start_block_display_order,
835 max(end_block_display_order) as end_block_display_order,
836 max(
837 case
838 when (should_be_populated = 1) then end_block_display_order
839 else null
840 end
841 ) as timeframe_ending
842 from
843 buffer_periods_824879560
844 group by
845 calendar_schedule_id,
846 block_schedule_id
847 order by null
848 ) as t1
849 inner join numeric_sequence as ns
850 on ns.item_number < 3 /* current targets period */
851 and ns.item_number < 12 /* cumulative targets period */
852 and t1.end_block_display_order >= ns.item_number
853 where
854 (t1.end_block_display_order - ns.item_number) /* block display order */
855 between t1.start_block_display_order and t1.end_block_display_order
856 or (t1.end_block_display_order - ns.item_number)
857 between (t1.timeframe_ending - (12 /* cumulative targets period */ - 1)) and t1.timeframe_ending
858 order by null
859 ) as t1
860 inner join blocks as b
861 on t1.block_schedule_id = b.block_schedule_id
862 and t1.block_display_order = b.display_order
863 left join buffer_periods_824879560 as p
864 on t1.calendar_schedule_id = p.calendar_schedule_id
865 and t1.block_display_order between p.start_block_display_order and p.end_block_display_order
866 left join published_blocks as pb
867 on b.id = pb.block_id
868 and t1.calendar_schedule_id = pb.calendar_schedule_id
869 and pb.assignment_ids is null
870 and pb.days_of_week_mask = 127
871 order by null
872 ) as t1
873 left join (
874 select
875 calendar_schedule_id,
876 block_id
877 from
878 unpublished_call_days_targets
879 where
880 calendar_schedule_id in (6) /* list of calendar schedules */
881 group by
882 calendar_schedule_id,
883 block_id
884 order by null
885 ) as cd_u
886 on t1.calendar_schedule_id = cd_u.calendar_schedule_id
887 and t1.block_id = cd_u.block_id
888 left join (
889 select
890 calendar_schedule_id,
891 block_id
892 from
893 unpublished_call_type_targets
894 where
895 calendar_schedule_id in (6) /* list of calendar schedules */
896 group by
897 calendar_schedule_id,
898 block_id
899 order by null
900 ) as ct_u
901 on t1.calendar_schedule_id = ct_u.calendar_schedule_id
902 and t1.block_id = ct_u.block_id
903 left join (
904 select
905 calendar_schedule_id,
906 block_id
907 from
908 unpublished_targets
909 where
910 calendar_schedule_id in (6) /* list of calendar schedules */
911 group by
912 calendar_schedule_id,
913 block_id
914 order by null
915 ) as oa_u
916 on t1.calendar_schedule_id = oa_u.calendar_schedule_id
917 and t1.block_id = oa_u.block_id
918 left join (
919 select
920 calendar_schedule_id,
921 block_id
922 from
923 unpublished_day_of_week_targets
924 where
925 calendar_schedule_id in (6) /* list of calendar schedules */
926 group by
927 calendar_schedule_id,
928 block_id
929 order by null
930 ) as dow_u
931 on t1.calendar_schedule_id = dow_u.calendar_schedule_id
932 and t1.block_id = dow_u.block_id
933 left join (
934 select
935 calendar_schedule_id,
936 block_id
937 from
938 unpublished_point_targets
939 where
940 calendar_schedule_id in (6) /* list of calendar schedules */
941 group by
942 calendar_schedule_id,
943 block_id
944 order by null
945 ) as p_u
946 on t1.calendar_schedule_id = p_u.calendar_schedule_id
947 and t1.block_id = p_u.block_id
948 left join (
949 select
950 calendar_schedule_id,
951 block_id
952 from
953 unpublished_hour_targets
954 where
955 calendar_schedule_id in (6) /* list of calendar schedules */
956 group by
957 calendar_schedule_id,
958 block_id
959 order by null
960 ) as h_u
961 on t1.calendar_schedule_id = h_u.calendar_schedule_id
962 and t1.block_id = h_u.block_id
963 left join (
964 select
965 pb.calendar_schedule_id,
966 pb.block_id,
967 max(
968 case
969 when (coalesce(pbct.days_of_week_mask, 0) > 0) then 1
970 else 0
971 end
972 ) as has_published,
973 max(
974 case
975 when (coalesce(pbct.days_of_week_mask, 0) < 127) then 1
976 else 0
977 end
978 ) as has_unpublished
979 from (
980 select
981 case
982 when (tg.id is null) then ct.id
983 else tg.id
984 end as assignment_id,
985 case
986 when (tg.id is null) then 'CallType'
987 else 'TargetGroup'
988 end as assignment_type,
989 ct.calendar_schedule_id
990 from
991 call_types as ct
992 left join target_group_calls as tgc
993 on ct.id = tgc.call_type_id
994 left join target_groups as tg
995 on tgc.target_group_id = tg.id
996 and tg.active = 1
997 where
998 ct.calendar_schedule_id in (6) /* list of calendar schedules */
999 and ct.active = 1
1000 and ct.included_in_targets > 0
1001 and ct.days_of_week_mask > 0
1002 group by
1003 assignment_id,
1004 assignment_type,
1005 ct.calendar_schedule_id
1006 order by null
1007 ) as ct
1008 inner join published_blocks as pb
1009 on ct.calendar_schedule_id = pb.calendar_schedule_id
1010 and (
1011 pb.assignment_ids is not null
1012 or pb.days_of_week_mask < 127
1013 )
1014 left join published_block_call_types as pbct
1015 on pb.id = pbct.published_block_id
1016 and ct.assignment_id = pbct.assignment_id
1017 and ct.assignment_type = pbct.assignment_type
1018 group by
1019 pb.calendar_schedule_id,
1020 pb.block_id
1021 order by null
1022 ) as pb
1023 on t1.calendar_schedule_id = pb.calendar_schedule_id
1024 and t1.block_id = pb.block_id
1025 order by null
1026
1027Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0101 - 470.24399999999997ms
1028 (153.1ms) /*
1029 MonthlyCallMixRule, CurrentWeeklyCallTypeTargetsRule, AnnualCallMixRule, CumulativeWeeklyCallTypeTargetsRule,
1030 StaffCapacityRule, CurrentWeeklyOverallTargetsRule, AnnualTargetsRule, CumulativeWeeklyOverallTargetsRule,
1031 MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule
1032 */
1033 update buffer_target_dates
1034 set build_cd_targets = 1
1035 where
1036 session_id = 824879560
1037 and build_cd_targets = 0
1038 and cd_targets_source = ''
1039 and (
1040 build_ct_targets = 1 /* MonthlyCallMixRule, CurrentWeeklyCallTypeTargetsRule, AnnualCallMixRule, CumulativeWeeklyCallTypeTargetsRule */ OR build_oa_targets = 1 /* StaffCapacityRule, CurrentWeeklyOverallTargetsRule, AnnualTargetsRule, CumulativeWeeklyOverallTargetsRule */ OR build_dow_targets = 1 /* MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule */
1041 )
1042
1043 (152.9ms) /*
1044 MonthlyCallMixRule, CurrentWeeklyCallTypeTargetsRule, AnnualCallMixRule, CumulativeWeeklyCallTypeTargetsRule,
1045 StaffCapacityRule, CurrentWeeklyOverallTargetsRule, AnnualTargetsRule, CumulativeWeeklyOverallTargetsRule,
1046 MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule
1047 */
1048 update buffer_target_dates
1049 set
1050 build_ct_targets = 1, ct_targets_source = "" /* MonthlyCallMixRule, CurrentWeeklyCallTypeTargetsRule, AnnualCallMixRule, CumulativeWeeklyCallTypeTargetsRule */,
1051build_oa_targets = 1, oa_targets_source = "" /* StaffCapacityRule, CurrentWeeklyOverallTargetsRule, AnnualTargetsRule, CumulativeWeeklyOverallTargetsRule */,
1052build_dow_targets = 1, dow_targets_source = "" /* MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule */
1053 where
1054 session_id = 824879560
1055 and build_cd_targets = 1
1056
1057Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0102 - 307.256ms
1058 (153.2ms) /*
1059 MonthlyCallMixRule, CurrentWeeklyCallTypeTargetsRule, AnnualCallMixRule, CumulativeWeeklyCallTypeTargetsRule,
1060 StaffCapacityRule, CurrentWeeklyOverallTargetsRule, AnnualTargetsRule, CumulativeWeeklyOverallTargetsRule,
1061 MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule
1062 */
1063
1064 insert into buffer_call_days_targets_824879560 (
1065 calendar_schedule_id,
1066 block_id,
1067 staff_id,
1068 assignment_id,
1069 assignment_type,
1070 day_of_week_mask,
1071 is_weekend,
1072 raw_target,
1073 target,
1074 initial_target,
1075 scheduled,
1076 available_days
1077 )
1078 select
1079 cdt.calendar_schedule_id,
1080 cdt.block_id,
1081 cdt.staff_id,
1082 cdt.assignment_id,
1083 cdt.assignment_type,
1084 cdt.day_of_week_mask,
1085 cdt.is_weekend,
1086 cdt.raw_target,
1087 cdt.target,
1088 cdt.initial_target,
1089 cdt.scheduled,
1090 cdt.available_days
1091 from
1092 buffer_target_dates as td
1093 inner join call_days_targets as cdt
1094 on td.calendar_schedule_id = cdt.calendar_schedule_id
1095 and td.block_id = cdt.block_id
1096 where
1097 td.session_id = 824879560
1098 and td.build_cd_targets = 0
1099 and td.cd_targets_source in ('published', 'both')
1100 and (
1101 td.build_ct_targets = 1 /* MonthlyCallMixRule, CurrentWeeklyCallTypeTargetsRule, AnnualCallMixRule, CumulativeWeeklyCallTypeTargetsRule */
1102OR
1103td.build_oa_targets = 1 /* StaffCapacityRule, CurrentWeeklyOverallTargetsRule, AnnualTargetsRule, CumulativeWeeklyOverallTargetsRule */
1104OR
1105td.build_dow_targets = 1 /* MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule */
1106 )
1107 order by null
1108
1109 (153.5ms) /*
1110 MonthlyCallMixRule, CurrentWeeklyCallTypeTargetsRule, AnnualCallMixRule, CumulativeWeeklyCallTypeTargetsRule,
1111 StaffCapacityRule, CurrentWeeklyOverallTargetsRule, AnnualTargetsRule, CumulativeWeeklyOverallTargetsRule,
1112 MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule
1113 */
1114 insert into buffer_call_days_targets_824879560 (
1115 calendar_schedule_id,
1116 block_id,
1117 staff_id,
1118 assignment_id,
1119 assignment_type,
1120 day_of_week_mask,
1121 is_weekend,
1122 raw_target,
1123 target,
1124 initial_target,
1125 scheduled,
1126 available_days
1127 )
1128 select
1129 ucdt.calendar_schedule_id,
1130 ucdt.block_id,
1131 ucdt.staff_id,
1132 ucdt.assignment_id,
1133 ucdt.assignment_type,
1134 ucdt.day_of_week_mask,
1135 ucdt.is_weekend,
1136 ucdt.raw_target,
1137 ucdt.target,
1138 ucdt.initial_target,
1139 ucdt.scheduled,
1140 ucdt.available_days
1141 from
1142 buffer_target_dates as td
1143 inner join unpublished_call_days_targets as ucdt
1144 on td.calendar_schedule_id = ucdt.calendar_schedule_id
1145 and td.block_id = ucdt.block_id
1146 where
1147 td.session_id = 824879560
1148 and td.build_cd_targets = 0
1149 and td.cd_targets_source in ('unpublished', 'both')
1150 and (
1151 td.build_ct_targets = 1 /* MonthlyCallMixRule, CurrentWeeklyCallTypeTargetsRule, AnnualCallMixRule, CumulativeWeeklyCallTypeTargetsRule */
1152OR
1153td.build_oa_targets = 1 /* StaffCapacityRule, CurrentWeeklyOverallTargetsRule, AnnualTargetsRule, CumulativeWeeklyOverallTargetsRule */
1154OR
1155td.build_dow_targets = 1 /* MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule */
1156 )
1157 order by null
1158
1159Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0103 - 307.83500000000004ms
1160 (153.3ms) select
1161 max(build_cd_targets) as build_cd_targets,
1162 max(build_ct_targets) as build_ct_targets,
1163 max(build_oa_targets) as build_oa_targets,
1164 max(build_dow_targets) as build_dow_targets,
1165 max(build_point_targets) as build_point_targets,
1166 max(build_hour_targets) as build_hour_targets
1167 from buffer_target_dates
1168 where session_id = 824879560
1169 order by null
1170
1171Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets02 - 153.701ms
1172 (152.9ms) select distinct calendar_schedule_id
1173 from buffer_target_dates
1174 where
1175 session_id = 824879560
1176 and (
1177 build_cd_targets = 1
1178 or build_ct_targets = 1
1179 or build_oa_targets = 1
1180 or build_dow_targets = 1
1181 )
1182
1183 (154.8ms) truncate table buffer_target_call_types_824879560
1184
1185 (155.7ms) insert into buffer_target_call_types_824879560 (
1186 id,
1187 target_group_id,
1188 assignment_id,
1189 assignment_type,
1190 calendar_schedule_id,
1191 days_of_week_mask,
1192 hours,
1193 points_days_of_week_mask,
1194 included_in_targets,
1195 all_staff_types,
1196 location_id
1197 )
1198 select
1199 ct.id,
1200 coalesce(tg.id, 0) as target_group_id,
1201 case
1202 when (tg.id is null) then ct.id
1203 else tg.id
1204 end as assignment_id,
1205 case
1206 when (tg.id is null) then 'CallType'
1207 else 'TargetGroup'
1208 end as assignment_type,
1209 ct.calendar_schedule_id,
1210 ct.days_of_week_mask,
1211 null as hours,
1212 null as points_days_of_week_mask,
1213 ct.included_in_targets,
1214 ct.all_staff_types,
1215 ct.location_id
1216 from
1217 call_types as ct
1218 left join target_group_calls as tgc
1219 on ct.id = tgc.call_type_id
1220 left join target_groups as tg
1221 on tgc.target_group_id = tg.id
1222 and tg.active = 1
1223 where
1224 ct.calendar_schedule_id in (6)
1225 and ct.active = 1
1226 and ct.days_of_week_mask > 0
1227 and ct.included_in_targets > 0
1228 order by null
1229
1230Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets02Calls - 464.72ms
1231 (164.9ms) select id from buffer_target_call_types_824879560 limit 1
1232 Block Exists (154.0ms) SELECT 1 AS one FROM `blocks` INNER JOIN `published_blocks` ON `published_blocks`.`block_id` = `blocks`.`id` INNER JOIN `block_schedules` ON `blocks`.`block_schedule_id` = `block_schedules`.`id` WHERE `block_schedules`.`id` = 6 LIMIT 1
1233 Block Load (154.8ms) SELECT `blocks`.* FROM `blocks` INNER JOIN `published_blocks` ON `published_blocks`.`block_id` = `blocks`.`id` INNER JOIN `block_schedules` ON `blocks`.`block_schedule_id` = `block_schedules`.`id` WHERE `block_schedules`.`id` = 6 ORDER BY start_date DESC, end_date DESC, blocks.start_date DESC LIMIT 1
1234 Block Load (153.1ms) SELECT `blocks`.* FROM `blocks` WHERE `blocks`.`client_id` = 6 AND `blocks`.`block_schedule_id` = 6 AND (blocks.end_date > '2017-09-30') AND (blocks.id != 16540) ORDER BY start_date asc LIMIT 1
1235 (155.5ms) truncate table buffer_location_privileges_824879560
1236
1237 (156.7ms) insert into buffer_location_privileges_824879560 (
1238 staff_id,
1239 location_id,
1240 begin_date,
1241 end_date
1242 )
1243 select
1244 s.id as staff_id,
1245 l.location_id,
1246 '0000-00-00' as begin_date,
1247 '9999-12-31' as end_date
1248 from (
1249 select
1250 l.id as location_id
1251 from
1252 buffer_target_call_types_824879560 as ct
1253 inner join locations as l
1254 on ct.location_id = l.id
1255 and l.active = 1
1256 group by
1257 l.id
1258 order by null
1259 ) as l
1260 inner join staffs as s
1261 on s.client_id = 6
1262 and s.active = 1
1263 and s.take_call = 1
1264 left join location_privileges as lp
1265 on s.id = lp.staff_id
1266 where
1267 lp.id is null
1268 union
1269 select
1270 lp.staff_id,
1271 lp.location_id,
1272 lp.begin_date,
1273 coalesce(lp.end_date, '9999-12-31') as end_date
1274 from (
1275 select
1276 l.id as location_id
1277 from
1278 buffer_target_call_types_824879560 as ct
1279 inner join locations as l
1280 on ct.location_id = l.id
1281 and l.active = 1
1282 group by
1283 l.id
1284 order by null
1285 ) as l
1286 inner join location_privileges as lp
1287 on l.location_id = lp.location_id
1288 order by null
1289
1290 (159.2ms) truncate table buffer_target_primary_availabilities_824879560
1291
1292 (162.9ms) insert into buffer_target_primary_availabilities_824879560 (
1293 staff_id,
1294 call_type_id,
1295 target_group_id,
1296 assignment_id,
1297 assignment_type,
1298 calendar_schedule_id,
1299 day_of_week_mask,
1300 is_weekend,
1301 staff_type_id,
1302 st_begin_date,
1303 st_end_date,
1304 location_id,
1305 lp_begin_date,
1306 lp_end_date,
1307 included_in_targets
1308 )
1309 select distinct straight_join
1310 s.id as staff_id,
1311 ct.id as call_type_id,
1312 ct.target_group_id,
1313 ct.assignment_id,
1314 ct.assignment_type,
1315 ct.calendar_schedule_id,
1316 t1.day_of_week_mask,
1317 t1.is_weekend,
1318 ast.staff_type_id,
1319 ast.begin_date as st_begin_date,
1320 coalesce(ast.end_date, '9999-12-31') as st_end_date,
1321 lp.location_id,
1322 lp.begin_date as lp_begin_date,
1323 lp.end_date as lp_end_date,
1324 ct.included_in_targets
1325 from (
1326 select 1 as day_of_week_mask, 1 as is_weekend
1327 union select 2, 0
1328 union select 4, 0
1329 union select 8, 0
1330 union select 16, 0
1331 union select 32, 0
1332 union select 64, 1
1333 ) as t1
1334 inner join buffer_target_call_types_824879560 as ct
1335 on (t1.day_of_week_mask & ct.days_of_week_mask) > 0
1336 and ct.all_staff_types = 1
1337 inner join staff_call_types as sct
1338 on ct.id = sct.call_type_id
1339 -- 1st pass (assignments)
1340 and ((
1341 ct.included_in_targets & 1 > 0
1342 and t1.day_of_week_mask & sct.days_of_week_mask > 0
1343 )
1344 or (
1345 ct.included_in_targets & 2 > 0
1346 and t1.day_of_week_mask & sct.secondary_availability_days_of_week_mask > 0
1347 )
1348 )
1349
1350 inner join staffs as s
1351 on sct.staff_id = s.id
1352 and s.active = 1
1353 and s.take_call = 1
1354 inner join buffer_location_privileges_824879560 as lp
1355 on s.id = lp.staff_id
1356 and ct.location_id = lp.location_id
1357 and coalesce(lp.end_date, '9999-12-31') >= '2017-10-01' /* current targets begin date */
1358 inner join assign_staff_types as ast
1359 on s.id = ast.staff_id
1360 and coalesce(ast.end_date, '9999-12-31') >= '2017-10-01' /* current targets begin date */
1361
1362 where
1363 ast.begin_date <= coalesce(lp.end_date, '9999-12-31')
1364 and lp.begin_date <= coalesce(ast.end_date, '9999-12-31')
1365
1366 order by null
1367
1368 (171.0ms) insert into buffer_target_primary_availabilities_824879560 (
1369 staff_id,
1370 call_type_id,
1371 target_group_id,
1372 assignment_id,
1373 assignment_type,
1374 calendar_schedule_id,
1375 day_of_week_mask,
1376 is_weekend,
1377 staff_type_id,
1378 st_begin_date,
1379 st_end_date,
1380 location_id,
1381 lp_begin_date,
1382 lp_end_date,
1383 included_in_targets
1384 )
1385 select distinct straight_join
1386 s.id as staff_id,
1387 ct.id as call_type_id,
1388 ct.target_group_id,
1389 ct.assignment_id,
1390 ct.assignment_type,
1391 ct.calendar_schedule_id,
1392 t1.day_of_week_mask,
1393 t1.is_weekend,
1394 ast.staff_type_id,
1395 ast.begin_date as st_begin_date,
1396 coalesce(ast.end_date, '9999-12-31') as st_end_date,
1397 lp.location_id,
1398 lp.begin_date as lp_begin_date,
1399 lp.end_date as lp_end_date,
1400 ct.included_in_targets
1401 from (
1402 select 1 as day_of_week_mask, 1 as is_weekend
1403 union select 2, 0
1404 union select 4, 0
1405 union select 8, 0
1406 union select 16, 0
1407 union select 32, 0
1408 union select 64, 1
1409 ) as t1
1410 inner join buffer_target_call_types_824879560 as ct
1411 on (t1.day_of_week_mask & ct.days_of_week_mask) > 0
1412 and ct.all_staff_types = 0
1413 inner join staff_call_types as sct
1414 on ct.id = sct.call_type_id
1415 -- 1st pass (assignments)
1416 and ((
1417 ct.included_in_targets & 1 > 0
1418 and t1.day_of_week_mask & sct.days_of_week_mask > 0
1419 )
1420 or (
1421 ct.included_in_targets & 2 > 0
1422 and t1.day_of_week_mask & sct.secondary_availability_days_of_week_mask > 0
1423 )
1424 )
1425
1426 inner join staffs as s
1427 on sct.staff_id = s.id
1428 and s.active = 1
1429 and s.take_call = 1
1430 inner join buffer_location_privileges_824879560 as lp
1431 on s.id = lp.staff_id
1432 and ct.location_id = lp.location_id
1433 and coalesce(lp.end_date, '9999-12-31') >= '2017-10-01' /* current targets begin date */
1434 inner join assign_staff_types as ast
1435 on s.id = ast.staff_id
1436 and coalesce(ast.end_date, '9999-12-31') >= '2017-10-01' /* current targets begin date */
1437 inner join eligible_staff_types as est
1438 on ct.id = est.call_type_id
1439 and ast.staff_type_id = est.staff_type_id
1440
1441 where
1442 ast.begin_date <= coalesce(lp.end_date, '9999-12-31')
1443 and lp.begin_date <= coalesce(ast.end_date, '9999-12-31')
1444
1445 order by null
1446
1447Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0201 - 1284.619ms
1448 (153.3ms) select id from buffer_target_primary_availabilities_824879560 limit 1
1449 (185.3ms) insert into buffer_annual_targets_staff_totals_824879560 (
1450 staff_id,
1451 assignment_id,
1452 assignment_type,
1453 calendar_schedule_id,
1454 day_of_week_mask,
1455 is_weekend,
1456 allocated,
1457 estimated_vacation,
1458 available_days,
1459 relative_capacity
1460 )
1461 select distinct
1462 pa.staff_id,
1463 pa.assignment_id,
1464 pa.assignment_type,
1465 pa.calendar_schedule_id,
1466 pa.day_of_week_mask,
1467 pa.is_weekend,
1468 case
1469 when (at_a.id is not null) then at_a.allocated
1470 when (ts.annual_target_view = 'fte') then 1.0
1471 else (t1.assignments_count * 52 / t1.staffs_count)
1472 end as allocated,
1473 coalesce(at_vc.allocated, 0) as estimated_vacation,
1474 (52 - coalesce(at_vc.allocated, 0)) as available_days,
1475 0 as relative_capacity /* will be calculated on the next step */
1476 from
1477 buffer_target_primary_availabilities_824879560 as pa
1478 inner join (
1479 select
1480 assignment_id,
1481 assignment_type,
1482 day_of_week_mask,
1483 count(distinct call_type_id) as assignments_count,
1484 count(distinct staff_id) as staffs_count
1485 from buffer_target_primary_availabilities_824879560
1486 group by
1487 assignment_id,
1488 assignment_type,
1489 day_of_week_mask
1490 order by null
1491 ) as t1
1492 on pa.assignment_id = t1.assignment_id
1493 and pa.assignment_type = t1.assignment_type
1494 and pa.day_of_week_mask = t1.day_of_week_mask
1495 inner join target_autopopulate_timeframes as ts
1496 on pa.calendar_schedule_id = ts.calendar_schedule_id
1497 left join annual_targets as at_a
1498 on pa.staff_id = at_a.staff_id
1499 and pa.assignment_id = at_a.assignment_id
1500 and pa.assignment_type = at_a.assignment_type
1501 and pa.day_of_week_mask = at_a.day_of_week_mask
1502 left join annual_targets as at_vc
1503 on pa.staff_id = at_vc.staff_id
1504 and pa.assignment_id = -1
1505 and pa.assignment_type = 'Vacation'
1506 and pa.day_of_week_mask = at_vc.day_of_week_mask
1507 order by null
1508
1509Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0203 - 185.925ms
1510 (159.5ms) update
1511 buffer_annual_targets_staff_totals_824879560 as atst
1512 inner join (
1513 select
1514 assignment_id,
1515 assignment_type,
1516 day_of_week_mask,
1517 sum(allocated) as allocated_total,
1518 sum(available_days) as available_days_total
1519 from buffer_annual_targets_staff_totals_824879560
1520 group by
1521 assignment_id,
1522 assignment_type,
1523 day_of_week_mask
1524 order by null
1525 ) as t1
1526 on atst.assignment_id = t1.assignment_id
1527 and atst.assignment_type = t1.assignment_type
1528 and atst.day_of_week_mask = t1.day_of_week_mask
1529 set
1530 atst.relative_capacity =
1531 case
1532 when (t1.allocated_total > 0 and t1.available_days_total > 0)
1533 then (atst.allocated / t1.allocated_total) / (atst.available_days / t1.available_days_total) * 100
1534 else 0
1535 end
1536
1537Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0204 - 159.911ms
1538 (155.1ms) truncate table buffer_target_dates_list_824879560
1539
1540 (156.3ms) insert into buffer_target_dates_list_824879560 (
1541 block_id,
1542 calendar_schedule_id,
1543 date,
1544 day_of_week_mask,
1545 is_weekend
1546
1547 )
1548 select
1549 dl.block_id,
1550 dl.calendar_schedule_id,
1551 dl.date,
1552 (1 << (dayofweek(dl.date) - 1)) as day_of_week_mask,
1553 case
1554 when (dayofweek(dl.date) between 2 /* Monday */ and 6 /* Friday */) then 0
1555 else 1
1556 end as is_weekend
1557
1558 from(
1559 select
1560 td.block_id,
1561 td.calendar_schedule_id,
1562 date_add(td.start_date, interval ns.item_number day) as date
1563 from
1564 buffer_target_dates as td
1565 inner join numeric_sequence as ns
1566 on ns.item_number <= datediff(td.end_date, td.start_date)
1567 where
1568 td.session_id = 824879560
1569 and (td.build_cd_targets = 1 OR td.build_ct_targets = 1 OR td.build_oa_targets = 1 OR td.build_dow_targets = 1)
1570 order by null
1571 ) as dl
1572
1573 order by null
1574
1575 (155.6ms) truncate table buffer_tmp_targets_availabilities_824879560
1576
1577 (164.6ms) insert into buffer_tmp_targets_availabilities_824879560 (
1578 block_id,
1579 calendar_schedule_id,
1580 date,
1581 day_of_week_mask,
1582 is_weekend,
1583 call_type_id,
1584 assignment_id,
1585 assignment_type,
1586 staff_id,
1587 included_in_targets
1588 )
1589 select
1590 dl.block_id,
1591 dl.calendar_schedule_id,
1592 dl.date,
1593 dl.day_of_week_mask,
1594 dl.is_weekend,
1595 pa.call_type_id,
1596 pa.assignment_id,
1597 pa.assignment_type,
1598 pa.staff_id,
1599 pa.included_in_targets
1600 from
1601 buffer_target_dates_list_824879560 as dl
1602 inner join buffer_target_primary_availabilities_824879560 as pa
1603 on dl.calendar_schedule_id = pa.calendar_schedule_id
1604 and dl.day_of_week_mask = pa.day_of_week_mask
1605 and dl.date between pa.st_begin_date and pa.st_end_date
1606 and dl.date between pa.lp_begin_date and pa.lp_end_date
1607 inner join staff_types as st
1608 on pa.staff_type_id = st.id
1609 and st.active = 1
1610 order by null
1611
1612 (154.8ms) truncate table buffer_tmp_targets_availabilities_exclusions_824879560
1613
1614 (159.3ms) insert into buffer_tmp_targets_availabilities_exclusions_824879560 (id)
1615 select ta.id
1616 from
1617 buffer_tmp_targets_availabilities_824879560 as ta
1618 inner join staff_rotations as sr use index (ix_staff_rotations_composite_1)
1619 on ta.staff_id = sr.staff_id
1620 and ta.date between sr.start_date and sr.end_date
1621 inner join rotations as r
1622 on sr.rotation_id = r.id
1623 and r.active = 1
1624 left join rotation_call_types as rct
1625 on sr.rotation_id = rct.rotation_id
1626 and ta.call_type_id = rct.call_type_id
1627 -- 1st pass
1628 and ((
1629 ta.included_in_targets & 1 > 0
1630 and ta.day_of_week_mask & rct.days_of_week_mask > 0
1631 )
1632 or (
1633 ta.included_in_targets & 2 > 0
1634 and ta.day_of_week_mask & rct.secondary_availability_days_of_week_mask > 0
1635 )
1636 )
1637
1638 left join daily_rotations as dr
1639 on ta.date = dr.schedule_on
1640 and ta.staff_id = dr.staff_id
1641 where
1642 rct.id is null
1643 and dr.id is null
1644 order by null
1645
1646 (160.9ms) insert into buffer_tmp_targets_availabilities_exclusions_824879560 (id)
1647 select ta.id
1648 from
1649 buffer_tmp_targets_availabilities_824879560 as ta
1650 inner join daily_rotations as dr
1651 on ta.date = dr.schedule_on
1652 and ta.staff_id = dr.staff_id
1653 inner join rotations as r
1654 on dr.rotation_id = r.id
1655 and r.active = 1
1656 left join rotation_call_types as rct
1657 on dr.rotation_id = rct.rotation_id
1658 and ta.call_type_id = rct.call_type_id
1659 -- 1st pass
1660 and ((
1661 ta.included_in_targets & 1 > 0
1662 and ta.day_of_week_mask & rct.days_of_week_mask > 0
1663 )
1664 or (
1665 ta.included_in_targets & 2 > 0
1666 and ta.day_of_week_mask & rct.secondary_availability_days_of_week_mask > 0
1667 )
1668 )
1669
1670 where rct.id is null
1671 order by null
1672
1673 (171.2ms) insert into buffer_tmp_targets_availabilities_exclusions_824879560 (id)
1674 select ta.id
1675 from
1676 buffer_tmp_targets_availabilities_824879560 as ta
1677 inner join target_autopopulate_timeframes as ts
1678 on ta.calendar_schedule_id = ts.calendar_schedule_id
1679 -- 1st pass
1680 and ts.available_days_in_calls = 1
1681
1682 inner join vacations as v
1683 on ta.date = v.schedule_on
1684 and ta.staff_id = v.staff_id
1685 and v.status = 3 /* status = fulfilled */
1686 order by null
1687
1688Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets03 - 1281.51ms
1689 (155.6ms) truncate table buffer_tmp_targets_scheduled_824879560
1690
1691 (161.2ms) /* Assignment points */
1692 insert into buffer_tmp_targets_scheduled_824879560 (
1693 block_id,
1694 calendar_schedule_id,
1695 staff_id,
1696 assignment_id,
1697 assignment_type,
1698 day_of_week_mask,
1699 is_weekend,
1700 scheduled,
1701 other_scheduled
1702 )
1703 select
1704 dl.block_id,
1705 dl.calendar_schedule_id,
1706 sc.staff_id,
1707 ct.assignment_id,
1708 ct.assignment_type,
1709 dl.day_of_week_mask,
1710 dl.is_weekend,
1711 count(sc.id) as _scheduled,
1712 0 as other_scheduled
1713 from
1714 buffer_target_dates_list_824879560 as dl
1715 inner join buffer_target_call_types_824879560 as ct
1716 on dl.calendar_schedule_id = ct.calendar_schedule_id
1717 and (dl.day_of_week_mask & ct.days_of_week_mask) > 0
1718 inner join schedules as sc
1719 on dl.date = sc.schedule_on
1720 and ct.id = sc.call_type_id
1721 group by
1722 dl.block_id,
1723 dl.calendar_schedule_id,
1724 sc.staff_id,
1725 ct.assignment_id,
1726 ct.assignment_type,
1727 dl.day_of_week_mask,
1728 dl.is_weekend
1729 having
1730 _scheduled != 0
1731 order by null
1732
1733 (155.1ms) truncate table buffer_tmp_targets_staff_totals_824879560
1734
1735 (178.1ms) insert into buffer_tmp_targets_staff_totals_824879560 (
1736 block_id,
1737 calendar_schedule_id,
1738 staff_id,
1739 assignment_id,
1740 assignment_type,
1741 day_of_week_mask,
1742 is_weekend,
1743 relative_capacity,
1744 available_days,
1745 weighted_days,
1746 scheduled,
1747 other_scheduled
1748 )
1749 select
1750 t1.block_id,
1751 t1.calendar_schedule_id,
1752 t1.staff_id,
1753 t1.assignment_id,
1754 t1.assignment_type,
1755 t1.day_of_week_mask,
1756 t1.is_weekend,
1757 atst.relative_capacity,
1758 t1.available_days,
1759 (t1.available_days * atst.relative_capacity / 100) as weighted_days,
1760 coalesce(sch_t.scheduled, 0) as scheduled,
1761 0 as other_scheduled
1762 from (
1763 select
1764 ta.block_id,
1765 ta.calendar_schedule_id,
1766 ta.staff_id,
1767 ta.assignment_id,
1768 ta.assignment_type,
1769 ta.day_of_week_mask,
1770 ta.is_weekend,
1771 count(distinct ta.date) as available_days
1772 from
1773 buffer_tmp_targets_availabilities_824879560 as ta
1774 left join buffer_tmp_targets_availabilities_exclusions_824879560 as tae
1775 on ta.id = tae.id
1776 where tae.id is null
1777 group by
1778 ta.block_id,
1779 ta.calendar_schedule_id,
1780 ta.staff_id,
1781 ta.assignment_id,
1782 ta.assignment_type,
1783 ta.day_of_week_mask,
1784 ta.is_weekend
1785 order by null
1786 ) as t1
1787 inner join buffer_annual_targets_staff_totals_824879560 as atst
1788 on t1.staff_id = atst.staff_id
1789 and t1.assignment_id = atst.assignment_id
1790 and t1.assignment_type = atst.assignment_type
1791 and t1.day_of_week_mask = atst.day_of_week_mask
1792 inner join (
1793 select
1794 block_id,
1795 calendar_schedule_id,
1796 day_of_week_mask,
1797 count(date) as available_days
1798 from buffer_target_dates_list_824879560
1799 group by
1800 block_id,
1801 calendar_schedule_id,
1802 day_of_week_mask
1803 order by null
1804 ) as dlt
1805 on t1.block_id = dlt.block_id
1806 and t1.calendar_schedule_id = dlt.calendar_schedule_id
1807 and t1.day_of_week_mask = dlt.day_of_week_mask
1808 left join (
1809 select
1810 block_id,
1811 calendar_schedule_id,
1812 staff_id,
1813 assignment_id,
1814 assignment_type,
1815 day_of_week_mask,
1816 sum(scheduled) as scheduled
1817 from buffer_tmp_targets_scheduled_824879560
1818 group by
1819 block_id,
1820 calendar_schedule_id,
1821 staff_id,
1822 assignment_id,
1823 assignment_type,
1824 day_of_week_mask
1825 order by null
1826 ) as sch_t
1827 on t1.block_id = sch_t.block_id
1828 and t1.calendar_schedule_id = sch_t.calendar_schedule_id
1829 and t1.staff_id = sch_t.staff_id
1830 and t1.assignment_id = sch_t.assignment_id
1831 and t1.assignment_type = sch_t.assignment_type
1832 and t1.day_of_week_mask = sch_t.day_of_week_mask
1833 order by null
1834
1835 (156.4ms) truncate table buffer_tmp_targets_client_totals_824879560
1836
1837 (160.2ms) insert into buffer_tmp_targets_client_totals_824879560 (
1838 block_id,
1839 calendar_schedule_id,
1840 assignment_id,
1841 assignment_type,
1842 day_of_week_mask,
1843 is_weekend,
1844 targets_total,
1845 weighted_days_total
1846 )
1847 select
1848 st.block_id,
1849 st.calendar_schedule_id,
1850 st.assignment_id,
1851 st.assignment_type,
1852 st.day_of_week_mask,
1853 st.is_weekend,
1854 ca.assignments_total as targets_total,
1855 sum(st.weighted_days) as weighted_days_total
1856 from
1857 buffer_tmp_targets_staff_totals_824879560 as st
1858 inner join (
1859 select
1860 dl.block_id,
1861 dl.calendar_schedule_id,
1862 ct.assignment_id,
1863 ct.assignment_type,
1864 dl.day_of_week_mask,
1865 sum(
1866 case
1867 when ((
1868 ts.use_non_targeted_staff = 0
1869 or sc.id is null
1870 or pa.staff_id is not null
1871 )
1872 and (
1873 ts.remove_slots_from_denominator_targets = 0
1874 or ae.id is null
1875 )
1876 ) then 1
1877 else 0
1878 end
1879 ) as assignments_total
1880 from
1881 buffer_target_dates_list_824879560 as dl
1882 inner join buffer_target_call_types_824879560 as ct
1883 on dl.calendar_schedule_id = ct.calendar_schedule_id
1884 and (dl.day_of_week_mask & ct.days_of_week_mask) > 0
1885 inner join target_autopopulate_timeframes as ts
1886 on dl.calendar_schedule_id = ts.calendar_schedule_id
1887 left join schedules as sc
1888 on dl.date = sc.schedule_on
1889 and ct.id = sc.call_type_id
1890 left join autopopulate_exclusions as ae
1891 on dl.date = ae.schedule_on
1892 and ct.id = ae.call_type_id
1893 left join buffer_target_primary_availabilities_824879560 as pa
1894 on sc.staff_id = pa.staff_id
1895 and ct.id = pa.call_type_id
1896 and dl.day_of_week_mask = pa.day_of_week_mask
1897 and dl.date between pa.st_begin_date and pa.st_end_date
1898 and dl.date between pa.lp_begin_date and pa.lp_end_date
1899 group by
1900 dl.block_id,
1901 dl.calendar_schedule_id,
1902 ct.assignment_id,
1903 ct.assignment_type,
1904 dl.day_of_week_mask
1905 order by null
1906 ) as ca
1907 on st.block_id = ca.block_id
1908 and st.calendar_schedule_id = ca.calendar_schedule_id
1909 and st.assignment_id = ca.assignment_id
1910 and st.assignment_type = ca.assignment_type
1911 and st.day_of_week_mask = ca.day_of_week_mask
1912 group by
1913 st.block_id,
1914 st.calendar_schedule_id,
1915 st.assignment_id,
1916 st.assignment_type,
1917 st.day_of_week_mask,
1918 st.is_weekend,
1919 ca.assignments_total
1920 order by null
1921
1922 (160.1ms) insert into buffer_call_days_targets_824879560 (
1923 block_id,
1924 calendar_schedule_id,
1925 staff_id,
1926 assignment_id,
1927 assignment_type,
1928 day_of_week_mask,
1929 is_weekend,
1930 raw_target,
1931 target,
1932 initial_target,
1933 scheduled,
1934 available_days
1935 )
1936 select
1937 st.block_id,
1938 st.calendar_schedule_id,
1939 st.staff_id,
1940 st.assignment_id,
1941 st.assignment_type,
1942 st.day_of_week_mask,
1943 st.is_weekend,
1944 case
1945 when (ct.weighted_days_total > 0)
1946 then (ct.targets_total * st.weighted_days / ct.weighted_days_total)
1947 else 0
1948 end as raw_target,
1949 case
1950 when (ct.weighted_days_total > 0)
1951 then (ct.targets_total * st.weighted_days / ct.weighted_days_total)
1952 else 0
1953 end as target,
1954 case
1955 when (ct.weighted_days_total > 0)
1956 then (ct.targets_total * st.weighted_days / ct.weighted_days_total)
1957 else 0
1958 end as initial_target,
1959 st.scheduled,
1960 st.available_days
1961 from
1962 buffer_tmp_targets_staff_totals_824879560 as st
1963 inner join buffer_tmp_targets_client_totals_824879560 as ct
1964 on st.block_id = ct.block_id
1965 and st.calendar_schedule_id = ct.calendar_schedule_id
1966 and st.assignment_id = ct.assignment_id
1967 and st.assignment_type = ct.assignment_type
1968 and st.day_of_week_mask = ct.day_of_week_mask
1969 order by null
1970
1971 (158.7ms) update
1972 buffer_call_days_targets_824879560 as cdt
1973 left join call_days_targets as pcdt
1974 on cdt.block_id = pcdt.block_id
1975 and cdt.calendar_schedule_id = pcdt.calendar_schedule_id
1976 and cdt.staff_id = pcdt.staff_id
1977 and cdt.assignment_id = pcdt.assignment_id
1978 and cdt.assignment_type = pcdt.assignment_type
1979 and cdt.day_of_week_mask = pcdt.day_of_week_mask
1980 left join call_type_adjusted_targets as ctat
1981 on cdt.block_id = ctat.block_id
1982 and cdt.calendar_schedule_id = ctat.calendar_schedule_id
1983 and cdt.staff_id = ctat.staff_id
1984 and cdt.assignment_id = ctat.assignment_id
1985 and cdt.assignment_type = ctat.assignment_type
1986 and cdt.day_of_week_mask = ctat.day_of_week_mask
1987 set
1988 cdt.raw_target =
1989 case
1990 when (pcdt.id is not null) then pcdt.raw_target
1991 else cdt.raw_target
1992 end,
1993 cdt.target =
1994 case
1995 when (pcdt.id is not null) then pcdt.target
1996 when (ctat.id is not null) then ctat.target
1997 else cdt.target
1998 end,
1999 cdt.initial_target =
2000 case
2001 when (pcdt.id is not null) then pcdt.initial_target
2002 else cdt.initial_target
2003 end
2004
2005 (302.4ms) insert into buffer_call_days_targets_824879560 (
2006 block_id,
2007 calendar_schedule_id,
2008 staff_id,
2009 assignment_id,
2010 assignment_type,
2011 day_of_week_mask,
2012 is_weekend,
2013 raw_target,
2014 target,
2015 initial_target,
2016 scheduled,
2017 available_days
2018 )
2019 select
2020 sch_t.block_id,
2021 sch_t.calendar_schedule_id,
2022 sch_t.staff_id,
2023 sch_t.assignment_id,
2024 sch_t.assignment_type,
2025 sch_t.day_of_week_mask,
2026 sch_t.is_weekend,
2027 0.0 as raw_target,
2028 0.0 as target,
2029 0.0 as initial_target,
2030 sum(sch_t.scheduled) as scheduled,
2031 0 as available_days
2032 from
2033 buffer_tmp_targets_scheduled_824879560 as sch_t
2034 left join buffer_call_days_targets_824879560 as cdt
2035 on sch_t.block_id = cdt.block_id
2036 and sch_t.calendar_schedule_id = cdt.calendar_schedule_id
2037 and sch_t.staff_id = cdt.staff_id
2038 and sch_t.assignment_id = cdt.assignment_id
2039 and sch_t.assignment_type = cdt.assignment_type
2040 and sch_t.day_of_week_mask = cdt.day_of_week_mask
2041 where
2042 sch_t.scheduled != 0
2043 and cdt.id is null
2044 group by
2045 sch_t.block_id,
2046 sch_t.calendar_schedule_id,
2047 sch_t.staff_id,
2048 sch_t.assignment_id,
2049 sch_t.assignment_type,
2050 sch_t.day_of_week_mask,
2051 sch_t.is_weekend
2052 order by null
2053
2054Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets05 - 1592.0240000000001ms
2055 (185.2ms) insert into buffer_targets_824879560 (
2056 block_id,
2057 calendar_schedule_id,
2058 staff_id,
2059 is_weekend,
2060 target,
2061 scheduled,
2062 raw_target,
2063 available_days
2064 )
2065 select
2066 cdt.block_id,
2067 cdt.calendar_schedule_id,
2068 cdt.staff_id,
2069 cdt.is_weekend,
2070 sum(cdt.target) as target,
2071 sum(cdt.scheduled) as scheduled,
2072 sum(cdt.raw_target) as raw_target,
2073 coalesce(t1.available_days, 0) as available_days
2074 from
2075 buffer_target_dates as td
2076 inner join buffer_call_days_targets_824879560 as cdt
2077 on td.block_id = cdt.block_id
2078 and td.calendar_schedule_id = cdt.calendar_schedule_id
2079 left join (
2080 select
2081 ta.block_id,
2082 ta.calendar_schedule_id,
2083 ta.staff_id,
2084 ta.is_weekend,
2085 count(distinct ta.date) as available_days
2086 from
2087 buffer_target_dates as td
2088 inner join buffer_tmp_targets_availabilities_824879560 as ta
2089 on td.block_id = ta.block_id
2090 and td.calendar_schedule_id = ta.calendar_schedule_id
2091 left join buffer_tmp_targets_availabilities_exclusions_824879560 as tae
2092 on ta.id = tae.id
2093 where td.session_id = 824879560
2094 and td.build_oa_targets = 1
2095 and tae.id is null
2096 group by
2097 ta.block_id,
2098 ta.calendar_schedule_id,
2099 ta.staff_id,
2100 ta.is_weekend
2101 order by null
2102 ) as t1
2103 on cdt.block_id = t1.block_id
2104 and cdt.calendar_schedule_id = t1.calendar_schedule_id
2105 and cdt.staff_id = t1.staff_id
2106 and cdt.is_weekend = t1.is_weekend
2107 where
2108 td.session_id = 824879560
2109 and td.build_oa_targets = 1
2110 group by
2111 cdt.block_id,
2112 cdt.calendar_schedule_id,
2113 cdt.staff_id,
2114 cdt.is_weekend,
2115 t1.available_days
2116 order by null
2117
2118Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0502 - 185.778ms
2119 (175.8ms) insert into buffer_call_type_targets_824879560 (
2120 block_id,
2121 calendar_schedule_id,
2122 staff_id,
2123 assignment_id,
2124 assignment_type,
2125 is_weekend,
2126 raw_target,
2127 target,
2128 initial_target,
2129 scheduled,
2130 available_days
2131 )
2132 select
2133 cdt.block_id,
2134 cdt.calendar_schedule_id,
2135 cdt.staff_id,
2136 cdt.assignment_id,
2137 cdt.assignment_type,
2138 cdt.is_weekend,
2139 sum(cdt.raw_target) as raw_target,
2140 sum(cdt.target) as target,
2141 sum(cdt.initial_target) as initial_target,
2142 sum(cdt.scheduled) as scheduled,
2143 coalesce(t1.available_days, 0) as available_days
2144 from buffer_target_dates as td
2145 inner join buffer_call_days_targets_824879560 as cdt
2146 on td.block_id = cdt.block_id
2147 and td.calendar_schedule_id = cdt.calendar_schedule_id
2148 left join (
2149 select
2150 ta.block_id,
2151 ta.calendar_schedule_id,
2152 ta.staff_id,
2153 ta.assignment_id,
2154 ta.assignment_type,
2155 ta.is_weekend,
2156 count(distinct ta.date) as available_days
2157 from buffer_target_dates as td
2158 inner join buffer_tmp_targets_availabilities_824879560 as ta
2159 on td.block_id = ta.block_id
2160 and td.calendar_schedule_id = ta.calendar_schedule_id
2161 left join buffer_tmp_targets_availabilities_exclusions_824879560 as tae
2162 on ta.id = tae.id
2163 where td.session_id = 824879560
2164 and td.build_ct_targets = 1
2165 and tae.id is null
2166 group by
2167 ta.block_id,
2168 ta.calendar_schedule_id,
2169 ta.staff_id,
2170 ta.assignment_id,
2171 ta.assignment_type,
2172 ta.is_weekend
2173 order by null
2174 ) as t1
2175 on cdt.block_id = t1.block_id
2176 and cdt.calendar_schedule_id = t1.calendar_schedule_id
2177 and cdt.staff_id = t1.staff_id
2178 and cdt.assignment_id = t1.assignment_id
2179 and cdt.assignment_type = t1.assignment_type
2180 and cdt.is_weekend = t1.is_weekend
2181 where
2182 td.session_id = 824879560
2183 and td.build_ct_targets = 1
2184 group by
2185 cdt.block_id,
2186 cdt.calendar_schedule_id,
2187 cdt.staff_id,
2188 cdt.assignment_id,
2189 cdt.assignment_type,
2190 cdt.is_weekend,
2191 t1.available_days
2192 order by null
2193
2194Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0503 - 176.269ms
2195 (381.4ms) insert into buffer_day_of_week_targets_824879560 (
2196 block_id,
2197 calendar_schedule_id,
2198 staff_id,
2199 wday,
2200 raw_target,
2201 target,
2202 scheduled,
2203 available_days
2204 )
2205 select
2206 cdt.block_id,
2207 cdt.calendar_schedule_id,
2208 cdt.staff_id,
2209 log2(cdt.day_of_week_mask) as _wday,
2210 sum(cdt.raw_target) as raw_target,
2211 sum(cdt.target) as target,
2212 sum(cdt.scheduled) as scheduled,
2213 coalesce(t1.available_days, 0) as available_days
2214 from
2215 buffer_target_dates as td
2216 inner join buffer_call_days_targets_824879560 as cdt
2217 on td.block_id = cdt.block_id
2218 and td.calendar_schedule_id = cdt.calendar_schedule_id
2219 left join (
2220 select
2221 ta.block_id,
2222 ta.calendar_schedule_id,
2223 ta.staff_id,
2224 ta.day_of_week_mask,
2225 count(distinct ta.date) as available_days
2226 from
2227 buffer_target_dates as td
2228 inner join buffer_tmp_targets_availabilities_824879560 as ta
2229 on td.block_id = ta.block_id
2230 and td.calendar_schedule_id = ta.calendar_schedule_id
2231 left join buffer_tmp_targets_availabilities_exclusions_824879560 as tae
2232 on ta.id = tae.id
2233 where
2234 td.session_id = 824879560 /* session_id */
2235 and td.build_dow_targets = 1
2236 and tae.id is null
2237 group by
2238 ta.block_id,
2239 ta.calendar_schedule_id,
2240 ta.staff_id,
2241 ta.day_of_week_mask
2242 order by null
2243 ) as t1
2244 on cdt.block_id = t1.block_id
2245 and cdt.calendar_schedule_id = t1.calendar_schedule_id
2246 and cdt.staff_id = t1.staff_id
2247 and cdt.day_of_week_mask = t1.day_of_week_mask
2248 where
2249 td.session_id = 824879560 /* session_id */
2250 and td.build_dow_targets = 1
2251 group by
2252 cdt.block_id,
2253 cdt.calendar_schedule_id,
2254 cdt.staff_id,
2255 _wday,
2256 t1.available_days
2257 order by null;
2258
2259Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets06 - 381.978ms
2260 (152.7ms) select distinct calendar_schedule_id
2261 from buffer_target_dates
2262 where
2263 session_id = 824879560
2264 and build_point_targets = 1
2265
2266 (172.3ms) truncate table buffer_target_call_types_824879560
2267
2268 (160.3ms) insert into buffer_target_call_types_824879560 (
2269 id,
2270 target_group_id,
2271 assignment_id,
2272 assignment_type,
2273 calendar_schedule_id,
2274 days_of_week_mask,
2275 hours,
2276 points_days_of_week_mask,
2277 included_in_targets,
2278 all_staff_types,
2279 location_id
2280 )
2281 select
2282 ct.id,
2283 0 as target_group_id,
2284 ct.id as assignment_id,
2285 'CallType' as assignment_type,
2286 ct.calendar_schedule_id,
2287 ct.days_of_week_mask,
2288 null as hours,
2289 sum((1 << dp.day)) as points_days_of_week_mask,
2290 ct.included_in_targets,
2291 ct.all_staff_types,
2292 ct.location_id
2293 from
2294 call_types as ct
2295 inner join assignment_annotations as aa
2296 on ct.id = aa.assignmentable_id
2297 and aa.assignmentable_type = 'CallType'
2298 and aa.annotation_id = 0 /* annotation = "None" */
2299 and aa.applicable = 1
2300 inner join assignment_annotation_daily_points as dp
2301 on aa.id = dp.assignment_annotation_id
2302 and dp.point != 0
2303 and dp.day <= 6
2304 where
2305 ct.calendar_schedule_id in (6)
2306 and ct.active = 1
2307 and ct.days_of_week_mask > 0
2308 group by
2309 ct.id,
2310 ct.calendar_schedule_id,
2311 ct.days_of_week_mask,
2312 ct.included_in_targets,
2313 ct.all_staff_types,
2314 ct.location_id
2315 order by null
2316
2317 (155.8ms) insert into buffer_target_daily_points_824879560 (
2318 call_type_id,
2319 day,
2320 point
2321 )
2322 select
2323 ct.id as call_type_id,
2324 dp.day,
2325 dp.point
2326 from buffer_target_call_types_824879560 as ct
2327 inner join assignment_annotations as aa
2328 on ct.id = aa.assignmentable_id
2329 and aa.assignmentable_type = 'CallType'
2330 and aa.annotation_id = 0 /* annotation = "None" */
2331 and aa.applicable = 1
2332 inner join assignment_annotation_daily_points as dp
2333 on aa.id = dp.assignment_annotation_id
2334 where dp.point != 0
2335 order by null
2336
2337Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets02Points - 642.851ms
2338 (152.7ms) select id from buffer_target_call_types_824879560 limit 1
2339 (154.9ms) truncate table buffer_location_privileges_824879560
2340
2341 (157.5ms) insert into buffer_location_privileges_824879560 (
2342 staff_id,
2343 location_id,
2344 begin_date,
2345 end_date
2346 )
2347 select
2348 s.id as staff_id,
2349 l.location_id,
2350 '0000-00-00' as begin_date,
2351 '9999-12-31' as end_date
2352 from (
2353 select
2354 l.id as location_id
2355 from
2356 buffer_target_call_types_824879560 as ct
2357 inner join locations as l
2358 on ct.location_id = l.id
2359 and l.active = 1
2360 group by
2361 l.id
2362 order by null
2363 ) as l
2364 inner join staffs as s
2365 on s.client_id = 6
2366 and s.active = 1
2367 and s.take_call = 1
2368 left join location_privileges as lp
2369 on s.id = lp.staff_id
2370 where
2371 lp.id is null
2372 union
2373 select
2374 lp.staff_id,
2375 lp.location_id,
2376 lp.begin_date,
2377 coalesce(lp.end_date, '9999-12-31') as end_date
2378 from (
2379 select
2380 l.id as location_id
2381 from
2382 buffer_target_call_types_824879560 as ct
2383 inner join locations as l
2384 on ct.location_id = l.id
2385 and l.active = 1
2386 group by
2387 l.id
2388 order by null
2389 ) as l
2390 inner join location_privileges as lp
2391 on l.location_id = lp.location_id
2392 order by null
2393
2394 (154.8ms) truncate table buffer_target_primary_availabilities_824879560
2395
2396 (153.9ms) insert into buffer_target_primary_availabilities_824879560 (
2397 staff_id,
2398 call_type_id,
2399 target_group_id,
2400 assignment_id,
2401 assignment_type,
2402 calendar_schedule_id,
2403 day_of_week_mask,
2404 is_weekend,
2405 staff_type_id,
2406 st_begin_date,
2407 st_end_date,
2408 location_id,
2409 lp_begin_date,
2410 lp_end_date,
2411 included_in_targets
2412 )
2413 select distinct straight_join
2414 s.id as staff_id,
2415 ct.id as call_type_id,
2416 ct.target_group_id,
2417 ct.assignment_id,
2418 ct.assignment_type,
2419 ct.calendar_schedule_id,
2420 t1.day_of_week_mask,
2421 t1.is_weekend,
2422 ast.staff_type_id,
2423 ast.begin_date as st_begin_date,
2424 coalesce(ast.end_date, '9999-12-31') as st_end_date,
2425 lp.location_id,
2426 lp.begin_date as lp_begin_date,
2427 lp.end_date as lp_end_date,
2428 ct.included_in_targets
2429 from (
2430 select 1 as day_of_week_mask, 1 as is_weekend
2431 union select 2, 0
2432 union select 4, 0
2433 union select 8, 0
2434 union select 16, 0
2435 union select 32, 0
2436 union select 64, 1
2437 ) as t1
2438 inner join buffer_target_call_types_824879560 as ct
2439 on (t1.day_of_week_mask & ct.days_of_week_mask) > 0
2440 and ct.all_staff_types = 1
2441 inner join staff_call_types as sct
2442 on ct.id = sct.call_type_id
2443
2444 inner join staffs as s
2445 on sct.staff_id = s.id
2446 and s.active = 1
2447 and s.take_call = 1
2448 inner join buffer_location_privileges_824879560 as lp
2449 on s.id = lp.staff_id
2450 and ct.location_id = lp.location_id
2451 and coalesce(lp.end_date, '9999-12-31') >= '2017-10-01' /* current targets begin date */
2452 inner join assign_staff_types as ast
2453 on s.id = ast.staff_id
2454 and coalesce(ast.end_date, '9999-12-31') >= '2017-10-01' /* current targets begin date */
2455
2456 where
2457 ast.begin_date <= coalesce(lp.end_date, '9999-12-31')
2458 and lp.begin_date <= coalesce(ast.end_date, '9999-12-31')
2459
2460 order by null
2461
2462 (169.0ms) insert into buffer_target_primary_availabilities_824879560 (
2463 staff_id,
2464 call_type_id,
2465 target_group_id,
2466 assignment_id,
2467 assignment_type,
2468 calendar_schedule_id,
2469 day_of_week_mask,
2470 is_weekend,
2471 staff_type_id,
2472 st_begin_date,
2473 st_end_date,
2474 location_id,
2475 lp_begin_date,
2476 lp_end_date,
2477 included_in_targets
2478 )
2479 select distinct straight_join
2480 s.id as staff_id,
2481 ct.id as call_type_id,
2482 ct.target_group_id,
2483 ct.assignment_id,
2484 ct.assignment_type,
2485 ct.calendar_schedule_id,
2486 t1.day_of_week_mask,
2487 t1.is_weekend,
2488 ast.staff_type_id,
2489 ast.begin_date as st_begin_date,
2490 coalesce(ast.end_date, '9999-12-31') as st_end_date,
2491 lp.location_id,
2492 lp.begin_date as lp_begin_date,
2493 lp.end_date as lp_end_date,
2494 ct.included_in_targets
2495 from (
2496 select 1 as day_of_week_mask, 1 as is_weekend
2497 union select 2, 0
2498 union select 4, 0
2499 union select 8, 0
2500 union select 16, 0
2501 union select 32, 0
2502 union select 64, 1
2503 ) as t1
2504 inner join buffer_target_call_types_824879560 as ct
2505 on (t1.day_of_week_mask & ct.days_of_week_mask) > 0
2506 and ct.all_staff_types = 0
2507 inner join staff_call_types as sct
2508 on ct.id = sct.call_type_id
2509
2510 inner join staffs as s
2511 on sct.staff_id = s.id
2512 and s.active = 1
2513 and s.take_call = 1
2514 inner join buffer_location_privileges_824879560 as lp
2515 on s.id = lp.staff_id
2516 and ct.location_id = lp.location_id
2517 and coalesce(lp.end_date, '9999-12-31') >= '2017-10-01' /* current targets begin date */
2518 inner join assign_staff_types as ast
2519 on s.id = ast.staff_id
2520 and coalesce(ast.end_date, '9999-12-31') >= '2017-10-01' /* current targets begin date */
2521 inner join eligible_staff_types as est
2522 on ct.id = est.call_type_id
2523 and ast.staff_type_id = est.staff_type_id
2524
2525 where
2526 ast.begin_date <= coalesce(lp.end_date, '9999-12-31')
2527 and lp.begin_date <= coalesce(ast.end_date, '9999-12-31')
2528
2529 order by null
2530
2531Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0201 - 793.3059999999999ms
2532 (152.5ms) select id from buffer_target_primary_availabilities_824879560 limit 1
2533 (157.1ms) insert into buffer_annual_point_targets_824879560 (
2534 staff_id,
2535 calendar_schedule_id,
2536 is_weekend,
2537 points,
2538 estimated_vacation,
2539 available_days,
2540 relative_capacity
2541 )
2542 select
2543 t1.staff_id,
2544 t1.calendar_schedule_id,
2545 t1.is_weekend,
2546 0 as points, /* will be calculated on the next step */
2547 coalesce(t2.estimated_vacation, 0) as estimated_vacation,
2548 (t1.available_days - coalesce(t2.estimated_vacation, 0)) as available_days,
2549 0 as relative_capacity /* will be calculated on the next step */
2550 from (
2551 select
2552 staff_id,
2553 calendar_schedule_id,
2554 is_weekend,
2555 case
2556 when (is_weekend = 0) then (5 * 52)
2557 else (2 * 52)
2558 end as available_days
2559 from buffer_target_primary_availabilities_824879560
2560 group by
2561 staff_id,
2562 calendar_schedule_id,
2563 is_weekend
2564 order by null
2565 ) as t1
2566 left join (
2567 select
2568 staff_id,
2569 is_weekend,
2570 sum(coalesce(allocated, 0)) as estimated_vacation
2571 from annual_targets
2572 where client_id = 6
2573 and assignment_id = -1
2574 and assignment_type = 'Vacation'
2575 group by
2576 staff_id,
2577 is_weekend
2578 order by null
2579 ) as t2
2580 on t1.staff_id = t2.staff_id
2581 and t1.is_weekend = t2.is_weekend
2582 order by null
2583
2584 (157.8ms) update
2585 buffer_annual_point_targets_824879560 as apt
2586 inner join (
2587 select
2588 calendar_schedule_id,
2589 is_weekend,
2590 sum(available_days) as available_days_total
2591 from buffer_annual_point_targets_824879560
2592 group by
2593 calendar_schedule_id,
2594 is_weekend
2595 order by null
2596 ) as t1
2597 on apt.calendar_schedule_id = t1.calendar_schedule_id
2598 and apt.is_weekend = t1.is_weekend
2599 inner join (
2600 select
2601 ct.calendar_schedule_id,
2602 t1.is_weekend,
2603 sum(dp.point) * 52 as points_total
2604 from (
2605 select 0 as wday, 1 as day_of_week_mask, 1 as is_weekend
2606 union select 1, 2, 0
2607 union select 2, 4, 0
2608 union select 3, 8, 0
2609 union select 4, 16, 0
2610 union select 5, 32, 0
2611 union select 6, 64, 1
2612 ) as t1
2613 inner join buffer_target_call_types_824879560 as ct
2614 on (t1.day_of_week_mask & ct.days_of_week_mask) > 0
2615 inner join buffer_target_daily_points_824879560 as dp
2616 on ct.id = dp.call_type_id
2617 and t1.wday = dp.day
2618 group by
2619 ct.calendar_schedule_id,
2620 t1.is_weekend
2621 order by null
2622 ) as t2
2623 on apt.calendar_schedule_id = t2.calendar_schedule_id
2624 and apt.is_weekend = t2.is_weekend
2625 left join annual_target_points as apt_2
2626 on apt.staff_id = apt_2.staff_id
2627 and apt.calendar_schedule_id = apt_2.calendar_schedule_id
2628 and apt.is_weekend = apt_2.is_weekend
2629 set apt.points =
2630 case
2631 when (apt_2.id is not null) then apt_2.points
2632 when (t1.available_days_total > 0)
2633 then (t2.points_total * apt.available_days / t1.available_days_total)
2634 else 0.0
2635 end
2636
2637 (153.3ms) update
2638 buffer_annual_point_targets_824879560 as apt
2639 inner join target_autopopulate_timeframes as ts
2640 on apt.calendar_schedule_id = ts.calendar_schedule_id
2641 and ts.annual_target_view = 'fte'
2642 left join annual_target_points as apt_2
2643 on apt.staff_id = apt_2.staff_id
2644 and apt.calendar_schedule_id = apt_2.calendar_schedule_id
2645 and apt.is_weekend = apt_2.is_weekend
2646 set apt.points = 1.0
2647 where
2648 apt.points != 0
2649 and apt_2.id is null
2650
2651 (155.9ms) update
2652 buffer_annual_point_targets_824879560 as apt
2653 inner join (
2654 select
2655 calendar_schedule_id,
2656 is_weekend,
2657 sum(points) as points_total,
2658 sum(available_days) as available_days_total
2659 from buffer_annual_point_targets_824879560
2660 where points != 0
2661 group by
2662 calendar_schedule_id,
2663 is_weekend
2664 order by null
2665 ) as t1
2666 on apt.calendar_schedule_id = t1.calendar_schedule_id
2667 and apt.is_weekend = t1.is_weekend
2668 set apt.relative_capacity =
2669 case
2670 when (t1.points_total > 0 and t1.available_days_total > 0)
2671 then (apt.points / t1.points_total) / (apt.available_days / t1.available_days_total) * 100
2672 else 0
2673 end
2674
2675Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0205 - 625.8620000000001ms
2676 (154.7ms) truncate table buffer_target_dates_list_824879560
2677
2678 (161.3ms) insert into buffer_target_dates_list_824879560 (
2679 block_id,
2680 calendar_schedule_id,
2681 date,
2682 day_of_week_mask,
2683 is_weekend
2684 ,dp_day_primary ,dp_day_secondary /* 2nd pass */
2685 )
2686 select
2687 dl.block_id,
2688 dl.calendar_schedule_id,
2689 dl.date,
2690 (1 << (dayofweek(dl.date) - 1)) as day_of_week_mask,
2691 case
2692 when (dayofweek(dl.date) between 2 /* Monday */ and 6 /* Friday */) then 0
2693 else 1
2694 end as is_weekend
2695 /* 2nd pass */
2696 ,case
2697 when (hl.id is null) then (dayofweek(dl.date) - 1)
2698 when (dl.date = hl.observed_date) then 7
2699 else 8
2700 end as dp_day_primary
2701 ,(dayofweek(dl.date) - 1) as dp_day_secondary
2702
2703 from(
2704 select
2705 td.block_id,
2706 td.calendar_schedule_id,
2707 date_add(td.start_date, interval ns.item_number day) as date
2708 from
2709 buffer_target_dates as td
2710 inner join numeric_sequence as ns
2711 on ns.item_number <= datediff(td.end_date, td.start_date)
2712 where
2713 td.session_id = 824879560
2714 and td.build_point_targets = 1
2715 order by null
2716 ) as dl
2717 /* 2nd pass */
2718 left join (
2719 select
2720 hd.id,
2721 hd.observed_date,
2722 case
2723 when (hd.observed_date > hd.extended_date) then hd.extended_date
2724 else hd.observed_date
2725 end as date_from,
2726 case
2727 when (hd.observed_date < hd.extended_date) then hd.extended_date
2728 else hd.observed_date
2729 end as date_to
2730 from
2731 holidays as h
2732 inner join holiday_dates as hd
2733 on h.id = hd.holiday_id
2734 inner join (
2735 select
2736 year(min(start_date)) as year_from,
2737 year(max(end_date)) as year_to
2738 from buffer_target_dates
2739 where
2740 session_id = 824879560 /* session_id */
2741 and build_point_targets = 1
2742 order by null
2743 ) as y
2744 on hd.year between y.year_from and y.year_to
2745 where
2746 h.client_id = 6 /* client_id */
2747 and (
2748 h.observed = 1
2749 or h.extended = 1
2750 )
2751 order by null
2752 ) as hl
2753 on dl.date between hl.date_from and hl.date_to
2754
2755 order by null
2756
2757 (155.3ms) truncate table buffer_tmp_targets_availabilities_824879560
2758
2759 (172.8ms) insert into buffer_tmp_targets_availabilities_824879560 (
2760 block_id,
2761 calendar_schedule_id,
2762 date,
2763 day_of_week_mask,
2764 is_weekend,
2765 call_type_id,
2766 assignment_id,
2767 assignment_type,
2768 staff_id,
2769 included_in_targets
2770 )
2771 select
2772 dl.block_id,
2773 dl.calendar_schedule_id,
2774 dl.date,
2775 dl.day_of_week_mask,
2776 dl.is_weekend,
2777 pa.call_type_id,
2778 pa.assignment_id,
2779 pa.assignment_type,
2780 pa.staff_id,
2781 pa.included_in_targets
2782 from
2783 buffer_target_dates_list_824879560 as dl
2784 inner join buffer_target_primary_availabilities_824879560 as pa
2785 on dl.calendar_schedule_id = pa.calendar_schedule_id
2786 and dl.day_of_week_mask = pa.day_of_week_mask
2787 and dl.date between pa.st_begin_date and pa.st_end_date
2788 and dl.date between pa.lp_begin_date and pa.lp_end_date
2789 inner join staff_types as st
2790 on pa.staff_type_id = st.id
2791 and st.active = 1
2792 order by null
2793
2794 (154.9ms) truncate table buffer_tmp_targets_availabilities_exclusions_824879560
2795
2796 (160.8ms) insert into buffer_tmp_targets_availabilities_exclusions_824879560 (id)
2797 select ta.id
2798 from
2799 buffer_tmp_targets_availabilities_824879560 as ta
2800 inner join staff_rotations as sr use index (ix_staff_rotations_composite_1)
2801 on ta.staff_id = sr.staff_id
2802 and ta.date between sr.start_date and sr.end_date
2803 inner join rotations as r
2804 on sr.rotation_id = r.id
2805 and r.active = 1
2806 left join rotation_call_types as rct
2807 on sr.rotation_id = rct.rotation_id
2808 and ta.call_type_id = rct.call_type_id
2809 -- 2nd and 3rd passes
2810 and ta.day_of_week_mask & rct.days_of_week_mask > 0
2811
2812 left join daily_rotations as dr
2813 on ta.date = dr.schedule_on
2814 and ta.staff_id = dr.staff_id
2815 where
2816 rct.id is null
2817 and dr.id is null
2818 order by null
2819
2820 (174.0ms) insert into buffer_tmp_targets_availabilities_exclusions_824879560 (id)
2821 select ta.id
2822 from
2823 buffer_tmp_targets_availabilities_824879560 as ta
2824 inner join daily_rotations as dr
2825 on ta.date = dr.schedule_on
2826 and ta.staff_id = dr.staff_id
2827 inner join rotations as r
2828 on dr.rotation_id = r.id
2829 and r.active = 1
2830 left join rotation_call_types as rct
2831 on dr.rotation_id = rct.rotation_id
2832 and ta.call_type_id = rct.call_type_id
2833 -- 2nd and 3rd passes
2834 and ta.day_of_week_mask & rct.days_of_week_mask > 0
2835
2836 where rct.id is null
2837 order by null
2838
2839 (167.3ms) insert into buffer_tmp_targets_availabilities_exclusions_824879560 (id)
2840 select ta.id
2841 from
2842 buffer_tmp_targets_availabilities_824879560 as ta
2843 inner join target_autopopulate_timeframes as ts
2844 on ta.calendar_schedule_id = ts.calendar_schedule_id
2845 -- 2nd pass
2846 and ts.available_days_in_points = 1
2847
2848 inner join vacations as v
2849 on ta.date = v.schedule_on
2850 and ta.staff_id = v.staff_id
2851 and v.status = 3 /* status = fulfilled */
2852 order by null
2853
2854Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets03 - 1304.642ms
2855 (153.1ms) select distinct calendar_schedule_id
2856 from buffer_target_dates
2857 where
2858 session_id = 824879560
2859 and build_point_targets = 1
2860
2861 (155.0ms) truncate buffer_tmp_targets_scheduled_824879560
2862
2863 (155.3ms) insert into buffer_tmp_targets_scheduled_824879560 (
2864 block_id,
2865 calendar_schedule_id,
2866 staff_id,
2867 assignment_id,
2868 assignment_type,
2869 day_of_week_mask,
2870 is_weekend,
2871 scheduled,
2872 other_scheduled
2873 )
2874 select
2875 dl.block_id,
2876 dl.calendar_schedule_id,
2877 sc.staff_id,
2878 0 as assignment_id,
2879 '' as assignment_type,
2880 0 as day_of_week_mask,
2881 dl.is_weekend,
2882 sum(
2883 case
2884 when (dl.calendar_schedule_id = ct.calendar_schedule_id)
2885 then coalesce(dp.point, dp_2.point, 0.0)
2886 else 0.0
2887 end
2888 ) as _scheduled,
2889 sum(
2890 case
2891 when (dl.calendar_schedule_id != ct.calendar_schedule_id)
2892 then coalesce(dp.point, dp_2.point, 0.0)
2893 else 0.0
2894 end
2895 ) as _other_scheduled
2896 from
2897 buffer_target_dates_list_824879560 as dl
2898 inner join schedules as sc
2899 on dl.date = sc.schedule_on
2900 and sc.client_id = 6 /* client_id */
2901 inner join (
2902 select
2903 ct.id,
2904 ct.calendar_schedule_id,
2905 aa.id as assignment_annotation_id
2906 from
2907 call_types as ct
2908 inner join assignment_annotations as aa
2909 on ct.id = aa.assignmentable_id
2910 and aa.assignmentable_type = 'CallType'
2911 and aa.annotation_id = 0 /* annotation = "None" */
2912 and aa.applicable = 1
2913 inner join assignment_annotation_daily_points as dp
2914 on aa.id = dp.assignment_annotation_id
2915 and dp.point != 0
2916 where
2917 ct.client_id = 6 /* client_id */
2918 and ct.active = 1
2919 group by
2920 ct.id,
2921 ct.calendar_schedule_id,
2922 aa.id
2923 order by null
2924 ) as ct
2925 on sc.call_type_id = ct.id
2926 left join assignment_annotation_daily_points as dp
2927 on ct.assignment_annotation_id = dp.assignment_annotation_id
2928 and dl.dp_day_primary = dp.day
2929 left join assignment_annotation_daily_points as dp_2
2930 on ct.assignment_annotation_id = dp_2.assignment_annotation_id
2931 and dl.dp_day_secondary = dp_2.day
2932 inner join assign_staff_types as ast
2933 on sc.staff_id = ast.staff_id
2934 and dl.date between ast.begin_date and coalesce(ast.end_date, '9999-12-31')
2935 inner join staff_types as st
2936 on ast.staff_type_id = st.id
2937 and dl.calendar_schedule_id = st.point_hour_schedule_id
2938 group by
2939 dl.block_id,
2940 dl.calendar_schedule_id,
2941 sc.staff_id,
2942 dl.is_weekend
2943 having
2944 _scheduled != 0
2945 or _other_scheduled != 0
2946 order by null
2947
2948 (154.9ms) truncate table buffer_tmp_targets_staff_totals_824879560
2949
2950 (158.7ms) insert into buffer_tmp_targets_staff_totals_824879560 (
2951 block_id,
2952 calendar_schedule_id,
2953 staff_id,
2954 assignment_id,
2955 assignment_type,
2956 day_of_week_mask,
2957 is_weekend,
2958 relative_capacity,
2959 available_days,
2960 weighted_days,
2961 scheduled,
2962 other_scheduled
2963 )
2964 select
2965 t1.block_id,
2966 t1.calendar_schedule_id,
2967 t1.staff_id,
2968 0 as assignment_id,
2969 '' as assignment_type,
2970 0 as day_of_week_mask,
2971 t1.is_weekend,
2972 apt.relative_capacity,
2973 t1.available_days,
2974 (t1.available_days * apt.relative_capacity / 100) as weighted_days,
2975 coalesce(sch_t._scheduled, 0.0) as scheduled,
2976 coalesce(sch_t._other_scheduled, 0.0) as other_scheduled
2977 from (
2978 select
2979 ta.block_id,
2980 ta.calendar_schedule_id,
2981 ta.staff_id,
2982 ta.date,
2983 ta.is_weekend,
2984 count(distinct ta.date) as available_days
2985 from
2986 buffer_tmp_targets_availabilities_824879560 as ta
2987 left join buffer_tmp_targets_availabilities_exclusions_824879560 as tae
2988 on ta.id = tae.id
2989 where tae.id is null
2990 group by
2991 ta.block_id,
2992 ta.calendar_schedule_id,
2993 ta.staff_id,
2994 ta.is_weekend
2995 order by null
2996 ) as t1
2997 inner join buffer_annual_point_targets_824879560 as apt
2998 on t1.staff_id = apt.staff_id
2999 and t1.calendar_schedule_id = apt.calendar_schedule_id
3000 and t1.is_weekend = apt.is_weekend
3001 inner join (
3002 select
3003 block_id,
3004 calendar_schedule_id,
3005 case
3006 when (day_of_week_mask & 62 > 0) then 0
3007 else 1
3008 end as _is_weekend,
3009 count(date) as available_days
3010 from buffer_target_dates_list_824879560
3011 group by
3012 block_id,
3013 calendar_schedule_id,
3014 _is_weekend
3015 order by null
3016 ) as dlt
3017 on t1.block_id = dlt.block_id
3018 and t1.calendar_schedule_id = dlt.calendar_schedule_id
3019 and t1.is_weekend = dlt._is_weekend
3020 left join (
3021 select
3022 block_id,
3023 calendar_schedule_id,
3024 staff_id,
3025 is_weekend,
3026 sum(scheduled) as _scheduled,
3027 sum(other_scheduled) as _other_scheduled
3028 from buffer_tmp_targets_scheduled_824879560
3029 group by
3030 block_id,
3031 calendar_schedule_id,
3032 staff_id,
3033 is_weekend
3034 order by null
3035 ) as sch_t
3036 on t1.block_id = sch_t.block_id
3037 and t1.calendar_schedule_id = sch_t.calendar_schedule_id
3038 and t1.staff_id = sch_t.staff_id
3039 and t1.is_weekend = sch_t.is_weekend
3040 order by null
3041
3042 (154.8ms) truncate table buffer_tmp_targets_client_totals_824879560
3043
3044 (160.5ms) insert into buffer_tmp_targets_client_totals_824879560 (
3045 block_id,
3046 calendar_schedule_id,
3047 assignment_id,
3048 assignment_type,
3049 day_of_week_mask,
3050 is_weekend,
3051 targets_total,
3052 weighted_days_total
3053 )
3054 select
3055 st.block_id,
3056 st.calendar_schedule_id,
3057 0 as assignment_id,
3058 '' as assignment_type,
3059 0 as day_of_week_mask,
3060 st.is_weekend,
3061 cp.points_total as targets_total,
3062 sum(st.weighted_days) as weighted_days_total
3063 from
3064 buffer_tmp_targets_staff_totals_824879560 as st
3065 inner join (
3066 select
3067 dl.block_id,
3068 dl.calendar_schedule_id,
3069 dl.is_weekend,
3070 sum(coalesce(dp.point, dp_2.point, 0.0)) as points_total
3071 from
3072 buffer_target_dates_list_824879560 as dl
3073 inner join buffer_target_call_types_824879560 as ct
3074 on dl.calendar_schedule_id = ct.calendar_schedule_id
3075 and (dl.day_of_week_mask & ct.points_days_of_week_mask) > 0
3076 inner join target_autopopulate_timeframes as ts
3077 on dl.calendar_schedule_id = ts.calendar_schedule_id
3078 left join autopopulate_exclusions as ae
3079 on dl.date = ae.schedule_on
3080 and ct.id = ae.call_type_id
3081 left join buffer_target_daily_points_824879560 as dp
3082 on ct.id = dp.call_type_id
3083 and dl.dp_day_primary = dp.day
3084 left join buffer_target_daily_points_824879560 as dp_2
3085 on ct.id = dp_2.call_type_id
3086 and dl.dp_day_secondary = dp_2.day
3087 where
3088 ts.remove_slots_from_denominator_targets = 0
3089 or ae.id is null
3090 group by
3091 dl.block_id,
3092 dl.calendar_schedule_id,
3093 dl.is_weekend
3094 order by null
3095 ) as cp
3096 on st.block_id = cp.block_id
3097 and st.calendar_schedule_id = cp.calendar_schedule_id
3098 and st.is_weekend = cp.is_weekend
3099 group by
3100 st.block_id,
3101 st.calendar_schedule_id,
3102 st.is_weekend,
3103 cp.points_total
3104 order by null
3105
3106 (156.0ms) insert into buffer_point_targets_824879560 (
3107 block_id,
3108 calendar_schedule_id,
3109 staff_id,
3110 is_weekend,
3111 raw_target,
3112 target,
3113 initial_target,
3114 scheduled,
3115 other_scheduled,
3116 available_days
3117 )
3118 select
3119 st.block_id,
3120 st.calendar_schedule_id,
3121 st.staff_id,
3122 st.is_weekend,
3123 case
3124 when (ct.weighted_days_total > 0)
3125 then (ct.targets_total * st.weighted_days / ct.weighted_days_total)
3126 else 0
3127 end as raw_target,
3128 case
3129 when (ct.weighted_days_total > 0)
3130 then (ct.targets_total * st.weighted_days / ct.weighted_days_total)
3131 else 0
3132 end as target,
3133 case
3134 when (ct.weighted_days_total > 0)
3135 then (ct.targets_total * st.weighted_days / ct.weighted_days_total)
3136 else 0
3137 end as initial_target,
3138 st.scheduled,
3139 st.other_scheduled,
3140 st.available_days
3141 from
3142 buffer_tmp_targets_staff_totals_824879560 as st
3143 inner join buffer_tmp_targets_client_totals_824879560 as ct
3144 on st.block_id = ct.block_id
3145 and st.calendar_schedule_id = ct.calendar_schedule_id
3146 and st.is_weekend = ct.is_weekend
3147 order by null
3148
3149 (154.2ms) update
3150 buffer_point_targets_824879560 as pt
3151 inner join (
3152 select
3153 block_id,
3154 calendar_schedule_id,
3155 is_weekend,
3156 sum(initial_target) as targets_total,
3157 sum(other_scheduled) as other_scheduled_total
3158 from buffer_point_targets_824879560
3159 group by
3160 block_id,
3161 calendar_schedule_id,
3162 is_weekend
3163 order by null
3164 ) as t1
3165 on pt.block_id = t1.block_id
3166 and pt.calendar_schedule_id = t1.calendar_schedule_id
3167 and pt.is_weekend = t1.is_weekend
3168 left join adjusted_target_points as apt
3169 on pt.block_id = apt.block_id
3170 and pt.calendar_schedule_id = apt.calendar_schedule_id
3171 and pt.staff_id = apt.staff_id
3172 and pt.is_weekend = apt.is_weekend
3173 set
3174 pt.target =
3175 case
3176 when (apt.id is not null) then apt.target
3177 when (t1.targets_total > 0)
3178 then ((t1.targets_total + t1.other_scheduled_total) * pt.initial_target / t1.targets_total - pt.other_scheduled)
3179 else 0.0
3180 end,
3181 pt.raw_target =
3182 case
3183 when (t1.targets_total > 0)
3184 then ((t1.targets_total + t1.other_scheduled_total) * pt.initial_target / t1.targets_total - pt.other_scheduled)
3185 else 0.0
3186 end
3187
3188 (153.0ms) insert into buffer_point_targets_824879560 (
3189 block_id,
3190 calendar_schedule_id,
3191 staff_id,
3192 is_weekend,
3193 raw_target,
3194 target,
3195 initial_target,
3196 scheduled,
3197 other_scheduled,
3198 available_days
3199 )
3200 select
3201 sch_t.block_id,
3202 sch_t.calendar_schedule_id,
3203 sch_t.staff_id,
3204 sch_t.is_weekend,
3205 0.0 as raw_target,
3206 0.0 as target,
3207 0.0 as initial_target,
3208 sum(sch_t.scheduled) as scheduled,
3209 sum(sch_t.other_scheduled) as other_scheduled,
3210 0 as available_days
3211 from
3212 buffer_tmp_targets_scheduled_824879560 as sch_t
3213 left join buffer_point_targets_824879560 as pt
3214 on sch_t.block_id = pt.block_id
3215 and sch_t.calendar_schedule_id = pt.calendar_schedule_id
3216 and sch_t.staff_id = pt.staff_id
3217 and sch_t.is_weekend = pt.is_weekend
3218 where
3219 sch_t.scheduled != 0
3220 and pt.id is null
3221 group by
3222 sch_t.block_id,
3223 sch_t.calendar_schedule_id,
3224 sch_t.staff_id,
3225 sch_t.is_weekend
3226 order by null
3227
3228Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0401 - 1559.8890000000001ms
3229 (177.7ms) select distinct calendar_schedule_id
3230 from buffer_target_dates
3231 where
3232 session_id = 824879560
3233 and build_hour_targets = 1
3234
3235 (154.9ms) truncate table buffer_target_call_types_824879560
3236
3237 (156.8ms) insert into buffer_target_call_types_824879560 (
3238 id,
3239 target_group_id,
3240 assignment_id,
3241 assignment_type,
3242 calendar_schedule_id,
3243 days_of_week_mask,
3244 hours,
3245 points_days_of_week_mask,
3246 included_in_targets,
3247 all_staff_types,
3248 location_id
3249 )
3250 select
3251 id,
3252 0 as target_group_id,
3253 id as assignment_id,
3254 'CallType' as assignment_type,
3255 calendar_schedule_id,
3256 days_of_week_mask,
3257 coalesce(
3258 timestampdiff(
3259 minute,
3260 concat('1900-01-01 ', maketime(start_time_hour, start_time_minute, 0)),
3261 concat(
3262 '1900-01-0',
3263 case
3264 when ((
3265 start_time_hour | start_time_minute | end_time_hour | end_time_minute > 0
3266 )
3267 and (
3268 timediff(
3269 maketime(end_time_hour, end_time_minute, 0),
3270 maketime(start_time_hour, start_time_minute, 0)
3271 ) <= 0
3272 )
3273 ) then '2'
3274 else '1'
3275 end,
3276 ' ',
3277 maketime(end_time_hour, end_time_minute, 0)
3278 )
3279 ) / 60,
3280 0.0
3281 ) as _hours,
3282 null as points_days_of_week_mask,
3283 included_in_targets,
3284 all_staff_types,
3285 location_id
3286 from call_types
3287 where
3288 calendar_schedule_id in (6)
3289 and active = 1
3290 and days_of_week_mask > 0
3291 having _hours != 0
3292 order by null
3293
3294Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets02Hours - 490.833ms
3295 (152.6ms) select id from buffer_target_call_types_824879560 limit 1
3296 (155.0ms) truncate table buffer_location_privileges_824879560
3297
3298 (157.2ms) insert into buffer_location_privileges_824879560 (
3299 staff_id,
3300 location_id,
3301 begin_date,
3302 end_date
3303 )
3304 select
3305 s.id as staff_id,
3306 l.location_id,
3307 '0000-00-00' as begin_date,
3308 '9999-12-31' as end_date
3309 from (
3310 select
3311 l.id as location_id
3312 from
3313 buffer_target_call_types_824879560 as ct
3314 inner join locations as l
3315 on ct.location_id = l.id
3316 and l.active = 1
3317 group by
3318 l.id
3319 order by null
3320 ) as l
3321 inner join staffs as s
3322 on s.client_id = 6
3323 and s.active = 1
3324 and s.take_call = 1
3325 left join location_privileges as lp
3326 on s.id = lp.staff_id
3327 where
3328 lp.id is null
3329 union
3330 select
3331 lp.staff_id,
3332 lp.location_id,
3333 lp.begin_date,
3334 coalesce(lp.end_date, '9999-12-31') as end_date
3335 from (
3336 select
3337 l.id as location_id
3338 from
3339 buffer_target_call_types_824879560 as ct
3340 inner join locations as l
3341 on ct.location_id = l.id
3342 and l.active = 1
3343 group by
3344 l.id
3345 order by null
3346 ) as l
3347 inner join location_privileges as lp
3348 on l.location_id = lp.location_id
3349 order by null
3350
3351 (155.2ms) truncate table buffer_target_primary_availabilities_824879560
3352
3353 (156.7ms) insert into buffer_target_primary_availabilities_824879560 (
3354 staff_id,
3355 call_type_id,
3356 target_group_id,
3357 assignment_id,
3358 assignment_type,
3359 calendar_schedule_id,
3360 day_of_week_mask,
3361 is_weekend,
3362 staff_type_id,
3363 st_begin_date,
3364 st_end_date,
3365 location_id,
3366 lp_begin_date,
3367 lp_end_date,
3368 included_in_targets
3369 )
3370 select distinct straight_join
3371 s.id as staff_id,
3372 ct.id as call_type_id,
3373 ct.target_group_id,
3374 ct.assignment_id,
3375 ct.assignment_type,
3376 ct.calendar_schedule_id,
3377 t1.day_of_week_mask,
3378 t1.is_weekend,
3379 ast.staff_type_id,
3380 ast.begin_date as st_begin_date,
3381 coalesce(ast.end_date, '9999-12-31') as st_end_date,
3382 lp.location_id,
3383 lp.begin_date as lp_begin_date,
3384 lp.end_date as lp_end_date,
3385 ct.included_in_targets
3386 from (
3387 select 1 as day_of_week_mask, 1 as is_weekend
3388 union select 2, 0
3389 union select 4, 0
3390 union select 8, 0
3391 union select 16, 0
3392 union select 32, 0
3393 union select 64, 1
3394 ) as t1
3395 inner join buffer_target_call_types_824879560 as ct
3396 on (t1.day_of_week_mask & ct.days_of_week_mask) > 0
3397 and ct.all_staff_types = 1
3398 inner join staff_call_types as sct
3399 on ct.id = sct.call_type_id
3400 -- 2nd and 3rd passes (points & hours)
3401 and t1.day_of_week_mask & sct.days_of_week_mask > 0
3402
3403 inner join staffs as s
3404 on sct.staff_id = s.id
3405 and s.active = 1
3406 and s.take_call = 1
3407 inner join buffer_location_privileges_824879560 as lp
3408 on s.id = lp.staff_id
3409 and ct.location_id = lp.location_id
3410 and coalesce(lp.end_date, '9999-12-31') >= '2017-10-01' /* current targets begin date */
3411 inner join assign_staff_types as ast
3412 on s.id = ast.staff_id
3413 and coalesce(ast.end_date, '9999-12-31') >= '2017-10-01' /* current targets begin date */
3414 -- 2nd and 3rd passes (points & hours)
3415 inner join staff_types as st
3416 on ast.staff_type_id = st.id
3417
3418 where
3419 ast.begin_date <= coalesce(lp.end_date, '9999-12-31')
3420 and lp.begin_date <= coalesce(ast.end_date, '9999-12-31')
3421 -- 2nd and 3rd passes (points & hours)
3422 and ct.calendar_schedule_id = st.point_hour_schedule_id
3423
3424 order by null
3425
3426 (167.3ms) insert into buffer_target_primary_availabilities_824879560 (
3427 staff_id,
3428 call_type_id,
3429 target_group_id,
3430 assignment_id,
3431 assignment_type,
3432 calendar_schedule_id,
3433 day_of_week_mask,
3434 is_weekend,
3435 staff_type_id,
3436 st_begin_date,
3437 st_end_date,
3438 location_id,
3439 lp_begin_date,
3440 lp_end_date,
3441 included_in_targets
3442 )
3443 select distinct straight_join
3444 s.id as staff_id,
3445 ct.id as call_type_id,
3446 ct.target_group_id,
3447 ct.assignment_id,
3448 ct.assignment_type,
3449 ct.calendar_schedule_id,
3450 t1.day_of_week_mask,
3451 t1.is_weekend,
3452 ast.staff_type_id,
3453 ast.begin_date as st_begin_date,
3454 coalesce(ast.end_date, '9999-12-31') as st_end_date,
3455 lp.location_id,
3456 lp.begin_date as lp_begin_date,
3457 lp.end_date as lp_end_date,
3458 ct.included_in_targets
3459 from (
3460 select 1 as day_of_week_mask, 1 as is_weekend
3461 union select 2, 0
3462 union select 4, 0
3463 union select 8, 0
3464 union select 16, 0
3465 union select 32, 0
3466 union select 64, 1
3467 ) as t1
3468 inner join buffer_target_call_types_824879560 as ct
3469 on (t1.day_of_week_mask & ct.days_of_week_mask) > 0
3470 and ct.all_staff_types = 0
3471 inner join staff_call_types as sct
3472 on ct.id = sct.call_type_id
3473 -- 2nd and 3rd passes (points & hours)
3474 and t1.day_of_week_mask & sct.days_of_week_mask > 0
3475
3476 inner join staffs as s
3477 on sct.staff_id = s.id
3478 and s.active = 1
3479 and s.take_call = 1
3480 inner join buffer_location_privileges_824879560 as lp
3481 on s.id = lp.staff_id
3482 and ct.location_id = lp.location_id
3483 and coalesce(lp.end_date, '9999-12-31') >= '2017-10-01' /* current targets begin date */
3484 inner join assign_staff_types as ast
3485 on s.id = ast.staff_id
3486 and coalesce(ast.end_date, '9999-12-31') >= '2017-10-01' /* current targets begin date */
3487 inner join eligible_staff_types as est
3488 on ct.id = est.call_type_id
3489 and ast.staff_type_id = est.staff_type_id
3490 -- 2nd and 3rd passes (points & hours)
3491 inner join staff_types as st
3492 on ast.staff_type_id = st.id
3493
3494 where
3495 ast.begin_date <= coalesce(lp.end_date, '9999-12-31')
3496 and lp.begin_date <= coalesce(ast.end_date, '9999-12-31')
3497 -- 2nd and 3rd passes (points & hours)
3498 and ct.calendar_schedule_id = st.point_hour_schedule_id
3499
3500 order by null
3501
3502Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0201 - 794.736ms
3503 (152.9ms) select id from buffer_target_primary_availabilities_824879560 limit 1
3504 (157.6ms) insert into buffer_annual_hour_targets_824879560 (
3505 staff_id,
3506 calendar_schedule_id,
3507 is_weekend,
3508 hours,
3509 estimated_vacation,
3510 available_days,
3511 relative_capacity
3512 )
3513 select
3514 t1.staff_id,
3515 t1.calendar_schedule_id,
3516 t1.is_weekend,
3517 0 as hours, /* will be calculated on the next step */
3518 coalesce(t2.estimated_vacation, 0) as estimated_vacation,
3519 (t1.available_days - coalesce(t2.estimated_vacation, 0)) as available_days,
3520 0 as relative_capacity /* will be calculated on the next step */
3521 from (
3522 select
3523 staff_id,
3524 calendar_schedule_id,
3525 is_weekend,
3526 case
3527 when (is_weekend = 0) then (5 * 52)
3528 else (2 * 52)
3529 end as available_days
3530 from buffer_target_primary_availabilities_824879560
3531 group by
3532 staff_id,
3533 calendar_schedule_id,
3534 is_weekend
3535 order by null
3536 ) as t1
3537 left join (
3538 select
3539 staff_id,
3540 is_weekend,
3541 sum(coalesce(allocated, 0)) as estimated_vacation
3542 from annual_targets
3543 where client_id = 6
3544 and assignment_id = -1
3545 and assignment_type = 'Vacation'
3546 group by
3547 staff_id,
3548 is_weekend
3549 order by null
3550 ) as t2
3551 on t1.staff_id = t2.staff_id
3552 and t1.is_weekend = t2.is_weekend
3553 order by null
3554
3555 (164.1ms) update
3556 buffer_annual_hour_targets_824879560 as aht
3557 inner join (
3558 select
3559 calendar_schedule_id,
3560 is_weekend,
3561 sum(available_days) as available_days_total
3562 from buffer_annual_hour_targets_824879560
3563 group by
3564 calendar_schedule_id,
3565 is_weekend
3566 order by null
3567 ) as t1
3568 on aht.calendar_schedule_id = t1.calendar_schedule_id
3569 and aht.is_weekend = t1.is_weekend
3570 inner join (
3571 select
3572 ct.calendar_schedule_id,
3573 t1.is_weekend,
3574 sum(ct.hours) * 52 as hours_total
3575 from (
3576 select 1 as day_of_week_mask, 1 as is_weekend
3577 union select 2, 0
3578 union select 4, 0
3579 union select 8, 0
3580 union select 16, 0
3581 union select 32, 0
3582 union select 64, 1
3583 ) as t1
3584 inner join buffer_target_call_types_824879560 as ct
3585 on (t1.day_of_week_mask & ct.days_of_week_mask) > 0
3586 group by
3587 ct.calendar_schedule_id,
3588 t1.is_weekend
3589 order by null
3590 ) as t2
3591 on aht.calendar_schedule_id = t2.calendar_schedule_id
3592 and aht.is_weekend = t2.is_weekend
3593 left join annual_target_hours as aht_2
3594 on aht.staff_id = aht_2.staff_id
3595 and aht.calendar_schedule_id = aht_2.calendar_schedule_id
3596 and aht.is_weekend = aht_2.is_weekend
3597 set aht.hours =
3598 case
3599 when (aht_2.id is not null) then aht_2.hours
3600 when (t1.available_days_total > 0)
3601 then (t2.hours_total * aht.available_days / t1.available_days_total)
3602 else 0.0
3603 end
3604
3605 (153.0ms) update
3606 buffer_annual_hour_targets_824879560 as aht
3607 inner join target_autopopulate_timeframes as ts
3608 on aht.calendar_schedule_id = ts.calendar_schedule_id
3609 and ts.annual_target_view = 'fte'
3610 left join annual_target_hours as aht_2
3611 on aht.staff_id = aht_2.staff_id
3612 and aht.calendar_schedule_id = aht_2.calendar_schedule_id
3613 and aht.is_weekend = aht_2.is_weekend
3614 set aht.hours = 1.0
3615 where
3616 aht.hours != 0
3617 and aht_2.id is null
3618
3619 (157.5ms) update
3620 buffer_annual_hour_targets_824879560 as aht
3621 inner join (
3622 select
3623 calendar_schedule_id,
3624 is_weekend,
3625 sum(hours) as hours_total,
3626 sum(available_days) as available_days_total
3627 from buffer_annual_hour_targets_824879560
3628 where hours != 0
3629 group by
3630 calendar_schedule_id,
3631 is_weekend
3632 order by null
3633 ) as t1
3634 on aht.calendar_schedule_id = t1.calendar_schedule_id
3635 and aht.is_weekend = t1.is_weekend
3636 set aht.relative_capacity =
3637 case
3638 when (t1.hours_total > 0 and t1.available_days_total > 0)
3639 then (aht.hours / t1.hours_total) / (aht.available_days / t1.available_days_total) * 100
3640 else 0
3641 end
3642
3643Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0206 - 633.992ms
3644 (155.3ms) truncate table buffer_target_dates_list_824879560
3645
3646 (155.9ms) insert into buffer_target_dates_list_824879560 (
3647 block_id,
3648 calendar_schedule_id,
3649 date,
3650 day_of_week_mask,
3651 is_weekend
3652
3653 )
3654 select
3655 dl.block_id,
3656 dl.calendar_schedule_id,
3657 dl.date,
3658 (1 << (dayofweek(dl.date) - 1)) as day_of_week_mask,
3659 case
3660 when (dayofweek(dl.date) between 2 /* Monday */ and 6 /* Friday */) then 0
3661 else 1
3662 end as is_weekend
3663
3664 from(
3665 select
3666 td.block_id,
3667 td.calendar_schedule_id,
3668 date_add(td.start_date, interval ns.item_number day) as date
3669 from
3670 buffer_target_dates as td
3671 inner join numeric_sequence as ns
3672 on ns.item_number <= datediff(td.end_date, td.start_date)
3673 where
3674 td.session_id = 824879560
3675 and td.build_hour_targets = 1
3676 order by null
3677 ) as dl
3678
3679 order by null
3680
3681 (154.9ms) truncate table buffer_tmp_targets_availabilities_824879560
3682
3683 (165.1ms) insert into buffer_tmp_targets_availabilities_824879560 (
3684 block_id,
3685 calendar_schedule_id,
3686 date,
3687 day_of_week_mask,
3688 is_weekend,
3689 call_type_id,
3690 assignment_id,
3691 assignment_type,
3692 staff_id,
3693 included_in_targets
3694 )
3695 select
3696 dl.block_id,
3697 dl.calendar_schedule_id,
3698 dl.date,
3699 dl.day_of_week_mask,
3700 dl.is_weekend,
3701 pa.call_type_id,
3702 pa.assignment_id,
3703 pa.assignment_type,
3704 pa.staff_id,
3705 pa.included_in_targets
3706 from
3707 buffer_target_dates_list_824879560 as dl
3708 inner join buffer_target_primary_availabilities_824879560 as pa
3709 on dl.calendar_schedule_id = pa.calendar_schedule_id
3710 and dl.day_of_week_mask = pa.day_of_week_mask
3711 and dl.date between pa.st_begin_date and pa.st_end_date
3712 and dl.date between pa.lp_begin_date and pa.lp_end_date
3713 inner join staff_types as st
3714 on pa.staff_type_id = st.id
3715 and st.active = 1
3716 order by null
3717
3718 (154.6ms) truncate table buffer_tmp_targets_availabilities_exclusions_824879560
3719
3720 (156.0ms) insert into buffer_tmp_targets_availabilities_exclusions_824879560 (id)
3721 select ta.id
3722 from
3723 buffer_tmp_targets_availabilities_824879560 as ta
3724 inner join staff_rotations as sr use index (ix_staff_rotations_composite_1)
3725 on ta.staff_id = sr.staff_id
3726 and ta.date between sr.start_date and sr.end_date
3727 inner join rotations as r
3728 on sr.rotation_id = r.id
3729 and r.active = 1
3730 left join rotation_call_types as rct
3731 on sr.rotation_id = rct.rotation_id
3732 and ta.call_type_id = rct.call_type_id
3733 -- 2nd and 3rd passes
3734 and ta.day_of_week_mask & rct.days_of_week_mask > 0
3735
3736 left join daily_rotations as dr
3737 on ta.date = dr.schedule_on
3738 and ta.staff_id = dr.staff_id
3739 where
3740 rct.id is null
3741 and dr.id is null
3742 order by null
3743
3744 (160.3ms) insert into buffer_tmp_targets_availabilities_exclusions_824879560 (id)
3745 select ta.id
3746 from
3747 buffer_tmp_targets_availabilities_824879560 as ta
3748 inner join daily_rotations as dr
3749 on ta.date = dr.schedule_on
3750 and ta.staff_id = dr.staff_id
3751 inner join rotations as r
3752 on dr.rotation_id = r.id
3753 and r.active = 1
3754 left join rotation_call_types as rct
3755 on dr.rotation_id = rct.rotation_id
3756 and ta.call_type_id = rct.call_type_id
3757 -- 2nd and 3rd passes
3758 and ta.day_of_week_mask & rct.days_of_week_mask > 0
3759
3760 where rct.id is null
3761 order by null
3762
3763 (159.0ms) insert into buffer_tmp_targets_availabilities_exclusions_824879560 (id)
3764 select ta.id
3765 from
3766 buffer_tmp_targets_availabilities_824879560 as ta
3767 inner join target_autopopulate_timeframes as ts
3768 on ta.calendar_schedule_id = ts.calendar_schedule_id
3769 -- 3rd pass
3770 and ts.available_days_in_hours = 1
3771
3772 inner join vacations as v
3773 on ta.date = v.schedule_on
3774 and ta.staff_id = v.staff_id
3775 and v.status = 3 /* status = fulfilled */
3776 order by null
3777
3778Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets03 - 1264.6580000000001ms
3779 (154.6ms) truncate table buffer_tmp_targets_scheduled_824879560
3780
3781 (167.8ms) insert into buffer_tmp_targets_scheduled_824879560 (
3782 block_id,
3783 calendar_schedule_id,
3784 staff_id,
3785 assignment_id,
3786 assignment_type,
3787 day_of_week_mask,
3788 is_weekend,
3789 scheduled,
3790 other_scheduled
3791 )
3792 select
3793 dl.block_id,
3794 dl.calendar_schedule_id,
3795 sc.staff_id,
3796 0 as assignment_id,
3797 '' as assignment_type,
3798 0 as day_of_week_mask,
3799 dl.is_weekend,
3800 sum(
3801 case
3802 when (dl.calendar_schedule_id = ct.calendar_schedule_id) then ct.hours
3803 else 0.0
3804 end
3805 ) as _scheduled,
3806 sum(
3807 case
3808 when (dl.calendar_schedule_id != ct.calendar_schedule_id) then ct.hours
3809 else 0.0
3810 end
3811 ) as _other_scheduled
3812 from
3813 buffer_target_dates_list_824879560 as dl
3814 inner join schedules as sc
3815 on dl.date = sc.schedule_on
3816 and sc.client_id = 6 /* client_id */
3817 inner join (
3818 select
3819 id,
3820 calendar_schedule_id,
3821 coalesce(
3822 timestampdiff(
3823 minute,
3824 concat('1900-01-01 ', maketime(start_time_hour, start_time_minute, 0)),
3825 concat(
3826 '1900-01-0',
3827 case
3828 when ((
3829 start_time_hour | start_time_minute | end_time_hour | end_time_minute > 0
3830 )
3831 and (
3832 timediff(
3833 maketime(end_time_hour, end_time_minute, 0),
3834 maketime(start_time_hour, start_time_minute, 0)
3835 ) <= 0
3836 )
3837 ) then '2'
3838 else '1'
3839 end,
3840 ' ',
3841 maketime(end_time_hour, end_time_minute, 0)
3842 )
3843 ) / 60,
3844 0.0
3845 ) as hours
3846 from call_types
3847 where
3848 client_id = 6 /* client_id */
3849 and active = 1
3850 having hours != 0
3851 order by null
3852 ) as ct
3853 on sc.call_type_id = ct.id
3854 inner join assign_staff_types as ast
3855 on sc.staff_id = ast.staff_id
3856 and dl.date between ast.begin_date and coalesce(ast.end_date, '9999-12-31')
3857 inner join staff_types as st
3858 on ast.staff_type_id = st.id
3859 and dl.calendar_schedule_id = st.point_hour_schedule_id
3860 group by
3861 dl.block_id,
3862 dl.calendar_schedule_id,
3863 sc.staff_id,
3864 dl.is_weekend
3865 having
3866 _scheduled != 0
3867 or _other_scheduled != 0
3868 order by null
3869
3870 (155.9ms) truncate table buffer_tmp_targets_staff_totals_824879560
3871
3872 (157.1ms) insert into buffer_tmp_targets_staff_totals_824879560 (
3873 block_id,
3874 calendar_schedule_id,
3875 staff_id,
3876 assignment_id,
3877 assignment_type,
3878 day_of_week_mask,
3879 is_weekend,
3880 relative_capacity,
3881 available_days,
3882 weighted_days,
3883 scheduled,
3884 other_scheduled
3885 )
3886 select
3887 t1.block_id,
3888 t1.calendar_schedule_id,
3889 t1.staff_id,
3890 0 as assignment_id,
3891 '' as assignment_type,
3892 0 as day_of_week_mask,
3893 t1.is_weekend,
3894 aht.relative_capacity,
3895 t1.available_days,
3896 (t1.available_days * aht.relative_capacity / 100) as weighted_days,
3897 coalesce(sch_t._scheduled, 0.0) as scheduled,
3898 coalesce(sch_t._other_scheduled, 0.0) as other_scheduled
3899 from (
3900 select
3901 ta.block_id,
3902 ta.calendar_schedule_id,
3903 ta.staff_id,
3904 ta.is_weekend,
3905 count(distinct ta.date) as available_days
3906 from
3907 buffer_tmp_targets_availabilities_824879560 as ta
3908 left join buffer_tmp_targets_availabilities_exclusions_824879560 as tae
3909 on ta.id = tae.id
3910 where tae.id is null
3911 group by
3912 ta.block_id,
3913 ta.calendar_schedule_id,
3914 ta.staff_id,
3915 ta.is_weekend
3916 order by null
3917 ) as t1
3918 inner join buffer_annual_hour_targets_824879560 as aht
3919 on t1.staff_id = aht.staff_id
3920 and t1.calendar_schedule_id = aht.calendar_schedule_id
3921 and t1.is_weekend = aht.is_weekend
3922 inner join (
3923 select
3924 block_id,
3925 calendar_schedule_id,
3926 case
3927 when (day_of_week_mask & 62 > 0) then 0
3928 else 1
3929 end as _is_weekend,
3930 count(date) as available_days
3931 from buffer_target_dates_list_824879560
3932 group by
3933 block_id,
3934 calendar_schedule_id,
3935 _is_weekend
3936 order by null
3937 ) as dlt
3938 on t1.block_id = dlt.block_id
3939 and t1.calendar_schedule_id = dlt.calendar_schedule_id
3940 and t1.is_weekend = dlt._is_weekend
3941 left join (
3942 select
3943 block_id,
3944 calendar_schedule_id,
3945 staff_id,
3946 is_weekend,
3947 sum(scheduled) as _scheduled,
3948 sum(other_scheduled) as _other_scheduled
3949 from buffer_tmp_targets_scheduled_824879560
3950 group by
3951 block_id,
3952 calendar_schedule_id,
3953 staff_id,
3954 is_weekend
3955 order by null
3956 ) as sch_t
3957 on t1.block_id = sch_t.block_id
3958 and t1.calendar_schedule_id = sch_t.calendar_schedule_id
3959 and t1.staff_id = sch_t.staff_id
3960 and t1.is_weekend = sch_t.is_weekend
3961 order by null
3962
3963 (154.7ms) truncate table buffer_tmp_targets_client_totals_824879560
3964
3965 (156.6ms) insert into buffer_tmp_targets_client_totals_824879560 (
3966 block_id,
3967 calendar_schedule_id,
3968 assignment_id,
3969 assignment_type,
3970 day_of_week_mask,
3971 is_weekend,
3972 targets_total,
3973 weighted_days_total
3974 )
3975 select
3976 st.block_id,
3977 st.calendar_schedule_id,
3978 0 as assignment_id,
3979 '' as assignment_type,
3980 0 as day_of_week_mask,
3981 st.is_weekend,
3982 ch.hours_total as targets_total,
3983 sum(st.weighted_days) as weighted_days_total
3984 from
3985 buffer_tmp_targets_staff_totals_824879560 as st
3986 inner join (
3987 select
3988 dl.block_id,
3989 dl.calendar_schedule_id,
3990 dl.is_weekend,
3991 sum(ct.hours) as hours_total
3992 from
3993 buffer_target_dates_list_824879560 as dl
3994 inner join buffer_target_call_types_824879560 as ct
3995 on dl.calendar_schedule_id = ct.calendar_schedule_id
3996 and (dl.day_of_week_mask & ct.days_of_week_mask) > 0
3997 inner join target_autopopulate_timeframes as ts
3998 on dl.calendar_schedule_id = ts.calendar_schedule_id
3999 left join autopopulate_exclusions as ae
4000 on dl.date = ae.schedule_on
4001 and ct.id = ae.call_type_id
4002 where
4003 ts.remove_slots_from_denominator_targets = 0
4004 or ae.id is null
4005 group by
4006 dl.block_id,
4007 dl.calendar_schedule_id,
4008 dl.is_weekend
4009 order by null
4010 ) as ch
4011 on st.block_id = ch.block_id
4012 and st.calendar_schedule_id = ch.calendar_schedule_id
4013 and st.is_weekend = ch.is_weekend
4014 group by
4015 st.block_id,
4016 st.calendar_schedule_id,
4017 st.is_weekend,
4018 ch.hours_total
4019 order by null
4020
4021 (156.3ms) insert into buffer_hour_targets_824879560 (
4022 block_id,
4023 calendar_schedule_id,
4024 staff_id,
4025 is_weekend,
4026 raw_target,
4027 target,
4028 initial_target,
4029 scheduled,
4030 other_scheduled,
4031 available_days
4032 )
4033 select
4034 st.block_id,
4035 st.calendar_schedule_id,
4036 st.staff_id,
4037 st.is_weekend,
4038 case
4039 when (ct.weighted_days_total > 0)
4040 then (ct.targets_total * st.weighted_days / ct.weighted_days_total)
4041 else 0
4042 end as raw_target,
4043 case
4044 when (ct.weighted_days_total > 0)
4045 then (ct.targets_total * st.weighted_days / ct.weighted_days_total)
4046 else 0
4047 end as target,
4048 case
4049 when (ct.weighted_days_total > 0)
4050 then (ct.targets_total * st.weighted_days / ct.weighted_days_total)
4051 else 0
4052 end as initial_target,
4053 st.scheduled,
4054 st.other_scheduled,
4055 st.available_days
4056 from
4057 buffer_tmp_targets_staff_totals_824879560 as st
4058 inner join buffer_tmp_targets_client_totals_824879560 as ct
4059 on st.block_id = ct.block_id
4060 and st.calendar_schedule_id = ct.calendar_schedule_id
4061 and st.is_weekend = ct.is_weekend
4062 order by null
4063
4064 (153.8ms) update
4065 buffer_hour_targets_824879560 as ht
4066 inner join (
4067 select
4068 block_id,
4069 calendar_schedule_id,
4070 is_weekend,
4071 sum(initial_target) as targets_total,
4072 sum(other_scheduled) as other_scheduled_total
4073 from buffer_hour_targets_824879560
4074 group by
4075 block_id,
4076 calendar_schedule_id,
4077 is_weekend
4078 order by null
4079 ) as t1
4080 on ht.block_id = t1.block_id
4081 and ht.calendar_schedule_id = t1.calendar_schedule_id
4082 and ht.is_weekend = t1.is_weekend
4083 left join adjusted_target_hours as aht
4084 on ht.block_id = aht.block_id
4085 and ht.calendar_schedule_id = aht.calendar_schedule_id
4086 and ht.staff_id = aht.staff_id
4087 and ht.is_weekend = aht.is_weekend
4088 set
4089 ht.target =
4090 case
4091 when (aht.id is not null) then aht.target
4092 when (t1.targets_total > 0)
4093 then ((t1.targets_total + t1.other_scheduled_total) * ht.initial_target / t1.targets_total - ht.other_scheduled)
4094 else 0.0
4095 end,
4096 ht.raw_target =
4097 case
4098 when (t1.targets_total > 0)
4099 then ((t1.targets_total + t1.other_scheduled_total) * ht.initial_target / t1.targets_total - ht.other_scheduled)
4100 else 0.0
4101 end
4102
4103 (152.8ms) insert into buffer_hour_targets_824879560 (
4104 block_id,
4105 calendar_schedule_id,
4106 staff_id,
4107 is_weekend,
4108 raw_target,
4109 target,
4110 initial_target,
4111 scheduled,
4112 other_scheduled,
4113 available_days
4114 )
4115 select
4116 sch_t.block_id,
4117 sch_t.calendar_schedule_id,
4118 sch_t.staff_id,
4119 sch_t.is_weekend,
4120 0.0 as raw_target,
4121 0.0 as target,
4122 0.0 as initial_target,
4123 sum(sch_t.scheduled) as scheduled,
4124 sum(sch_t.other_scheduled) as other_scheduled,
4125 0 as available_days
4126 from
4127 buffer_tmp_targets_scheduled_824879560 as sch_t
4128 left join buffer_hour_targets_824879560 as ht
4129 on sch_t.block_id = ht.block_id
4130 and sch_t.calendar_schedule_id = ht.calendar_schedule_id
4131 and sch_t.staff_id = ht.staff_id
4132 and sch_t.is_weekend = ht.is_weekend
4133 where
4134 sch_t.scheduled != 0
4135 and ht.id is null
4136 group by
4137 sch_t.block_id,
4138 sch_t.calendar_schedule_id,
4139 sch_t.staff_id,
4140 sch_t.is_weekend
4141 order by null
4142
4143Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0402 - 1413.721ms
4144 (163.4ms) delete ucdt
4145 from buffer_target_dates as td
4146 inner join unpublished_call_days_targets as ucdt
4147 on td.calendar_schedule_id = ucdt.calendar_schedule_id
4148 and td.block_id = ucdt.block_id
4149 where
4150 td.session_id = 824879560
4151 and td.build_cd_targets = 1
4152
4153 (171.3ms) insert into unpublished_call_days_targets (
4154 client_id,
4155 calendar_schedule_id,
4156 block_id,
4157 staff_id,
4158 assignment_id,
4159 assignment_type,
4160 day_of_week_mask,
4161 is_weekend,
4162 raw_target,
4163 target,
4164 initial_target,
4165 scheduled,
4166 available_days
4167 )
4168 select
4169 td.client_id,
4170 cdt.calendar_schedule_id,
4171 cdt.block_id,
4172 cdt.staff_id,
4173 cdt.assignment_id,
4174 cdt.assignment_type,
4175 cdt.day_of_week_mask,
4176 cdt.is_weekend,
4177 cdt.raw_target,
4178 cdt.target,
4179 cdt.initial_target,
4180 cdt.scheduled,
4181 cdt.available_days
4182 from
4183 buffer_target_dates as td
4184 inner join buffer_call_days_targets_824879560 as cdt
4185 on td.calendar_schedule_id = cdt.calendar_schedule_id
4186 and td.block_id = cdt.block_id
4187 left join published_blocks as pb
4188 on td.calendar_schedule_id = pb.calendar_schedule_id
4189 and td.block_id = pb.block_id
4190 left join published_block_call_types as pbct
4191 on pb.id = pbct.published_block_id
4192 and cdt.assignment_id = pbct.assignment_id
4193 and cdt.assignment_type = pbct.assignment_type
4194 and cdt.day_of_week_mask & pbct.days_of_week_mask > 0
4195 where
4196 td.session_id = 824879560 /* session_id */
4197 and td.build_cd_targets = 1
4198 and pbct.id is null
4199 union all
4200 select
4201 td.client_id,
4202 td.calendar_schedule_id,
4203 td.block_id,
4204 0 as staff_id,
4205 0 as assignment_id,
4206 '' as assignment_type,
4207 0 as day_of_week_mask,
4208 0 as is_weekend,
4209 0 as raw_target,
4210 0 as target,
4211 0 as initial_target,
4212 0 as scheduled,
4213 0 as available_days
4214 from
4215 buffer_target_dates as td
4216 where
4217 td.session_id = 824879560 /* session_id */
4218 and td.build_cd_targets = 1
4219 order by null
4220
4221 (155.2ms) delete uctt
4222 from
4223 buffer_target_dates as td
4224 inner join unpublished_call_type_targets as uctt
4225 on td.calendar_schedule_id = uctt.calendar_schedule_id
4226 and td.block_id = uctt.block_id
4227 where td.session_id = 824879560
4228 and td.build_ct_targets = 1
4229
4230 (158.9ms) insert into unpublished_call_type_targets (
4231 client_id,
4232 calendar_schedule_id,
4233 block_id,
4234 staff_id,
4235 assignment_id,
4236 assignment_type,
4237 is_weekend,
4238 raw_target,
4239 target,
4240 initial_target,
4241 scheduled,
4242 available_days
4243 )
4244 select
4245 td.client_id,
4246 ctt.calendar_schedule_id,
4247 ctt.block_id,
4248 ctt.staff_id,
4249 ctt.assignment_id,
4250 ctt.assignment_type,
4251 ctt.is_weekend,
4252 ctt.raw_target,
4253 ctt.target,
4254 ctt.initial_target,
4255 ctt.scheduled,
4256 ctt.available_days
4257 from buffer_target_dates as td
4258 inner join buffer_call_type_targets_824879560 as ctt
4259 on td.calendar_schedule_id = ctt.calendar_schedule_id
4260 and td.block_id = ctt.block_id
4261 left join published_blocks as pb
4262 on td.calendar_schedule_id = pb.calendar_schedule_id
4263 and td.block_id = pb.block_id
4264 left join published_block_call_types as pbct
4265 on pb.id = pbct.published_block_id
4266 and ctt.assignment_id = pbct.assignment_id
4267 and ctt.assignment_type = pbct.assignment_type
4268 and if(ctt.is_weekend = 0, 62, 65) & pbct.days_of_week_mask > 0
4269 where
4270 td.session_id = 824879560 /* session_id */
4271 and td.build_ct_targets = 1
4272 and pbct.id is null
4273 union all
4274 select
4275 td.client_id,
4276 td.calendar_schedule_id,
4277 td.block_id,
4278 0 as staff_id,
4279 0 as assignment_id,
4280 '' as assignment_type,
4281 0 as is_weekend,
4282 0 as raw_target,
4283 0 as target,
4284 0 as initial_target,
4285 0 as scheduled,
4286 0 as available_days
4287 from
4288 buffer_target_dates as td
4289 where
4290 td.session_id = 824879560 /* session_id */
4291 and td.build_ct_targets = 1
4292 order by null
4293
4294 (152.8ms) delete ut
4295 from
4296 buffer_target_dates as td
4297 inner join unpublished_targets as ut
4298 on td.calendar_schedule_id = ut.calendar_schedule_id
4299 and td.block_id = ut.block_id
4300 where td.session_id = 824879560
4301 and td.build_oa_targets = 1
4302
4303 (157.4ms) insert into unpublished_targets (
4304 client_id,
4305 calendar_schedule_id,
4306 block_id,
4307 staff_id,
4308 is_weekend,
4309 raw_target,
4310 target,
4311 initial_target,
4312 scheduled,
4313 available_days
4314 )
4315 select
4316 td.client_id,
4317 t.calendar_schedule_id,
4318 t.block_id,
4319 t.staff_id,
4320 t.is_weekend,
4321 t.raw_target,
4322 t.target,
4323 t.raw_target as initial_target,
4324 t.scheduled,
4325 t.available_days
4326 from buffer_target_dates as td
4327 inner join buffer_targets_824879560 as t
4328 on td.calendar_schedule_id = t.calendar_schedule_id
4329 and td.block_id = t.block_id
4330 where
4331 td.session_id = 824879560 /* session_id */
4332 and td.build_oa_targets = 1
4333 union all
4334 select
4335 td.client_id,
4336 td.calendar_schedule_id,
4337 td.block_id,
4338 0 as staff_id,
4339 0 as is_weekend,
4340 0 as raw_target,
4341 0 as target,
4342 0 as initial_target,
4343 0 as scheduled,
4344 0 as available_days
4345 from
4346 buffer_target_dates as td
4347 where
4348 td.session_id = 824879560 /* session_id */
4349 and td.build_oa_targets = 1
4350 order by null
4351
4352 (153.4ms) delete udowt
4353 from
4354 buffer_target_dates as td
4355 inner join unpublished_day_of_week_targets as udowt
4356 on td.calendar_schedule_id = udowt.calendar_schedule_id
4357 and td.block_id = udowt.block_id
4358 where
4359 td.session_id = 824879560
4360 and td.build_dow_targets = 1
4361
4362 (159.3ms) insert into unpublished_day_of_week_targets (
4363 client_id,
4364 calendar_schedule_id,
4365 block_id,
4366 staff_id,
4367 wday,
4368 raw_target,
4369 target,
4370 scheduled,
4371 available_days
4372 )
4373 select
4374 td.client_id,
4375 dowt.calendar_schedule_id,
4376 dowt.block_id,
4377 dowt.staff_id,
4378 dowt.wday,
4379 dowt.raw_target,
4380 dowt.target,
4381 dowt.scheduled,
4382 dowt.available_days
4383 from buffer_target_dates as td
4384 inner join buffer_day_of_week_targets_824879560 as dowt
4385 on td.calendar_schedule_id = dowt.calendar_schedule_id
4386 and td.block_id = dowt.block_id
4387 where
4388 td.session_id = 824879560 /* session_id */
4389 and td.build_dow_targets = 1
4390 union all
4391 select
4392 td.client_id,
4393 td.calendar_schedule_id,
4394 td.block_id,
4395 0 as staff_id,
4396 0 as wday,
4397 0 as raw_target,
4398 0 as target,
4399 0 as scheduled,
4400 0 as available_days
4401 from
4402 buffer_target_dates as td
4403 where
4404 td.session_id = 824879560 /* session_id */
4405 and td.build_dow_targets = 1
4406 order by null
4407
4408 (153.5ms) delete upt
4409 from
4410 buffer_target_dates as td
4411 inner join unpublished_point_targets as upt
4412 on td.calendar_schedule_id = upt.calendar_schedule_id
4413 and td.block_id = upt.block_id
4414 where
4415 td.session_id = 824879560
4416 and td.build_point_targets = 1
4417
4418 (158.1ms) insert into unpublished_point_targets (
4419 client_id,
4420 calendar_schedule_id,
4421 block_id,
4422 staff_id,
4423 is_weekend,
4424 raw_target,
4425 target,
4426 initial_target,
4427 scheduled,
4428 other_scheduled,
4429 available_days
4430 )
4431 select
4432 td.client_id,
4433 pt.calendar_schedule_id,
4434 pt.block_id,
4435 pt.staff_id,
4436 pt.is_weekend,
4437 pt.raw_target,
4438 pt.target,
4439 pt.initial_target,
4440 pt.scheduled,
4441 pt.other_scheduled,
4442 pt.available_days
4443 from
4444 buffer_target_dates as td
4445 inner join buffer_point_targets_824879560 as pt
4446 on td.calendar_schedule_id = pt.calendar_schedule_id
4447 and td.block_id = pt.block_id
4448 where
4449 td.session_id = 824879560 /* session_id */
4450 and td.build_point_targets = 1
4451 union all
4452 select
4453 td.client_id,
4454 td.calendar_schedule_id,
4455 td.block_id,
4456 0 as staff_id,
4457 0 as is_weekend,
4458 0 as raw_target,
4459 0 as target,
4460 0 as initial_target,
4461 0 as scheduled,
4462 0 as other_scheduled,
4463 0 as available_days
4464 from
4465 buffer_target_dates as td
4466 where
4467 td.session_id = 824879560 /* session_id */
4468 and td.build_point_targets = 1
4469 order by null
4470
4471 (152.8ms) delete uht
4472 from
4473 buffer_target_dates as td
4474 inner join unpublished_hour_targets as uht
4475 on td.calendar_schedule_id = uht.calendar_schedule_id
4476 and td.block_id = uht.block_id
4477 where
4478 td.session_id = 824879560
4479 and td.build_hour_targets = 1
4480
4481 (187.8ms) insert into unpublished_hour_targets (
4482 client_id,
4483 calendar_schedule_id,
4484 block_id,
4485 staff_id,
4486 is_weekend,
4487 raw_target,
4488 target,
4489 initial_target,
4490 scheduled,
4491 other_scheduled,
4492 available_days
4493 )
4494 select
4495 td.client_id,
4496 ht.calendar_schedule_id,
4497 ht.block_id,
4498 ht.staff_id,
4499 ht.is_weekend,
4500 ht.raw_target,
4501 ht.target,
4502 ht.initial_target,
4503 ht.scheduled,
4504 ht.other_scheduled,
4505 ht.available_days
4506 from
4507 buffer_target_dates as td
4508 inner join buffer_hour_targets_824879560 as ht
4509 on td.calendar_schedule_id = ht.calendar_schedule_id
4510 and td.block_id = ht.block_id
4511 where
4512 td.session_id = 824879560 /* session_id */
4513 and td.build_hour_targets = 1
4514 union all
4515 select
4516 td.client_id,
4517 td.calendar_schedule_id,
4518 td.block_id,
4519 0 as staff_id,
4520 0 as is_weekend,
4521 0 as raw_target,
4522 0 as target,
4523 0 as initial_target,
4524 0 as scheduled,
4525 0 as other_scheduled,
4526 0 as available_days
4527 from
4528 buffer_target_dates as td
4529 where
4530 td.session_id = 824879560 /* session_id */
4531 and td.build_hour_targets = 1
4532 order by null
4533
4534Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0701 - 1929.435ms
4535 (171.6ms) /* CumulativeCallDaysTargetsRule */
4536 insert into buffer_cumulative_cd_targets_824879560 (
4537 staff_id,
4538 assignment_id,
4539 assignment_type,
4540 day_of_week_mask,
4541 is_weekend,
4542 calendar_schedule_id,
4543 raw_target,
4544 adjusted_target,
4545 scheduled,
4546 available_days
4547 )
4548 select
4549 t.staff_id,
4550 t.assignment_id,
4551 t.assignment_type,
4552 t.day_of_week_mask,
4553 t.is_weekend,
4554 t.calendar_schedule_id,
4555 sum(t.raw_target) as raw_target,
4556 sum(t.adjusted_target) as adjusted_target,
4557 sum(t.scheduled) as scheduled,
4558 sum(t.available_days) as available_days
4559 from (
4560 select
4561 t.calendar_schedule_id,
4562 t.block_id,
4563 t.staff_id,
4564 t.assignment_id,
4565 t.assignment_type,
4566 t.day_of_week_mask,
4567 t.is_weekend,
4568 t.raw_target,
4569 t.target as adjusted_target,
4570 t.scheduled,
4571 t.available_days
4572 from
4573 buffer_target_dates as td
4574 inner join buffer_call_days_targets_824879560 as t
4575 on td.calendar_schedule_id = t.calendar_schedule_id
4576 and td.block_id = t.block_id
4577 where
4578 td.session_id = 824879560
4579 and td.build_cd_targets = 1
4580 and td.within_cumulative_period = 1
4581 union
4582 select
4583 cdt.calendar_schedule_id,
4584 cdt.block_id,
4585 cdt.staff_id,
4586 cdt.assignment_id,
4587 cdt.assignment_type,
4588 cdt.day_of_week_mask,
4589 cdt.is_weekend,
4590 cdt.raw_target,
4591 cdt.target,
4592 cdt.scheduled,
4593 cdt.available_days
4594 from
4595 buffer_target_dates as td
4596 inner join call_days_targets as cdt
4597 on td.calendar_schedule_id = cdt.calendar_schedule_id
4598 and td.block_id = cdt.block_id
4599 where
4600 td.session_id = 824879560
4601 and td.build_cd_targets = 0
4602 and td.cd_targets_source in ('published', 'both')
4603 and td.within_cumulative_period = 1
4604 union
4605 select
4606 ucdt.calendar_schedule_id,
4607 ucdt.block_id,
4608 ucdt.staff_id,
4609 ucdt.assignment_id,
4610 ucdt.assignment_type,
4611 ucdt.day_of_week_mask,
4612 ucdt.is_weekend,
4613 ucdt.raw_target,
4614 ucdt.target,
4615 ucdt.scheduled,
4616 ucdt.available_days
4617 from
4618 buffer_target_dates as td
4619 inner join unpublished_call_days_targets as ucdt
4620 on td.calendar_schedule_id = ucdt.calendar_schedule_id
4621 and td.block_id = ucdt.block_id
4622 where
4623 td.session_id = 824879560
4624 and td.build_cd_targets = 0
4625 and td.cd_targets_source in ('unpublished', 'both')
4626 and td.within_cumulative_period = 1
4627 union all
4628 select
4629 tad.calendar_schedule_id,
4630 tad.block_id,
4631 tad.staff_id,
4632 tad.assignment_id,
4633 tad.assignment_type,
4634 tad.day_of_week_mask,
4635 tad.is_weekend,
4636 0 as raw_target,
4637 0 as target,
4638 tad.adjustment_value as scheduled,
4639 0 as available_days
4640 from
4641 buffer_target_dates as td
4642 inner join target_adjustment_details as tad
4643 on td.calendar_schedule_id = tad.calendar_schedule_id
4644 and td.block_id = tad.block_id
4645 and tad.staff_id > 0
4646 where
4647 td.session_id = 824879560
4648 and td.within_cumulative_period = 1
4649 order by null
4650 ) as t
4651 group by
4652 t.staff_id,
4653 t.assignment_id,
4654 t.assignment_type,
4655 t.day_of_week_mask,
4656 t.is_weekend,
4657 t.calendar_schedule_id
4658 order by null
4659
4660 (161.1ms) /* AnnualCallMixRule */
4661 insert into buffer_cumulative_ct_targets_824879560 (
4662 staff_id,
4663 assignment_id,
4664 assignment_type,
4665 is_weekend,
4666 calendar_schedule_id,
4667 raw_target,
4668 adjusted_target,
4669 scheduled,
4670 available_days
4671 )
4672 select
4673 t.staff_id,
4674 t.assignment_id,
4675 t.assignment_type,
4676 t.is_weekend,
4677 t.calendar_schedule_id,
4678 sum(t.raw_target) as raw_target,
4679 sum(t.adjusted_target) as adjusted_target,
4680 sum(t.scheduled) as scheduled,
4681 sum(t.available_days) as available_days
4682 from (
4683 select
4684 t.calendar_schedule_id,
4685 t.block_id,
4686 t.staff_id,
4687 t.assignment_id,
4688 t.assignment_type,
4689 t.is_weekend,
4690 t.raw_target,
4691 t.target as adjusted_target,
4692 t.scheduled,
4693 t.available_days
4694 from buffer_target_dates as td
4695 inner join buffer_call_type_targets_824879560 as t
4696 on td.calendar_schedule_id = t.calendar_schedule_id
4697 and td.block_id = t.block_id
4698 where
4699 td.session_id = 824879560
4700 and td.build_ct_targets = 1
4701 and td.within_cumulative_period = 1
4702 union
4703 select
4704 ctt.calendar_schedule_id,
4705 ctt.block_id,
4706 ctt.staff_id,
4707 ctt.assignment_id,
4708 ctt.assignment_type,
4709 ctt.is_weekend,
4710 ctt.raw_target,
4711 ctt.target,
4712 ctt.scheduled,
4713 ctt.available_days
4714 from buffer_target_dates as td
4715 inner join call_type_targets as ctt
4716 on td.calendar_schedule_id = ctt.calendar_schedule_id
4717 and td.block_id = ctt.block_id
4718 where
4719 td.session_id = 824879560
4720 and td.build_ct_targets = 0
4721 and td.ct_targets_source in ('published', 'both')
4722 and td.within_cumulative_period = 1
4723 union
4724 select
4725 uctt.calendar_schedule_id,
4726 uctt.block_id,
4727 uctt.staff_id,
4728 uctt.assignment_id,
4729 uctt.assignment_type,
4730 uctt.is_weekend,
4731 uctt.raw_target,
4732 uctt.target,
4733 uctt.scheduled,
4734 uctt.available_days
4735 from
4736 buffer_target_dates as td
4737 inner join unpublished_call_type_targets as uctt
4738 on td.calendar_schedule_id = uctt.calendar_schedule_id
4739 and td.block_id = uctt.block_id
4740 where
4741 td.session_id = 824879560
4742 and td.build_ct_targets = 0
4743 and td.ct_targets_source in ('unpublished', 'both')
4744 and td.within_cumulative_period = 1
4745 union all
4746 select
4747 tad.calendar_schedule_id,
4748 tad.block_id,
4749 tad.staff_id,
4750 tad.assignment_id,
4751 tad.assignment_type,
4752 tad.is_weekend,
4753 0 as raw_target,
4754 0 as target,
4755 tad.adjustment_value as scheduled,
4756 0 as available_days
4757 from
4758 buffer_target_dates as td
4759 inner join target_adjustment_details as tad
4760 on td.calendar_schedule_id = tad.calendar_schedule_id
4761 and td.block_id = tad.block_id
4762 and tad.staff_id > 0
4763 where
4764 td.session_id = 824879560
4765 and td.within_cumulative_period = 1
4766 order by null
4767 ) as t
4768 group by
4769 t.staff_id,
4770 t.assignment_id,
4771 t.assignment_type,
4772 t.is_weekend,
4773 t.calendar_schedule_id
4774 order by null
4775
4776 (159.5ms) /* CumulativeWeeklyCallTypeTargetsRule */
4777 insert into buffer_cumulative_ct_targets_824879560 (
4778 staff_id,
4779 assignment_id,
4780 assignment_type,
4781 is_weekend,
4782 calendar_schedule_id,
4783 raw_target,
4784 adjusted_target,
4785 scheduled,
4786 available_days
4787 )
4788 select
4789 t.staff_id,
4790 t.assignment_id,
4791 t.assignment_type,
4792 -1 as is_weekend,
4793 t.calendar_schedule_id,
4794 sum(t.raw_target) as raw_target,
4795 sum(t.adjusted_target) as adjusted_target,
4796 sum(t.scheduled) as scheduled,
4797 sum(t.available_days) as available_days
4798 from (
4799 select
4800 t.calendar_schedule_id,
4801 t.block_id,
4802 t.staff_id,
4803 t.assignment_id,
4804 t.assignment_type,
4805 t.is_weekend,
4806 t.raw_target,
4807 t.target as adjusted_target,
4808 t.scheduled,
4809 t.available_days
4810 from
4811 buffer_target_dates as td
4812 inner join buffer_call_type_targets_824879560 as t
4813 on td.calendar_schedule_id = t.calendar_schedule_id
4814 and td.block_id = t.block_id
4815 where
4816 td.session_id = 824879560
4817 and td.build_ct_targets = 1
4818 and td.within_cumulative_period = 1
4819 union
4820 select
4821 ctt.calendar_schedule_id,
4822 ctt.block_id,
4823 ctt.staff_id,
4824 ctt.assignment_id,
4825 ctt.assignment_type,
4826 ctt.is_weekend,
4827 ctt.raw_target,
4828 ctt.target,
4829 ctt.scheduled,
4830 ctt.available_days
4831 from
4832 buffer_target_dates as td
4833 inner join call_type_targets as ctt
4834 on td.calendar_schedule_id = ctt.calendar_schedule_id
4835 and td.block_id = ctt.block_id
4836 where
4837 td.session_id = 824879560
4838 and td.build_ct_targets = 0
4839 and td.ct_targets_source in ('published', 'both')
4840 and td.within_cumulative_period = 1
4841 union
4842 select
4843 uctt.calendar_schedule_id,
4844 uctt.block_id,
4845 uctt.staff_id,
4846 uctt.assignment_id,
4847 uctt.assignment_type,
4848 uctt.is_weekend,
4849 uctt.raw_target,
4850 uctt.target,
4851 uctt.scheduled,
4852 uctt.available_days
4853 from
4854 buffer_target_dates as td
4855 inner join unpublished_call_type_targets as uctt
4856 on td.calendar_schedule_id = uctt.calendar_schedule_id
4857 and td.block_id = uctt.block_id
4858 where
4859 td.session_id = 824879560
4860 and td.build_ct_targets = 0
4861 and td.ct_targets_source in ('unpublished', 'both')
4862 and td.within_cumulative_period = 1
4863 union all
4864 select
4865 tad.calendar_schedule_id,
4866 tad.block_id,
4867 tad.staff_id,
4868 tad.assignment_id,
4869 tad.assignment_type,
4870 tad.is_weekend,
4871 0 as raw_target,
4872 0 as target,
4873 tad.adjustment_value as scheduled,
4874 0 as available_days
4875 from
4876 buffer_target_dates as td
4877 inner join target_adjustment_details as tad
4878 on td.calendar_schedule_id = tad.calendar_schedule_id
4879 and td.block_id = tad.block_id
4880 and tad.staff_id > 0
4881 where
4882 td.session_id = 824879560
4883 and td.within_cumulative_period = 1
4884 order by null
4885 ) as t
4886 group by
4887 t.staff_id,
4888 t.assignment_id,
4889 t.assignment_type,
4890 t.calendar_schedule_id
4891 order by null
4892
4893 (304.9ms) /* AnnualTargetsRule */
4894 insert into buffer_cumulative_oa_targets_824879560 (
4895 staff_id,
4896 is_weekend,
4897 calendar_schedule_id,
4898 raw_target,
4899 adjusted_target,
4900 scheduled,
4901 available_days
4902 )
4903 select
4904 t.staff_id,
4905 t.is_weekend,
4906 t.calendar_schedule_id,
4907 sum(t.raw_target) as raw_target,
4908 sum(t.adjusted_target) as adjusted_target,
4909 sum(t.scheduled) as scheduled,
4910 sum(t.available_days) as available_days
4911 from (
4912 select
4913 t.calendar_schedule_id,
4914 t.block_id,
4915 t.staff_id,
4916 t.is_weekend,
4917 t.raw_target,
4918 t.target as adjusted_target,
4919 t.scheduled,
4920 t.available_days
4921 from
4922 buffer_target_dates as td
4923 inner join buffer_targets_824879560 as t
4924 on td.calendar_schedule_id = t.calendar_schedule_id
4925 and td.block_id = t.block_id
4926 where
4927 td.session_id = 824879560
4928 and td.build_oa_targets = 1
4929 and td.within_cumulative_period = 1
4930 union
4931 select
4932 t.calendar_schedule_id,
4933 t.block_id,
4934 t.staff_id,
4935 t.is_weekend,
4936 t.raw_target,
4937 t.target,
4938 t.scheduled,
4939 t.days_with_availability as available_days
4940 from buffer_target_dates as td
4941 inner join targets as t
4942 on td.calendar_schedule_id = t.calendar_schedule_id
4943 and td.block_id = t.block_id
4944 where td.session_id = 824879560
4945 and td.build_oa_targets = 0
4946 and td.oa_targets_source = 'published'
4947 and td.within_cumulative_period = 1
4948 union
4949 select
4950 ut.calendar_schedule_id,
4951 ut.block_id,
4952 ut.staff_id,
4953 ut.is_weekend,
4954 ut.raw_target,
4955 ut.target,
4956 ut.scheduled,
4957 ut.available_days
4958 from buffer_target_dates as td
4959 inner join unpublished_targets as ut
4960 on td.calendar_schedule_id = ut.calendar_schedule_id
4961 and td.block_id = ut.block_id
4962 where td.session_id = 824879560
4963 and td.build_oa_targets = 0
4964 and td.oa_targets_source = 'unpublished'
4965 and td.within_cumulative_period = 1
4966 union all
4967 select
4968 tad.calendar_schedule_id,
4969 tad.block_id,
4970 tad.staff_id,
4971 tad.is_weekend,
4972 0 as raw_target,
4973 0 as target,
4974 tad.adjustment_value as scheduled,
4975 0 as available_days
4976 from buffer_target_dates as td
4977 inner join target_adjustment_details as tad
4978 on td.calendar_schedule_id = tad.calendar_schedule_id
4979 and td.block_id = tad.block_id
4980 and tad.staff_id > 0
4981 where td.session_id = 824879560
4982 and td.within_cumulative_period = 1
4983 order by null
4984 ) as t
4985 group by
4986 t.staff_id,
4987 t.is_weekend,
4988 t.calendar_schedule_id
4989 order by null
4990
4991 (301.8ms) /* CumulativeWeeklyOverallTargetsRule */
4992 insert into buffer_cumulative_oa_targets_824879560 (
4993 staff_id,
4994 is_weekend,
4995 calendar_schedule_id,
4996 raw_target,
4997 adjusted_target,
4998 scheduled,
4999 available_days
5000 )
5001 select
5002 t.staff_id,
5003 -1 as is_weekend,
5004 t.calendar_schedule_id,
5005 sum(t.raw_target) as raw_target,
5006 sum(t.adjusted_target) as adjusted_target,
5007 sum(t.scheduled) as scheduled,
5008 sum(t.available_days) as available_days
5009 from (
5010 select
5011 t.calendar_schedule_id,
5012 t.block_id,
5013 t.staff_id,
5014 t.is_weekend,
5015 t.raw_target,
5016 t.target as adjusted_target,
5017 t.scheduled,
5018 t.available_days
5019 from
5020 buffer_target_dates as td
5021 inner join buffer_targets_824879560 as t
5022 on td.calendar_schedule_id = t.calendar_schedule_id
5023 and td.block_id = t.block_id
5024 where
5025 td.session_id = 824879560
5026 and td.build_oa_targets = 1
5027 and td.within_cumulative_period = 1
5028 union
5029 select
5030 t.calendar_schedule_id,
5031 t.block_id,
5032 t.staff_id,
5033 t.is_weekend,
5034 t.raw_target,
5035 t.target,
5036 t.scheduled,
5037 t.days_with_availability as available_days
5038 from
5039 buffer_target_dates as td
5040 inner join targets as t
5041 on td.calendar_schedule_id = t.calendar_schedule_id
5042 and td.block_id = t.block_id
5043 where
5044 td.session_id = 824879560
5045 and td.build_oa_targets = 0
5046 and td.oa_targets_source = 'published'
5047 and td.within_cumulative_period = 1
5048 union
5049 select
5050 ut.calendar_schedule_id,
5051 ut.block_id,
5052 ut.staff_id,
5053 ut.is_weekend,
5054 ut.raw_target,
5055 ut.target,
5056 ut.scheduled,
5057 ut.available_days
5058 from
5059 buffer_target_dates as td
5060 inner join unpublished_targets as ut
5061 on td.calendar_schedule_id = ut.calendar_schedule_id
5062 and td.block_id = ut.block_id
5063 where
5064 td.session_id = 824879560
5065 and td.build_oa_targets = 0
5066 and td.oa_targets_source = 'unpublished'
5067 and td.within_cumulative_period = 1
5068 union all
5069 select
5070 tad.calendar_schedule_id,
5071 tad.block_id,
5072 tad.staff_id,
5073 tad.is_weekend,
5074 0 as raw_target,
5075 0 as target,
5076 tad.adjustment_value as scheduled,
5077 0 as available_days
5078 from
5079 buffer_target_dates as td
5080 inner join target_adjustment_details as tad
5081 on td.calendar_schedule_id = tad.calendar_schedule_id
5082 and td.block_id = tad.block_id
5083 and tad.staff_id > 0
5084 where
5085 td.session_id = 824879560
5086 and td.within_cumulative_period = 1
5087 order by null
5088 ) as t
5089 group by
5090 t.staff_id,
5091 t.calendar_schedule_id
5092 order by null
5093
5094 (159.4ms) /* AnnualDayOfWeekMixRule */
5095 insert into buffer_cumulative_dow_targets_824879560 (
5096 staff_id,
5097 wday,
5098 calendar_schedule_id,
5099 raw_target,
5100 adjusted_target,
5101 scheduled,
5102 available_days
5103 )
5104 select
5105 t.staff_id,
5106 t.wday,
5107 t.calendar_schedule_id,
5108 sum(t.raw_target) as raw_target,
5109 sum(t.adjusted_target) as adjusted_target,
5110 sum(t.scheduled) as scheduled,
5111 sum(t.available_days) as available_days
5112 from (
5113 select
5114 t.calendar_schedule_id,
5115 t.block_id,
5116 t.staff_id,
5117 t.wday,
5118 t.raw_target,
5119 t.target as adjusted_target,
5120 t.scheduled,
5121 t.available_days
5122 from buffer_target_dates as td
5123 inner join buffer_day_of_week_targets_824879560 as t
5124 on td.calendar_schedule_id = t.calendar_schedule_id
5125 and td.block_id = t.block_id
5126 where td.session_id = 824879560
5127 and td.build_dow_targets = 1
5128 and td.within_cumulative_period = 1
5129 union
5130 select
5131 dowt.calendar_schedule_id,
5132 dowt.block_id,
5133 dowt.staff_id,
5134 dowt.wday,
5135 dowt.raw_target,
5136 dowt.target,
5137 dowt.scheduled,
5138 dowt.available_days
5139 from buffer_target_dates as td
5140 inner join day_of_week_targets as dowt
5141 on td.calendar_schedule_id = dowt.calendar_schedule_id
5142 and td.block_id = dowt.block_id
5143 where td.session_id = 824879560
5144 and td.build_dow_targets = 0
5145 and td.dow_targets_source = 'published'
5146 and td.within_cumulative_period = 1
5147 union
5148 select
5149 udowt.calendar_schedule_id,
5150 udowt.block_id,
5151 udowt.staff_id,
5152 udowt.wday,
5153 udowt.raw_target,
5154 udowt.target,
5155 udowt.scheduled,
5156 udowt.available_days
5157 from buffer_target_dates as td
5158 inner join unpublished_day_of_week_targets as udowt
5159 on td.calendar_schedule_id = udowt.calendar_schedule_id
5160 and td.block_id = udowt.block_id
5161 where td.session_id = 824879560
5162 and td.build_dow_targets = 0
5163 and td.dow_targets_source = 'unpublished'
5164 and td.within_cumulative_period = 1
5165 union all
5166 select
5167 tad.calendar_schedule_id,
5168 tad.block_id,
5169 tad.staff_id,
5170 log2(tad.day_of_week_mask) as wday,
5171 0 as raw_target,
5172 0 as target,
5173 tad.adjustment_value as scheduled,
5174 0 as available_days
5175 from buffer_target_dates as td
5176 inner join target_adjustment_details as tad
5177 on td.calendar_schedule_id = tad.calendar_schedule_id
5178 and td.block_id = tad.block_id
5179 and tad.staff_id > 0
5180 where td.session_id = 824879560
5181 and td.within_cumulative_period = 1
5182 order by null
5183 ) as t
5184 group by
5185 t.staff_id,
5186 t.wday,
5187 t.calendar_schedule_id
5188 order by null
5189
5190 (161.7ms) /* CumulativePointTargetsRule */
5191 insert into buffer_cumulative_point_targets_824879560 (
5192 staff_id,
5193 is_weekend,
5194 calendar_schedule_id,
5195 raw_target,
5196 adjusted_target,
5197 scheduled,
5198 other_scheduled,
5199 available_days
5200 )
5201 select
5202 t.staff_id,
5203 t.is_weekend,
5204 t.calendar_schedule_id,
5205 sum(t.raw_target) as raw_target,
5206 sum(t.adjusted_target) as adjusted_target,
5207 sum(t.scheduled) as scheduled,
5208 sum(t.other_scheduled) as other_scheduled,
5209 sum(t.available_days) as available_days
5210 from (
5211 select
5212 t.calendar_schedule_id,
5213 t.block_id,
5214 t.staff_id,
5215 t.is_weekend,
5216 t.raw_target,
5217 t.target as adjusted_target,
5218 t.scheduled,
5219 t.other_scheduled,
5220 t.available_days
5221 from buffer_target_dates as td
5222 inner join buffer_point_targets_824879560 as t
5223 on td.calendar_schedule_id = t.calendar_schedule_id
5224 and td.block_id = t.block_id
5225 where td.session_id = 824879560
5226 and td.build_point_targets = 1
5227 and td.within_cumulative_period = 1
5228 union
5229 select
5230 pt.calendar_schedule_id,
5231 pt.block_id,
5232 pt.staff_id,
5233 pt.is_weekend,
5234 pt.raw_target,
5235 pt.target,
5236 pt.scheduled,
5237 pt.other_scheduled,
5238 pt.available_days
5239 from buffer_target_dates as td
5240 inner join point_targets as pt
5241 on td.calendar_schedule_id = pt.calendar_schedule_id
5242 and td.block_id = pt.block_id
5243 where td.session_id = 824879560
5244 and td.build_point_targets = 0
5245 and td.point_targets_source = 'published'
5246 and td.within_cumulative_period = 1
5247 union
5248 select
5249 upt.calendar_schedule_id,
5250 upt.block_id,
5251 upt.staff_id,
5252 upt.is_weekend,
5253 upt.raw_target,
5254 upt.target,
5255 upt.scheduled,
5256 upt.other_scheduled,
5257 upt.available_days
5258 from buffer_target_dates as td
5259 inner join unpublished_point_targets as upt
5260 on td.calendar_schedule_id = upt.calendar_schedule_id
5261 and td.block_id = upt.block_id
5262 where td.session_id = 824879560
5263 and td.build_point_targets = 0
5264 and td.point_targets_source = 'unpublished'
5265 and td.within_cumulative_period = 1
5266 order by null
5267 ) as t
5268 group by
5269 t.staff_id,
5270 t.is_weekend,
5271 t.calendar_schedule_id
5272 order by null
5273
5274 (158.6ms) /* CumulativeWeeklyPointTargetsRule */
5275 insert into buffer_cumulative_point_targets_824879560 (
5276 staff_id,
5277 is_weekend,
5278 calendar_schedule_id,
5279 raw_target,
5280 adjusted_target,
5281 scheduled,
5282 other_scheduled,
5283 available_days
5284 )
5285 select
5286 t.staff_id,
5287 -1 as is_weekend,
5288 t.calendar_schedule_id,
5289 sum(t.raw_target) as raw_target,
5290 sum(t.adjusted_target) as adjusted_target,
5291 sum(t.scheduled) as scheduled,
5292 sum(t.other_scheduled) as other_scheduled,
5293 sum(t.available_days) as available_days
5294 from (
5295 select
5296 t.calendar_schedule_id,
5297 t.block_id,
5298 t.staff_id,
5299 t.is_weekend,
5300 t.raw_target,
5301 t.target as adjusted_target,
5302 t.scheduled,
5303 t.other_scheduled,
5304 t.available_days
5305 from
5306 buffer_target_dates as td
5307 inner join buffer_point_targets_824879560 as t
5308 on td.calendar_schedule_id = t.calendar_schedule_id
5309 and td.block_id = t.block_id
5310 where
5311 td.session_id = 824879560
5312 and td.build_point_targets = 1
5313 and td.within_cumulative_period = 1
5314 union
5315 select
5316 pt.calendar_schedule_id,
5317 pt.block_id,
5318 pt.staff_id,
5319 pt.is_weekend,
5320 pt.raw_target,
5321 pt.target,
5322 pt.scheduled,
5323 pt.other_scheduled,
5324 pt.available_days
5325 from
5326 buffer_target_dates as td
5327 inner join point_targets as pt
5328 on td.calendar_schedule_id = pt.calendar_schedule_id
5329 and td.block_id = pt.block_id
5330 where
5331 td.session_id = 824879560
5332 and td.build_point_targets = 0
5333 and td.point_targets_source = 'published'
5334 and td.within_cumulative_period = 1
5335 union
5336 select
5337 upt.calendar_schedule_id,
5338 upt.block_id,
5339 upt.staff_id,
5340 upt.is_weekend,
5341 upt.raw_target,
5342 upt.target,
5343 upt.scheduled,
5344 upt.other_scheduled,
5345 upt.available_days
5346 from
5347 buffer_target_dates as td
5348 inner join unpublished_point_targets as upt
5349 on td.calendar_schedule_id = upt.calendar_schedule_id
5350 and td.block_id = upt.block_id
5351 where
5352 td.session_id = 824879560
5353 and td.build_point_targets = 0
5354 and td.point_targets_source = 'unpublished'
5355 and td.within_cumulative_period = 1
5356 order by null
5357 ) as t
5358 group by
5359 t.staff_id,
5360 t.calendar_schedule_id
5361 order by null
5362
5363 (158.0ms) /* CumulativeHourTargetsRule */
5364 insert into buffer_cumulative_hour_targets_824879560 (
5365 staff_id,
5366 is_weekend,
5367 calendar_schedule_id,
5368 raw_target,
5369 adjusted_target,
5370 scheduled,
5371 other_scheduled,
5372 available_days
5373 )
5374 select
5375 t.staff_id,
5376 t.is_weekend,
5377 t.calendar_schedule_id,
5378 sum(t.raw_target) as raw_target,
5379 sum(t.adjusted_target) as adjusted_target,
5380 sum(t.scheduled) as scheduled,
5381 sum(t.other_scheduled) as other_scheduled,
5382 sum(t.available_days) as available_days
5383 from (
5384 select
5385 t.calendar_schedule_id,
5386 t.block_id,
5387 t.staff_id,
5388 t.is_weekend,
5389 t.raw_target,
5390 t.target as adjusted_target,
5391 t.scheduled,
5392 t.other_scheduled,
5393 t.available_days
5394 from buffer_target_dates as td
5395 inner join buffer_hour_targets_824879560 as t
5396 on td.calendar_schedule_id = t.calendar_schedule_id
5397 and td.block_id = t.block_id
5398 where td.session_id = 824879560
5399 and td.build_hour_targets = 1
5400 and td.within_cumulative_period = 1
5401 union
5402 select
5403 ht.calendar_schedule_id,
5404 ht.block_id,
5405 ht.staff_id,
5406 ht.is_weekend,
5407 ht.raw_target,
5408 ht.target,
5409 ht.scheduled,
5410 ht.other_scheduled,
5411 ht.available_days
5412 from buffer_target_dates as td
5413 inner join hour_targets as ht
5414 on td.calendar_schedule_id = ht.calendar_schedule_id
5415 and td.block_id = ht.block_id
5416 where td.session_id = 824879560
5417 and td.build_hour_targets = 0
5418 and td.hour_targets_source = 'published'
5419 and td.within_cumulative_period = 1
5420 union
5421 select
5422 uht.calendar_schedule_id,
5423 uht.block_id,
5424 uht.staff_id,
5425 uht.is_weekend,
5426 uht.raw_target,
5427 uht.target,
5428 uht.scheduled,
5429 uht.other_scheduled,
5430 uht.available_days
5431 from buffer_target_dates as td
5432 inner join unpublished_hour_targets as uht
5433 on td.calendar_schedule_id = uht.calendar_schedule_id
5434 and td.block_id = uht.block_id
5435 where td.session_id = 824879560
5436 and td.build_hour_targets = 0
5437 and td.hour_targets_source = 'unpublished'
5438 and td.within_cumulative_period = 1
5439 order by null
5440 ) as t
5441 group by
5442 t.staff_id,
5443 t.is_weekend,
5444 t.calendar_schedule_id
5445 order by null
5446
5447 (156.4ms) /* CumulativeWeeklyHourTargetsRule */
5448 insert into buffer_cumulative_hour_targets_824879560 (
5449 staff_id,
5450 is_weekend,
5451 calendar_schedule_id,
5452 raw_target,
5453 adjusted_target,
5454 scheduled,
5455 other_scheduled,
5456 available_days
5457 )
5458 select
5459 t.staff_id,
5460 -1 as is_weekend,
5461 t.calendar_schedule_id,
5462 sum(t.raw_target) as raw_target,
5463 sum(t.adjusted_target) as adjusted_target,
5464 sum(t.scheduled) as scheduled,
5465 sum(t.other_scheduled) as other_scheduled,
5466 sum(t.available_days) as available_days
5467 from (
5468 select
5469 t.calendar_schedule_id,
5470 t.block_id,
5471 t.staff_id,
5472 t.is_weekend,
5473 t.raw_target,
5474 t.target as adjusted_target,
5475 t.scheduled,
5476 t.other_scheduled,
5477 t.available_days
5478 from
5479 buffer_target_dates as td
5480 inner join buffer_hour_targets_824879560 as t
5481 on td.calendar_schedule_id = t.calendar_schedule_id
5482 and td.block_id = t.block_id
5483 where
5484 td.session_id = 824879560
5485 and td.build_hour_targets = 1
5486 and td.within_cumulative_period = 1
5487 union
5488 select
5489 ht.calendar_schedule_id,
5490 ht.block_id,
5491 ht.staff_id,
5492 ht.is_weekend,
5493 ht.raw_target,
5494 ht.target,
5495 ht.scheduled,
5496 ht.other_scheduled,
5497 ht.available_days
5498 from
5499 buffer_target_dates as td
5500 inner join hour_targets as ht
5501 on td.calendar_schedule_id = ht.calendar_schedule_id
5502 and td.block_id = ht.block_id
5503 where
5504 td.session_id = 824879560
5505 and td.build_hour_targets = 0
5506 and td.hour_targets_source = 'published'
5507 and td.within_cumulative_period = 1
5508 union
5509 select
5510 uht.calendar_schedule_id,
5511 uht.block_id,
5512 uht.staff_id,
5513 uht.is_weekend,
5514 uht.raw_target,
5515 uht.target,
5516 uht.scheduled,
5517 uht.other_scheduled,
5518 uht.available_days
5519 from
5520 buffer_target_dates as td
5521 inner join unpublished_hour_targets as uht
5522 on td.calendar_schedule_id = uht.calendar_schedule_id
5523 and td.block_id = uht.block_id
5524 where
5525 td.session_id = 824879560
5526 and td.build_hour_targets = 0
5527 and td.hour_targets_source = 'unpublished'
5528 and td.within_cumulative_period = 1
5529 order by null
5530 ) as t
5531 group by
5532 t.staff_id,
5533 t.calendar_schedule_id
5534 order by null
5535
5536Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0702 - 1900.2079999999999ms
5537 (178.8ms) /* CurrentCallDaysTargetsRule */
5538 insert into buffer_current_cd_targets_824879560 (
5539 staff_id,
5540 assignment_id,
5541 assignment_type,
5542 day_of_week_mask,
5543 is_weekend,
5544 period_offset,
5545 calendar_schedule_id,
5546 raw_target,
5547 adjusted_target,
5548 scheduled,
5549 available_days
5550 )
5551 select
5552 t.staff_id,
5553 t.assignment_id,
5554 t.assignment_type,
5555 t.day_of_week_mask,
5556 t.is_weekend,
5557 t.period_offset,
5558 t.calendar_schedule_id,
5559 sum(t.raw_target) as raw_target,
5560 sum(t.adjusted_target) as adjusted_target,
5561 sum(t.scheduled) as scheduled,
5562 sum(t.available_days) as available_days
5563 from (
5564 select
5565 t.calendar_schedule_id,
5566 t.block_id,
5567 t.staff_id,
5568 td.period_offset,
5569 t.assignment_id,
5570 t.assignment_type,
5571 t.day_of_week_mask,
5572 t.is_weekend,
5573 t.raw_target,
5574 t.target as adjusted_target,
5575 t.scheduled,
5576 t.available_days
5577 from buffer_target_dates as td
5578 inner join buffer_call_days_targets_824879560 as t
5579 on td.calendar_schedule_id = t.calendar_schedule_id
5580 and td.block_id = t.block_id
5581 where td.session_id = 824879560
5582 and td.build_cd_targets = 1
5583 and td.affected_by_populate = 1
5584 union
5585 select
5586 cdt.calendar_schedule_id,
5587 cdt.block_id,
5588 cdt.staff_id,
5589 td.period_offset,
5590 cdt.assignment_id,
5591 cdt.assignment_type,
5592 cdt.day_of_week_mask,
5593 cdt.is_weekend,
5594 cdt.raw_target,
5595 cdt.target,
5596 cdt.scheduled,
5597 cdt.available_days
5598 from buffer_target_dates as td
5599 inner join call_days_targets as cdt
5600 on td.calendar_schedule_id = cdt.calendar_schedule_id
5601 and td.block_id = cdt.block_id
5602 where td.session_id = 824879560
5603 and td.build_cd_targets = 0
5604 and td.cd_targets_source in ('published', 'both')
5605 and td.affected_by_populate = 1
5606 union
5607 select
5608 ucdt.calendar_schedule_id,
5609 ucdt.block_id,
5610 ucdt.staff_id,
5611 td.period_offset,
5612 ucdt.assignment_id,
5613 ucdt.assignment_type,
5614 ucdt.day_of_week_mask,
5615 ucdt.is_weekend,
5616 ucdt.raw_target,
5617 ucdt.target,
5618 ucdt.scheduled,
5619 ucdt.available_days
5620 from buffer_target_dates as td
5621 inner join unpublished_call_days_targets as ucdt
5622 on td.calendar_schedule_id = ucdt.calendar_schedule_id
5623 and td.block_id = ucdt.block_id
5624 where td.session_id = 824879560
5625 and td.build_cd_targets = 0
5626 and td.cd_targets_source in ('unpublished', 'both')
5627 and td.affected_by_populate = 1
5628 union all
5629 select
5630 tad.calendar_schedule_id,
5631 tad.block_id,
5632 tad.staff_id,
5633 td.period_offset,
5634 tad.assignment_id,
5635 tad.assignment_type,
5636 tad.day_of_week_mask,
5637 tad.is_weekend,
5638 0 as raw_target,
5639 0 as target,
5640 tad.adjustment_value as scheduled,
5641 0 as available_days
5642 from buffer_target_dates as td
5643 inner join target_adjustment_details as tad
5644 on td.calendar_schedule_id = tad.calendar_schedule_id
5645 and td.block_id = tad.block_id
5646 and tad.staff_id > 0
5647 where td.session_id = 824879560
5648 and td.affected_by_populate = 1
5649 order by null
5650 ) as t
5651 group by
5652 t.staff_id,
5653 t.assignment_id,
5654 t.assignment_type,
5655 t.day_of_week_mask,
5656 t.is_weekend,
5657 t.period_offset,
5658 t.calendar_schedule_id
5659 order by null
5660
5661 (188.4ms) /* MonthlyCallMixRule */
5662 insert into buffer_current_ct_targets_824879560 (
5663 staff_id,
5664 assignment_id,
5665 assignment_type,
5666 is_weekend,
5667 period_offset,
5668 calendar_schedule_id,
5669 raw_target,
5670 adjusted_target,
5671 scheduled,
5672 available_days
5673 )
5674 select
5675 t.staff_id,
5676 t.assignment_id,
5677 t.assignment_type,
5678 t.is_weekend,
5679 t.period_offset,
5680 t.calendar_schedule_id,
5681 sum(t.raw_target) as raw_target,
5682 sum(t.adjusted_target) as adjusted_target,
5683 sum(t.scheduled) as scheduled,
5684 sum(t.available_days) as available_days
5685 from (
5686 select
5687 t.calendar_schedule_id,
5688 t.block_id,
5689 t.staff_id,
5690 td.period_offset,
5691 t.assignment_id,
5692 t.assignment_type,
5693 t.is_weekend,
5694 t.raw_target,
5695 t.target as adjusted_target,
5696 t.scheduled,
5697 t.available_days
5698 from buffer_target_dates as td
5699 inner join buffer_call_type_targets_824879560 as t
5700 on td.calendar_schedule_id = t.calendar_schedule_id
5701 and td.block_id = t.block_id
5702 where td.session_id = 824879560
5703 and td.build_ct_targets = 1
5704 and td.affected_by_populate = 1
5705 union
5706 select
5707 ctt.calendar_schedule_id,
5708 ctt.block_id,
5709 ctt.staff_id,
5710 td.period_offset,
5711 ctt.assignment_id,
5712 ctt.assignment_type,
5713 ctt.is_weekend,
5714 ctt.raw_target,
5715 ctt.target,
5716 ctt.scheduled,
5717 ctt.available_days
5718 from buffer_target_dates as td
5719 inner join call_type_targets as ctt
5720 on td.calendar_schedule_id = ctt.calendar_schedule_id
5721 and td.block_id = ctt.block_id
5722 where td.session_id = 824879560
5723 and td.build_ct_targets = 0
5724 and td.ct_targets_source in ('published', 'both')
5725 and td.affected_by_populate = 1
5726 union
5727 select
5728 uctt.calendar_schedule_id,
5729 uctt.block_id,
5730 uctt.staff_id,
5731 td.period_offset,
5732 uctt.assignment_id,
5733 uctt.assignment_type,
5734 uctt.is_weekend,
5735 uctt.raw_target,
5736 uctt.target,
5737 uctt.scheduled,
5738 uctt.available_days
5739 from buffer_target_dates as td
5740 inner join unpublished_call_type_targets as uctt
5741 on td.calendar_schedule_id = uctt.calendar_schedule_id
5742 and td.block_id = uctt.block_id
5743 where td.session_id = 824879560
5744 and td.build_ct_targets = 0
5745 and td.ct_targets_source in ('unpublished', 'both')
5746 and td.affected_by_populate = 1
5747 union all
5748 select
5749 tad.calendar_schedule_id,
5750 tad.block_id,
5751 tad.staff_id,
5752 td.period_offset,
5753 tad.assignment_id,
5754 tad.assignment_type,
5755 tad.is_weekend,
5756 0 as raw_target,
5757 0 as target,
5758 tad.adjustment_value as scheduled,
5759 0 as available_days
5760 from buffer_target_dates as td
5761 inner join target_adjustment_details as tad
5762 on td.calendar_schedule_id = tad.calendar_schedule_id
5763 and td.block_id = tad.block_id
5764 and tad.staff_id > 0
5765 where td.session_id = 824879560
5766 and td.affected_by_populate = 1
5767 order by null
5768 ) as t
5769 group by
5770 t.staff_id,
5771 t.assignment_id,
5772 t.assignment_type,
5773 t.is_weekend,
5774 t.period_offset,
5775 t.calendar_schedule_id
5776 order by null
5777
5778 (164.9ms) /* CurrentWeeklyCallTypeTargetsRule */
5779 insert into buffer_current_ct_targets_824879560 (
5780 staff_id,
5781 assignment_id,
5782 assignment_type,
5783 is_weekend,
5784 period_offset,
5785 calendar_schedule_id,
5786 raw_target,
5787 adjusted_target,
5788 scheduled,
5789 available_days
5790 )
5791 select
5792 t.staff_id,
5793 t.assignment_id,
5794 t.assignment_type,
5795 -1 as is_weekend,
5796 t.period_offset,
5797 t.calendar_schedule_id,
5798 sum(t.raw_target) as raw_target,
5799 sum(t.adjusted_target) as adjusted_target,
5800 sum(t.scheduled) as scheduled,
5801 sum(t.available_days) as available_days
5802 from (
5803 select
5804 t.calendar_schedule_id,
5805 t.block_id,
5806 t.staff_id,
5807 td.period_offset,
5808 t.assignment_id,
5809 t.assignment_type,
5810 t.is_weekend,
5811 t.raw_target,
5812 t.target as adjusted_target,
5813 t.scheduled,
5814 t.available_days
5815 from
5816 buffer_target_dates as td
5817 inner join buffer_call_type_targets_824879560 as t
5818 on td.calendar_schedule_id = t.calendar_schedule_id
5819 and td.block_id = t.block_id
5820 where
5821 td.session_id = 824879560
5822 and td.build_ct_targets = 1
5823 and td.affected_by_populate = 1
5824 union
5825 select
5826 ctt.calendar_schedule_id,
5827 ctt.block_id,
5828 ctt.staff_id,
5829 td.period_offset,
5830 ctt.assignment_id,
5831 ctt.assignment_type,
5832 ctt.is_weekend,
5833 ctt.raw_target,
5834 ctt.target,
5835 ctt.scheduled,
5836 ctt.available_days
5837 from
5838 buffer_target_dates as td
5839 inner join call_type_targets as ctt
5840 on td.calendar_schedule_id = ctt.calendar_schedule_id
5841 and td.block_id = ctt.block_id
5842 where
5843 td.session_id = 824879560
5844 and td.build_ct_targets = 0
5845 and td.ct_targets_source in ('published', 'both')
5846 and td.affected_by_populate = 1
5847 union
5848 select
5849 uctt.calendar_schedule_id,
5850 uctt.block_id,
5851 uctt.staff_id,
5852 td.period_offset,
5853 uctt.assignment_id,
5854 uctt.assignment_type,
5855 uctt.is_weekend,
5856 uctt.raw_target,
5857 uctt.target,
5858 uctt.scheduled,
5859 uctt.available_days
5860 from
5861 buffer_target_dates as td
5862 inner join unpublished_call_type_targets as uctt
5863 on td.calendar_schedule_id = uctt.calendar_schedule_id
5864 and td.block_id = uctt.block_id
5865 where
5866 td.session_id = 824879560
5867 and td.build_ct_targets = 0
5868 and td.ct_targets_source in ('unpublished', 'both')
5869 and td.affected_by_populate = 1
5870 union all
5871 select
5872 tad.calendar_schedule_id,
5873 tad.block_id,
5874 tad.staff_id,
5875 td.period_offset,
5876 tad.assignment_id,
5877 tad.assignment_type,
5878 tad.is_weekend,
5879 0 as raw_target,
5880 0 as target,
5881 tad.adjustment_value as scheduled,
5882 0 as available_days
5883 from
5884 buffer_target_dates as td
5885 inner join target_adjustment_details as tad
5886 on td.calendar_schedule_id = tad.calendar_schedule_id
5887 and td.block_id = tad.block_id
5888 and tad.staff_id > 0
5889 where
5890 td.session_id = 824879560
5891 and td.affected_by_populate = 1
5892 order by null
5893 ) as t
5894 group by
5895 t.staff_id,
5896 t.assignment_id,
5897 t.assignment_type,
5898 t.period_offset,
5899 t.calendar_schedule_id
5900 order by null
5901
5902 (158.8ms) /* StaffCapacityRule */
5903 insert into buffer_current_oa_targets_824879560 (
5904 staff_id,
5905 is_weekend,
5906 period_offset,
5907 calendar_schedule_id,
5908 raw_target,
5909 adjusted_target,
5910 scheduled,
5911 available_days
5912 )
5913 select
5914 t.staff_id,
5915 t.is_weekend,
5916 t.period_offset,
5917 t.calendar_schedule_id,
5918 sum(t.raw_target) as raw_target,
5919 sum(t.adjusted_target) as adjusted_target,
5920 sum(t.scheduled) as scheduled,
5921 sum(t.available_days) as available_days
5922 from (
5923 select
5924 t.calendar_schedule_id,
5925 t.block_id,
5926 t.staff_id,
5927 td.period_offset,
5928 t.is_weekend,
5929 t.raw_target,
5930 t.target as adjusted_target,
5931 t.scheduled,
5932 t.available_days
5933 from buffer_target_dates as td
5934 inner join buffer_targets_824879560 as t
5935 on td.calendar_schedule_id = t.calendar_schedule_id
5936 and td.block_id = t.block_id
5937 where td.session_id = 824879560
5938 and td.build_oa_targets = 1
5939 and td.affected_by_populate = 1
5940 union
5941 select
5942 t.calendar_schedule_id,
5943 t.block_id,
5944 t.staff_id,
5945 td.period_offset,
5946 t.is_weekend,
5947 t.raw_target,
5948 t.target,
5949 t.scheduled,
5950 t.days_with_availability as available_days
5951 from buffer_target_dates as td
5952 inner join targets as t
5953 on td.calendar_schedule_id = t.calendar_schedule_id
5954 and td.block_id = t.block_id
5955 where td.session_id = 824879560
5956 and td.build_oa_targets = 0
5957 and td.oa_targets_source = 'published'
5958 and td.affected_by_populate = 1
5959 union
5960 select
5961 ut.calendar_schedule_id,
5962 ut.block_id,
5963 ut.staff_id,
5964 td.period_offset,
5965 ut.is_weekend,
5966 ut.raw_target,
5967 ut.target,
5968 ut.scheduled,
5969 ut.available_days
5970 from
5971 buffer_target_dates as td
5972 inner join unpublished_targets as ut
5973 on td.calendar_schedule_id = ut.calendar_schedule_id
5974 and td.block_id = ut.block_id
5975 where
5976 td.session_id = 824879560
5977 and td.build_oa_targets = 0
5978 and td.oa_targets_source = 'unpublished'
5979 and td.affected_by_populate = 1
5980 union all
5981 select
5982 tad.calendar_schedule_id,
5983 tad.block_id,
5984 tad.staff_id,
5985 td.period_offset,
5986 tad.is_weekend,
5987 0 as raw_target,
5988 0 as target,
5989 tad.adjustment_value as scheduled,
5990 0 as available_days
5991 from buffer_target_dates as td
5992 inner join target_adjustment_details as tad
5993 on td.calendar_schedule_id = tad.calendar_schedule_id
5994 and td.block_id = tad.block_id
5995 and tad.staff_id > 0
5996 where td.session_id = 824879560
5997 and td.build_oa_targets = 0
5998 and td.oa_targets_source = 'unpublished'
5999 and td.affected_by_populate = 1
6000 order by null
6001 ) as t
6002 group by
6003 t.staff_id,
6004 t.is_weekend,
6005 t.period_offset,
6006 t.calendar_schedule_id
6007 order by null
6008
6009 (158.7ms) /* CurrentWeeklyOverallTargetsRule */
6010 insert into buffer_current_oa_targets_824879560 (
6011 staff_id,
6012 is_weekend,
6013 period_offset,
6014 calendar_schedule_id,
6015 raw_target,
6016 adjusted_target,
6017 scheduled,
6018 available_days
6019 )
6020 select
6021 t.staff_id,
6022 -1 as is_weekend,
6023 t.period_offset,
6024 t.calendar_schedule_id,
6025 sum(t.raw_target) as raw_target,
6026 sum(t.adjusted_target) as adjusted_target,
6027 sum(t.scheduled) as scheduled,
6028 sum(t.available_days) as available_days
6029 from (
6030 select
6031 t.calendar_schedule_id,
6032 t.block_id,
6033 t.staff_id,
6034 td.period_offset,
6035 t.is_weekend,
6036 t.raw_target,
6037 t.target as adjusted_target,
6038 t.scheduled,
6039 t.available_days
6040 from
6041 buffer_target_dates as td
6042 inner join buffer_targets_824879560 as t
6043 on td.calendar_schedule_id = t.calendar_schedule_id
6044 and td.block_id = t.block_id
6045 where
6046 td.session_id = 824879560
6047 and td.build_oa_targets = 1
6048 and td.affected_by_populate = 1
6049 union
6050 select
6051 t.calendar_schedule_id,
6052 t.block_id,
6053 t.staff_id,
6054 td.period_offset,
6055 t.is_weekend,
6056 t.raw_target,
6057 t.target,
6058 t.scheduled,
6059 t.days_with_availability as available_days
6060 from
6061 buffer_target_dates as td
6062 inner join targets as t
6063 on td.calendar_schedule_id = t.calendar_schedule_id
6064 and td.block_id = t.block_id
6065 where
6066 td.session_id = 824879560
6067 and td.build_oa_targets = 0
6068 and td.oa_targets_source = 'published'
6069 and td.affected_by_populate = 1
6070 union
6071 select
6072 ut.calendar_schedule_id,
6073 ut.block_id,
6074 ut.staff_id,
6075 td.period_offset,
6076 ut.is_weekend,
6077 ut.raw_target,
6078 ut.target,
6079 ut.scheduled,
6080 ut.available_days
6081 from
6082 buffer_target_dates as td
6083 inner join unpublished_targets as ut
6084 on td.calendar_schedule_id = ut.calendar_schedule_id
6085 and td.block_id = ut.block_id
6086 where
6087 td.session_id = 824879560
6088 and td.build_oa_targets = 0
6089 and td.oa_targets_source = 'unpublished'
6090 and td.affected_by_populate = 1
6091 union all
6092 select
6093 tad.calendar_schedule_id,
6094 tad.block_id,
6095 tad.staff_id,
6096 td.period_offset,
6097 tad.is_weekend,
6098 0 as raw_target,
6099 0 as target,
6100 tad.adjustment_value as scheduled,
6101 0 as available_days
6102 from
6103 buffer_target_dates as td
6104 inner join target_adjustment_details as tad
6105 on td.calendar_schedule_id = tad.calendar_schedule_id
6106 and td.block_id = tad.block_id
6107 and tad.staff_id > 0
6108 where
6109 td.session_id = 824879560
6110 and td.build_oa_targets = 0
6111 and td.oa_targets_source = 'unpublished'
6112 and td.affected_by_populate = 1
6113 order by null
6114 ) as t
6115 group by
6116 t.staff_id,
6117 t.period_offset,
6118 t.calendar_schedule_id
6119 order by null
6120
6121 (161.4ms) /* MonthlyDayOfWeekMixRule */
6122 insert into buffer_current_dow_targets_824879560 (
6123 staff_id,
6124 wday,
6125 period_offset,
6126 calendar_schedule_id,
6127 raw_target,
6128 adjusted_target,
6129 scheduled,
6130 available_days
6131 )
6132 select
6133 t.staff_id,
6134 t.wday,
6135 t.period_offset,
6136 t.calendar_schedule_id,
6137 sum(t.raw_target) as raw_target,
6138 sum(t.adjusted_target) as adjusted_target,
6139 sum(t.scheduled) as scheduled,
6140 sum(t.available_days) as available_days
6141 from (
6142 select
6143 t.calendar_schedule_id,
6144 t.block_id,
6145 t.staff_id,
6146 td.period_offset,
6147 t.wday,
6148 t.raw_target,
6149 t.target as adjusted_target,
6150 t.scheduled,
6151 t.available_days
6152 from buffer_target_dates as td
6153 inner join buffer_day_of_week_targets_824879560 as t
6154 on td.calendar_schedule_id = t.calendar_schedule_id
6155 and td.block_id = t.block_id
6156 where td.session_id = 824879560
6157 and td.build_dow_targets = 1
6158 and td.affected_by_populate = 1
6159 union
6160 select
6161 dowt.calendar_schedule_id,
6162 dowt.block_id,
6163 dowt.staff_id,
6164 td.period_offset,
6165 dowt.wday,
6166 dowt.raw_target,
6167 dowt.target,
6168 dowt.scheduled,
6169 dowt.available_days
6170 from buffer_target_dates as td
6171 inner join day_of_week_targets as dowt
6172 on td.calendar_schedule_id = dowt.calendar_schedule_id
6173 and td.block_id = dowt.block_id
6174 where td.session_id = 824879560
6175 and td.build_dow_targets = 0
6176 and td.dow_targets_source = 'published'
6177 and td.affected_by_populate = 1
6178 union
6179 select
6180 udowt.calendar_schedule_id,
6181 udowt.block_id,
6182 udowt.staff_id,
6183 td.period_offset,
6184 udowt.wday,
6185 udowt.raw_target,
6186 udowt.target,
6187 udowt.scheduled,
6188 udowt.available_days
6189 from buffer_target_dates as td
6190 inner join unpublished_day_of_week_targets as udowt
6191 on td.calendar_schedule_id = udowt.calendar_schedule_id
6192 and td.block_id = udowt.block_id
6193 where td.session_id = 824879560
6194 and td.build_dow_targets = 0
6195 and td.dow_targets_source = 'unpublished'
6196 and td.affected_by_populate = 1
6197 union all
6198 select
6199 tad.calendar_schedule_id,
6200 tad.block_id,
6201 tad.staff_id,
6202 td.period_offset,
6203 log2(tad.day_of_week_mask) as wday,
6204 0 as raw_target,
6205 0 as target,
6206 tad.adjustment_value as scheduled,
6207 0 as available_days
6208 from buffer_target_dates as td
6209 inner join target_adjustment_details as tad
6210 on td.calendar_schedule_id = tad.calendar_schedule_id
6211 and td.block_id = tad.block_id
6212 and tad.staff_id > 0
6213 where td.session_id = 824879560
6214 and td.affected_by_populate = 1
6215 order by null
6216 ) as t
6217 group by
6218 t.staff_id,
6219 t.wday,
6220 t.period_offset,
6221 t.calendar_schedule_id
6222 order by null
6223
6224 (157.3ms) /* CurrentPointTargetsRule */
6225 insert into buffer_current_point_targets_824879560 (
6226 staff_id,
6227 is_weekend,
6228 period_offset,
6229 calendar_schedule_id,
6230 raw_target,
6231 adjusted_target,
6232 scheduled,
6233 other_scheduled,
6234 available_days
6235 )
6236 select
6237 t.staff_id,
6238 t.is_weekend,
6239 t.period_offset,
6240 t.calendar_schedule_id,
6241 sum(t.raw_target) as raw_target,
6242 sum(t.adjusted_target) as adjusted_target,
6243 sum(t.scheduled) as scheduled,
6244 sum(t.other_scheduled) as other_scheduled,
6245 sum(t.available_days) as available_days
6246 from (
6247 select
6248 t.calendar_schedule_id,
6249 t.block_id,
6250 t.staff_id,
6251 td.period_offset,
6252 t.is_weekend,
6253 t.raw_target,
6254 t.target as adjusted_target,
6255 t.scheduled,
6256 t.other_scheduled,
6257 t.available_days
6258 from buffer_target_dates as td
6259 inner join buffer_point_targets_824879560 as t
6260 on td.calendar_schedule_id = t.calendar_schedule_id
6261 and td.block_id = t.block_id
6262 where td.session_id = 824879560
6263 and td.build_point_targets = 1
6264 and td.affected_by_populate = 1
6265 union
6266 select
6267 pt.calendar_schedule_id,
6268 pt.block_id,
6269 pt.staff_id,
6270 td.period_offset,
6271 pt.is_weekend,
6272 pt.raw_target,
6273 pt.target,
6274 pt.scheduled,
6275 pt.other_scheduled,
6276 pt.available_days
6277 from buffer_target_dates as td
6278 inner join point_targets as pt
6279 on td.calendar_schedule_id = pt.calendar_schedule_id
6280 and td.block_id = pt.block_id
6281 where td.session_id = 824879560
6282 and td.build_point_targets = 0
6283 and td.point_targets_source = 'published'
6284 and td.affected_by_populate = 1
6285 union
6286 select
6287 upt.calendar_schedule_id,
6288 upt.block_id,
6289 upt.staff_id,
6290 td.period_offset,
6291 upt.is_weekend,
6292 upt.raw_target,
6293 upt.target,
6294 upt.scheduled,
6295 upt.other_scheduled,
6296 upt.available_days
6297 from buffer_target_dates as td
6298 inner join unpublished_point_targets as upt
6299 on td.calendar_schedule_id = upt.calendar_schedule_id
6300 and td.block_id = upt.block_id
6301 where td.session_id = 824879560
6302 and td.build_point_targets = 0
6303 and td.point_targets_source = 'unpublished'
6304 and td.affected_by_populate = 1
6305 order by null
6306 ) as t
6307 group by
6308 t.staff_id,
6309 t.is_weekend,
6310 t.period_offset,
6311 t.calendar_schedule_id
6312 order by null
6313
6314 (156.6ms) /* CurrentWeeklyPointTargetsRule */
6315 insert into buffer_current_point_targets_824879560 (
6316 staff_id,
6317 is_weekend,
6318 period_offset,
6319 calendar_schedule_id,
6320 raw_target,
6321 adjusted_target,
6322 scheduled,
6323 other_scheduled,
6324 available_days
6325 )
6326 select
6327 t.staff_id,
6328 -1 as is_weekend,
6329 t.period_offset,
6330 t.calendar_schedule_id,
6331 sum(t.raw_target) as raw_target,
6332 sum(t.adjusted_target) as adjusted_target,
6333 sum(t.scheduled) as scheduled,
6334 sum(t.other_scheduled) as other_scheduled,
6335 sum(t.available_days) as available_days
6336 from (
6337 select
6338 t.calendar_schedule_id,
6339 t.block_id,
6340 t.staff_id,
6341 td.period_offset,
6342 t.is_weekend,
6343 t.raw_target,
6344 t.target as adjusted_target,
6345 t.scheduled,
6346 t.other_scheduled,
6347 t.available_days
6348 from
6349 buffer_target_dates as td
6350 inner join buffer_point_targets_824879560 as t
6351 on td.calendar_schedule_id = t.calendar_schedule_id
6352 and td.block_id = t.block_id
6353 where
6354 td.session_id = 824879560
6355 and td.build_point_targets = 1
6356 and td.affected_by_populate = 1
6357 union
6358 select
6359 pt.calendar_schedule_id,
6360 pt.block_id,
6361 pt.staff_id,
6362 td.period_offset,
6363 pt.is_weekend,
6364 pt.raw_target,
6365 pt.target,
6366 pt.scheduled,
6367 pt.other_scheduled,
6368 pt.available_days
6369 from
6370 buffer_target_dates as td
6371 inner join point_targets as pt
6372 on td.calendar_schedule_id = pt.calendar_schedule_id
6373 and td.block_id = pt.block_id
6374 where
6375 td.session_id = 824879560
6376 and td.build_point_targets = 0
6377 and td.point_targets_source = 'published'
6378 and td.affected_by_populate = 1
6379 union
6380 select
6381 upt.calendar_schedule_id,
6382 upt.block_id,
6383 upt.staff_id,
6384 td.period_offset,
6385 upt.is_weekend,
6386 upt.raw_target,
6387 upt.target,
6388 upt.scheduled,
6389 upt.other_scheduled,
6390 upt.available_days
6391 from
6392 buffer_target_dates as td
6393 inner join unpublished_point_targets as upt
6394 on td.calendar_schedule_id = upt.calendar_schedule_id
6395 and td.block_id = upt.block_id
6396 where
6397 td.session_id = 824879560
6398 and td.build_point_targets = 0
6399 and td.point_targets_source = 'unpublished'
6400 and td.affected_by_populate = 1
6401 order by null
6402 ) as t
6403 group by
6404 t.staff_id,
6405 t.period_offset,
6406 t.calendar_schedule_id
6407 order by null
6408
6409 (157.2ms) /* CurrentHourTargetsRule */
6410 insert into buffer_current_hour_targets_824879560 (
6411 staff_id,
6412 is_weekend,
6413 period_offset,
6414 calendar_schedule_id,
6415 raw_target,
6416 adjusted_target,
6417 scheduled,
6418 other_scheduled,
6419 available_days
6420 )
6421 select
6422 t.staff_id,
6423 t.is_weekend,
6424 t.period_offset,
6425 t.calendar_schedule_id,
6426 sum(t.raw_target) as raw_target,
6427 sum(t.adjusted_target) as adjusted_target,
6428 sum(t.scheduled) as scheduled,
6429 sum(t.other_scheduled) as other_scheduled,
6430 sum(t.available_days) as available_days
6431 from (
6432 select
6433 t.calendar_schedule_id,
6434 t.block_id,
6435 t.staff_id,
6436 td.period_offset,
6437 t.is_weekend,
6438 t.raw_target,
6439 t.target as adjusted_target,
6440 t.scheduled,
6441 t.other_scheduled,
6442 t.available_days
6443 from buffer_target_dates as td
6444 inner join buffer_hour_targets_824879560 as t
6445 on td.calendar_schedule_id = t.calendar_schedule_id
6446 and td.block_id = t.block_id
6447 where td.session_id = 824879560
6448 and td.build_hour_targets = 1
6449 and td.affected_by_populate = 1
6450 union
6451 select
6452 ht.calendar_schedule_id,
6453 ht.block_id,
6454 ht.staff_id,
6455 td.period_offset,
6456 ht.is_weekend,
6457 ht.raw_target,
6458 ht.target,
6459 ht.scheduled,
6460 ht.other_scheduled,
6461 ht.available_days
6462 from buffer_target_dates as td
6463 inner join hour_targets as ht
6464 on td.calendar_schedule_id = ht.calendar_schedule_id
6465 and td.block_id = ht.block_id
6466 where td.session_id = 824879560
6467 and td.build_hour_targets = 0
6468 and td.hour_targets_source = 'published'
6469 and td.affected_by_populate = 1
6470 union
6471 select
6472 uht.calendar_schedule_id,
6473 uht.block_id,
6474 uht.staff_id,
6475 td.period_offset,
6476 uht.is_weekend,
6477 uht.raw_target,
6478 uht.target,
6479 uht.scheduled,
6480 uht.other_scheduled,
6481 uht.available_days
6482 from
6483 buffer_target_dates as td
6484 inner join unpublished_hour_targets as uht
6485 on td.calendar_schedule_id = uht.calendar_schedule_id
6486 and td.block_id = uht.block_id
6487 where td.session_id = 824879560
6488 and td.build_hour_targets = 0
6489 and td.hour_targets_source = 'unpublished'
6490 and td.affected_by_populate = 1
6491 order by null
6492 ) as t
6493 group by
6494 t.staff_id,
6495 t.is_weekend,
6496 t.period_offset,
6497 t.calendar_schedule_id
6498 order by null
6499
6500 (156.0ms) /* CurrentWeeklyHourTargetsRule */
6501 insert into buffer_current_hour_targets_824879560 (
6502 staff_id,
6503 is_weekend,
6504 period_offset,
6505 calendar_schedule_id,
6506 raw_target,
6507 adjusted_target,
6508 scheduled,
6509 other_scheduled,
6510 available_days
6511 )
6512 select
6513 t.staff_id,
6514 -1 as is_weekend,
6515 t.period_offset,
6516 t.calendar_schedule_id,
6517 sum(t.raw_target) as raw_target,
6518 sum(t.adjusted_target) as adjusted_target,
6519 sum(t.scheduled) as scheduled,
6520 sum(t.other_scheduled) as other_scheduled,
6521 sum(t.available_days) as available_days
6522 from (
6523 select
6524 t.calendar_schedule_id,
6525 t.block_id,
6526 t.staff_id,
6527 td.period_offset,
6528 t.is_weekend,
6529 t.raw_target,
6530 t.target as adjusted_target,
6531 t.scheduled,
6532 t.other_scheduled,
6533 t.available_days
6534 from
6535 buffer_target_dates as td
6536 inner join buffer_hour_targets_824879560 as t
6537 on td.calendar_schedule_id = t.calendar_schedule_id
6538 and td.block_id = t.block_id
6539 where
6540 td.session_id = 824879560
6541 and td.build_hour_targets = 1
6542 and td.affected_by_populate = 1
6543 union
6544 select
6545 ht.calendar_schedule_id,
6546 ht.block_id,
6547 ht.staff_id,
6548 td.period_offset,
6549 ht.is_weekend,
6550 ht.raw_target,
6551 ht.target,
6552 ht.scheduled,
6553 ht.other_scheduled,
6554 ht.available_days
6555 from
6556 buffer_target_dates as td
6557 inner join hour_targets as ht
6558 on td.calendar_schedule_id = ht.calendar_schedule_id
6559 and td.block_id = ht.block_id
6560 where
6561 td.session_id = 824879560
6562 and td.build_hour_targets = 0
6563 and td.hour_targets_source = 'published'
6564 and td.affected_by_populate = 1
6565 union
6566 select
6567 uht.calendar_schedule_id,
6568 uht.block_id,
6569 uht.staff_id,
6570 td.period_offset,
6571 uht.is_weekend,
6572 uht.raw_target,
6573 uht.target,
6574 uht.scheduled,
6575 uht.other_scheduled,
6576 uht.available_days
6577 from
6578 buffer_target_dates as td
6579 inner join unpublished_hour_targets as uht
6580 on td.calendar_schedule_id = uht.calendar_schedule_id
6581 and td.block_id = uht.block_id
6582 where
6583 td.session_id = 824879560
6584 and td.build_hour_targets = 0
6585 and td.hour_targets_source = 'unpublished'
6586 and td.affected_by_populate = 1
6587 order by null
6588 ) as t
6589 group by
6590 t.staff_id,
6591 t.period_offset,
6592 t.calendar_schedule_id
6593 order by null
6594
6595Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0703 - 1644.5749999999998ms
6596 (155.1ms) /* CurrentCallDaysTargetsRule, CumulativeCallDaysTargetsRule */
6597 insert into buffer_call_days_targets_824879560 (
6598 calendar_schedule_id,
6599 block_id,
6600 staff_id,
6601 assignment_id,
6602 assignment_type,
6603 day_of_week_mask,
6604 is_weekend,
6605 raw_target,
6606 target,
6607 initial_target,
6608 scheduled,
6609 available_days
6610 )
6611 select
6612 cdt.calendar_schedule_id,
6613 cdt.block_id,
6614 cdt.staff_id,
6615 cdt.assignment_id,
6616 cdt.assignment_type,
6617 cdt.day_of_week_mask,
6618 cdt.is_weekend,
6619 cdt.raw_target,
6620 cdt.target,
6621 cdt.initial_target,
6622 cdt.scheduled,
6623 cdt.available_days
6624 from buffer_target_dates as td
6625 inner join call_days_targets as cdt
6626 on td.calendar_schedule_id = cdt.calendar_schedule_id
6627 and td.block_id = cdt.block_id
6628 where td.session_id = 824879560
6629 and td.build_cd_targets = 0
6630 and td.build_ct_targets = 0
6631 and td.build_oa_targets = 0
6632 and td.build_dow_targets = 0
6633 and td.cd_targets_source in ('published', 'both')
6634 and td.affected_by_populate = 1
6635 union
6636 select
6637 ucdt.calendar_schedule_id,
6638 ucdt.block_id,
6639 ucdt.staff_id,
6640 ucdt.assignment_id,
6641 ucdt.assignment_type,
6642 ucdt.day_of_week_mask,
6643 ucdt.is_weekend,
6644 ucdt.raw_target,
6645 ucdt.target,
6646 ucdt.initial_target,
6647 ucdt.scheduled,
6648 ucdt.available_days
6649 from buffer_target_dates as td
6650 inner join unpublished_call_days_targets as ucdt
6651 on td.calendar_schedule_id = ucdt.calendar_schedule_id
6652 and td.block_id = ucdt.block_id
6653 where td.session_id = 824879560
6654 and td.build_cd_targets = 0
6655 and td.build_ct_targets = 0
6656 and td.build_oa_targets = 0
6657 and td.build_dow_targets = 0
6658 and td.cd_targets_source in ('unpublished', 'both')
6659 and td.affected_by_populate = 1
6660 order by null
6661
6662 (154.1ms) /* CurrentCallDaysTargetsRule, CumulativeCallDaysTargetsRule */
6663 update buffer_call_days_targets_824879560 as cdt
6664 inner join (
6665 select
6666 cdt.block_id,
6667 cdt.calendar_schedule_id,
6668 cdt.staff_id,
6669 cdt.assignment_id,
6670 cdt.assignment_type,
6671 cdt.day_of_week_mask,
6672 sum(tad.adjustment_value) as adjustment_value
6673 from buffer_call_days_targets_824879560 as cdt
6674 inner join target_adjustment_details as tad
6675 on cdt.block_id = tad.block_id
6676 and cdt.calendar_schedule_id = tad.calendar_schedule_id
6677 and cdt.staff_id = tad.staff_id
6678 and cdt.assignment_id = tad.assignment_id
6679 and cdt.assignment_type = tad.assignment_type
6680 and cdt.day_of_week_mask = tad.day_of_week_mask
6681 group by
6682 cdt.block_id,
6683 cdt.calendar_schedule_id,
6684 cdt.staff_id,
6685 cdt.assignment_id,
6686 cdt.assignment_type,
6687 cdt.day_of_week_mask
6688 order by null
6689 ) as cdta
6690 on cdt.block_id = cdta.block_id
6691 and cdt.calendar_schedule_id = cdta.calendar_schedule_id
6692 and cdt.staff_id = cdta.staff_id
6693 and cdt.assignment_id = cdta.assignment_id
6694 and cdt.assignment_type = cdta.assignment_type
6695 and cdt.day_of_week_mask = cdta.day_of_week_mask
6696 set cdt.scheduled = cdt.scheduled + cdta.adjustment_value
6697
6698 (153.0ms) /* MonthlyCallMixRule, CurrentWeeklyCallTypeTargetsRule, AnnualCallMixRule, CumulativeWeeklyCallTypeTargetsRule */
6699 insert into buffer_call_type_targets_824879560 (
6700 calendar_schedule_id,
6701 block_id,
6702 staff_id,
6703 assignment_id,
6704 assignment_type,
6705 is_weekend,
6706 raw_target,
6707 target,
6708 scheduled,
6709 available_days,
6710 initial_target
6711 )
6712 select
6713 ctt.calendar_schedule_id,
6714 ctt.block_id,
6715 ctt.staff_id,
6716 ctt.assignment_id,
6717 ctt.assignment_type,
6718 ctt.is_weekend,
6719 ctt.raw_target,
6720 ctt.target,
6721 ctt.scheduled,
6722 ctt.available_days,
6723 ctt.initial_target
6724 from buffer_target_dates as td
6725 inner join call_type_targets as ctt
6726 on td.calendar_schedule_id = ctt.calendar_schedule_id
6727 and td.block_id = ctt.block_id
6728 where td.session_id = 824879560
6729 and td.build_ct_targets = 0
6730 and td.ct_targets_source in ('published', 'both')
6731 and td.affected_by_populate = 1
6732 union
6733 select
6734 uctt.calendar_schedule_id,
6735 uctt.block_id,
6736 uctt.staff_id,
6737 uctt.assignment_id,
6738 uctt.assignment_type,
6739 uctt.is_weekend,
6740 uctt.raw_target,
6741 uctt.target,
6742 uctt.scheduled,
6743 uctt.available_days,
6744 uctt.initial_target
6745 from buffer_target_dates as td
6746 inner join unpublished_call_type_targets as uctt
6747 on td.calendar_schedule_id = uctt.calendar_schedule_id
6748 and td.block_id = uctt.block_id
6749 where td.session_id = 824879560
6750 and td.build_ct_targets = 0
6751 and td.ct_targets_source in ('unpublished', 'both')
6752 and td.affected_by_populate = 1
6753 order by null
6754
6755 (153.5ms) update
6756 buffer_call_type_targets_824879560 as ctt
6757 inner join (
6758 select
6759 ctt.block_id,
6760 ctt.calendar_schedule_id,
6761 ctt.staff_id,
6762 ctt.assignment_id,
6763 ctt.assignment_type,
6764 ctt.is_weekend,
6765 sum(tad.adjustment_value) as adjustment_value
6766 from buffer_call_type_targets_824879560 as ctt
6767 inner join target_adjustment_details as tad
6768 on ctt.block_id = tad.block_id
6769 and ctt.calendar_schedule_id = tad.calendar_schedule_id
6770 and ctt.staff_id = tad.staff_id
6771 and ctt.assignment_id = tad.assignment_id
6772 and ctt.assignment_type = tad.assignment_type
6773 and ctt.is_weekend = tad.is_weekend
6774 group by
6775 ctt.block_id,
6776 ctt.calendar_schedule_id,
6777 ctt.staff_id,
6778 ctt.assignment_id,
6779 ctt.assignment_type,
6780 ctt.is_weekend
6781 order by null
6782 ) as ctta
6783 on ctt.block_id = ctta.block_id
6784 and ctt.calendar_schedule_id = ctta.calendar_schedule_id
6785 and ctt.staff_id = ctta.staff_id
6786 and ctt.assignment_id = ctta.assignment_id
6787 and ctt.assignment_type = ctta.assignment_type
6788 and ctt.is_weekend = ctta.is_weekend
6789 set ctt.scheduled = ctt.scheduled + ctta.adjustment_value
6790
6791 (153.1ms) /* StaffCapacityRule, CurrentWeeklyOverallTargetsRule, AnnualTargetsRule, CumulativeWeeklyOverallTargetsRule */
6792 insert into buffer_targets_824879560 (
6793 calendar_schedule_id,
6794 block_id,
6795 staff_id,
6796 is_weekend,
6797 raw_target,
6798 target,
6799 scheduled,
6800 available_days
6801 )
6802 select
6803 t.calendar_schedule_id,
6804 t.block_id,
6805 t.staff_id,
6806 t.is_weekend,
6807 t.raw_target,
6808 t.target,
6809 t.scheduled,
6810 t.days_with_availability as available_days
6811 from buffer_target_dates as td
6812 inner join targets as t
6813 on td.calendar_schedule_id = t.calendar_schedule_id
6814 and td.block_id = t.block_id
6815 where td.session_id = 824879560
6816 and td.build_oa_targets = 0
6817 and td.oa_targets_source = 'published'
6818 and td.affected_by_populate = 1
6819 union
6820 select
6821 ut.calendar_schedule_id,
6822 ut.block_id,
6823 ut.staff_id,
6824 ut.is_weekend,
6825 ut.raw_target,
6826 ut.target,
6827 ut.scheduled,
6828 ut.available_days
6829 from buffer_target_dates as td
6830 inner join unpublished_targets as ut
6831 on td.calendar_schedule_id = ut.calendar_schedule_id
6832 and td.block_id = ut.block_id
6833 where td.session_id = 824879560
6834 and td.build_oa_targets = 0
6835 and td.oa_targets_source = 'unpublished'
6836 and td.affected_by_populate = 1
6837 order by null
6838
6839 (153.1ms) /* StaffCapacityRule, CurrentWeeklyOverallTargetsRule, AnnualTargetsRule, CumulativeWeeklyOverallTargetsRule */
6840 update buffer_targets_824879560 as t
6841 inner join (
6842 select
6843 t.block_id,
6844 t.calendar_schedule_id,
6845 t.staff_id,
6846 t.is_weekend,
6847 sum(tad.adjustment_value) as adjustment_value
6848 from buffer_targets_824879560 as t
6849 inner join target_adjustment_details as tad
6850 on t.block_id = tad.block_id
6851 and t.calendar_schedule_id = tad.calendar_schedule_id
6852 and t.staff_id = tad.staff_id
6853 and t.is_weekend = tad.is_weekend
6854 group by
6855 t.block_id,
6856 t.calendar_schedule_id,
6857 t.staff_id,
6858 t.is_weekend
6859 order by null
6860 ) as ta
6861 on t.block_id = ta.block_id
6862 and t.calendar_schedule_id = ta.calendar_schedule_id
6863 and t.staff_id = ta.staff_id
6864 and t.is_weekend = ta.is_weekend
6865 set t.scheduled = t.scheduled + ta.adjustment_value
6866
6867 (162.6ms) /* MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule */
6868 insert into buffer_day_of_week_targets_824879560 (
6869 calendar_schedule_id,
6870 block_id,
6871 staff_id,
6872 wday,
6873 raw_target,
6874 target,
6875 scheduled,
6876 available_days
6877 )
6878 select
6879 dowt.calendar_schedule_id,
6880 dowt.block_id,
6881 dowt.staff_id,
6882 dowt.wday,
6883 dowt.raw_target,
6884 dowt.target,
6885 dowt.scheduled,
6886 dowt.available_days
6887 from buffer_target_dates as td
6888 inner join day_of_week_targets as dowt
6889 on td.calendar_schedule_id = dowt.calendar_schedule_id
6890 and td.block_id = dowt.block_id
6891 where td.session_id = 824879560
6892 and td.build_dow_targets = 0
6893 and td.dow_targets_source = 'published'
6894 and td.affected_by_populate = 1
6895 union
6896 select
6897 udowt.calendar_schedule_id,
6898 udowt.block_id,
6899 udowt.staff_id,
6900 udowt.wday,
6901 udowt.raw_target,
6902 udowt.target,
6903 udowt.scheduled,
6904 udowt.available_days
6905 from buffer_target_dates as td
6906 inner join unpublished_day_of_week_targets as udowt
6907 on td.calendar_schedule_id = udowt.calendar_schedule_id
6908 and td.block_id = udowt.block_id
6909 where td.session_id = 824879560
6910 and td.build_dow_targets = 0
6911 and td.dow_targets_source = 'unpublished'
6912 and td.affected_by_populate = 1
6913 order by null
6914
6915 (153.8ms) /* MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule */
6916 update buffer_day_of_week_targets_824879560 as dowt
6917 inner join (
6918 select
6919 dowt.block_id,
6920 dowt.calendar_schedule_id,
6921 dowt.staff_id,
6922 dowt.wday,
6923 sum(tad.adjustment_value) as adjustment_value
6924 from
6925 buffer_day_of_week_targets_824879560 as dowt
6926 inner join target_adjustment_details as tad
6927 on dowt.block_id = tad.block_id
6928 and dowt.calendar_schedule_id = tad.calendar_schedule_id
6929 and dowt.staff_id = tad.staff_id
6930 and dowt.wday = log2(tad.day_of_week_mask)
6931 group by
6932 dowt.block_id,
6933 dowt.calendar_schedule_id,
6934 dowt.staff_id,
6935 dowt.wday
6936 order by null
6937 ) as dowta
6938 on dowt.block_id = dowta.block_id
6939 and dowt.calendar_schedule_id = dowta.calendar_schedule_id
6940 and dowt.staff_id = dowta.staff_id
6941 and dowt.wday = dowta.wday
6942 set dowt.scheduled = dowt.scheduled + dowta.adjustment_value
6943
6944 (153.8ms) /* CurrentPointTargetsRule, CurrentWeeklyPointTargetsRule, CumulativePointTargetsRule, CumulativeWeeklyPointTargetsRule */
6945 insert into buffer_point_targets_824879560 (
6946 calendar_schedule_id,
6947 block_id,
6948 staff_id,
6949 is_weekend,
6950 raw_target,
6951 target,
6952 scheduled,
6953 other_scheduled,
6954 available_days,
6955 initial_target
6956 )
6957 select
6958 pt.calendar_schedule_id,
6959 pt.block_id,
6960 pt.staff_id,
6961 pt.is_weekend,
6962 pt.raw_target,
6963 pt.target,
6964 pt.scheduled,
6965 pt.other_scheduled,
6966 pt.available_days,
6967 pt.initial_target
6968 from buffer_target_dates as td
6969 inner join point_targets as pt
6970 on td.calendar_schedule_id = pt.calendar_schedule_id
6971 and td.block_id = pt.block_id
6972 where td.session_id = 824879560
6973 and td.build_point_targets = 0
6974 and td.point_targets_source = 'published'
6975 and td.affected_by_populate = 1
6976 union
6977 select
6978 upt.calendar_schedule_id,
6979 upt.block_id,
6980 upt.staff_id,
6981 upt.is_weekend,
6982 upt.raw_target,
6983 upt.target,
6984 upt.scheduled,
6985 upt.other_scheduled,
6986 upt.available_days,
6987 upt.initial_target
6988 from buffer_target_dates as td
6989 inner join unpublished_point_targets as upt
6990 on td.calendar_schedule_id = upt.calendar_schedule_id
6991 and td.block_id = upt.block_id
6992 where td.session_id = 824879560
6993 and td.build_point_targets = 0
6994 and td.point_targets_source = 'unpublished'
6995 and td.affected_by_populate = 1
6996 order by null
6997
6998 (153.0ms) /* CurrentHourTargetsRule, CurrentWeeklyHourTargetsRule, CumulativeHourTargetsRule, CumulativeWeeklyHourTargetsRule */
6999 insert into buffer_hour_targets_824879560 (
7000 calendar_schedule_id,
7001 block_id,
7002 staff_id,
7003 is_weekend,
7004 raw_target,
7005 target,
7006 scheduled,
7007 other_scheduled,
7008 available_days,
7009 initial_target
7010 )
7011 select
7012 ht.calendar_schedule_id,
7013 ht.block_id,
7014 ht.staff_id,
7015 ht.is_weekend,
7016 ht.raw_target,
7017 ht.target,
7018 ht.scheduled,
7019 ht.other_scheduled,
7020 ht.available_days,
7021 ht.initial_target
7022 from buffer_target_dates as td
7023 inner join hour_targets as ht
7024 on td.calendar_schedule_id = ht.calendar_schedule_id
7025 and td.block_id = ht.block_id
7026 where td.session_id = 824879560
7027 and td.build_hour_targets = 0
7028 and td.hour_targets_source = 'published'
7029 and td.affected_by_populate = 1
7030 union
7031 select
7032 uht.calendar_schedule_id,
7033 uht.block_id,
7034 uht.staff_id,
7035 uht.is_weekend,
7036 uht.raw_target,
7037 uht.target,
7038 uht.scheduled,
7039 uht.other_scheduled,
7040 uht.available_days,
7041 uht.initial_target
7042 from buffer_target_dates as td
7043 inner join unpublished_hour_targets as uht
7044 on td.calendar_schedule_id = uht.calendar_schedule_id
7045 and td.block_id = uht.block_id
7046 where td.session_id = 824879560
7047 and td.build_hour_targets = 0
7048 and td.hour_targets_source = 'unpublished'
7049 and td.affected_by_populate = 1
7050 order by null
7051
7052Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets07Reports - 1552.478ms
7053INFO : (04-03 14:41:21) --> fill: 7 - Scheduler::AutoPopulate::Queries::Query013
7054 (187.9ms) insert into buffer_counter_increments_824879560 (
7055 schedule_id,
7056 calls,
7057 points,
7058 hours,
7059 affects_cumulative_targets
7060 )
7061 select
7062 sc.id as schedule_id,
7063 case
7064 when (ct.included_in_targets > 0) then 1
7065 else 0
7066 end as calls,
7067 coalesce(
7068 case
7069 when (hl.observed_date is null or dp.point is not null) then dp.point
7070 else dp_2.point
7071 end,
7072 0.0
7073 ) as points,
7074 ct.hours,
7075 case
7076 when (b.display_order between (t1.timeframe_ending - (4 /* cumulative targets period */ - 1)) and t1.timeframe_ending) then 1
7077 else 0
7078 end as affects_cumulative_targets
7079 from
7080 buffer_schedules_824879560 as sc
7081 inner join (
7082 select
7083 id,
7084 included_in_targets,
7085 coalesce(
7086 timestampdiff(
7087 minute,
7088 concat('1900-01-01 ', maketime(start_time_hour, start_time_minute, 0)),
7089 concat(
7090 '1900-01-0',
7091 case
7092 when ((
7093 start_time_hour | start_time_minute | end_time_hour | end_time_minute > 0
7094 )
7095 and (
7096 timediff(
7097 maketime(end_time_hour, end_time_minute, 0),
7098 maketime(start_time_hour, start_time_minute, 0)
7099 ) <= 0
7100 )
7101 ) then '2'
7102 else '1'
7103 end,
7104 ' ',
7105 maketime(end_time_hour, end_time_minute, 0)
7106 )
7107 ) / 60,
7108 0.0
7109 ) as hours
7110 from call_types
7111 where
7112 client_id = 6
7113 and active = 1
7114 order by null
7115 ) as ct
7116 on sc.call_type_id = ct.id
7117 inner join blocks as b
7118 on sc.block_id = b.id
7119 inner join (
7120 select
7121 calendar_schedule_id,
7122 max(
7123 case
7124 when (should_be_populated = 1) then end_block_display_order
7125 else null
7126 end
7127 ) as timeframe_ending
7128 from buffer_periods_824879560
7129 group by calendar_schedule_id
7130 order by null
7131 ) as t1
7132 on sc.calendar_schedule_id = t1.calendar_schedule_id
7133 left join (
7134 select
7135 hd.observed_date,
7136 case
7137 when (hd.observed_date > hd.extended_date) then hd.extended_date
7138 else hd.observed_date
7139 end as date_from,
7140 case
7141 when (hd.observed_date < hd.extended_date) then hd.extended_date
7142 else hd.observed_date
7143 end as date_to
7144 from
7145 holidays as h
7146 inner join holiday_dates as hd
7147 on h.id = hd.holiday_id
7148 inner join (
7149 select
7150 year(min(schedule_on)) as year_from,
7151 year(max(schedule_on)) as year_to
7152 from buffer_schedules/* session_id */
7153 where should_be_evaluated = 1
7154 ) as y
7155 on hd.year between y.year_from and y.year_to
7156 where
7157 h.client_id = 6
7158 and (
7159 h.observed = 1
7160 or h.extended = 1
7161 )
7162 order by null
7163 ) as hl
7164 on sc.schedule_on between hl.date_from and hl.date_to
7165 left join assignment_annotations as aa
7166 on ct.id = aa.assignmentable_id
7167 and aa.assignmentable_type = 'CallType'
7168 and aa.annotation_id = 0 /* annotation = "None" */
7169 and aa.applicable = 1
7170 left join assignment_annotation_daily_points as dp
7171 on aa.id = dp.assignment_annotation_id
7172 and case
7173 when (hl.observed_date is null) then (dayofweek(sc.schedule_on) - 1)
7174 when (sc.schedule_on = hl.observed_date) then 7
7175 else 8
7176 end = dp.day
7177 left join assignment_annotation_daily_points as dp_2
7178 on aa.id = dp_2.assignment_annotation_id
7179 and (dayofweek(sc.schedule_on) - 1) = dp_2.day
7180 where sc.should_be_evaluated = 1
7181 order by null
7182
7183INFO : (04-03 14:41:21) --> fill: 8 - Scheduler::AutoPopulate::Queries::Query014
7184 (153.6ms) -- Prepare the information about the blocks we're populating and the linkage patterns which will be used on those blocks
7185 insert into buffer_linkage_patterns_824879560 (
7186 period_offset,
7187 calendar_schedule_id,
7188 block_id,
7189 block_start_date,
7190 block_start_dow,
7191 block_length,
7192 linkage_pattern_id,
7193 pattern_start_dow,
7194 days_before_start,
7195 pattern_length,
7196 start_offset,
7197 iterations_count
7198 )
7199 select
7200 b1.period_offset,
7201 b1.calendar_schedule_id,
7202 b1.block_id,
7203 b2.start_date as block_start_date,
7204 dayofweek(b2.start_date) as block_start_dow,
7205 (datediff(b2.end_date, b2.start_date) + 1) as block_length,
7206 lp.id as linkage_pattern_id,
7207 (lp.start_on + 1) as pattern_start_dow,
7208 lp.days_before_start,
7209 (lp.length * 7) as pattern_length,
7210 null as start_offset,
7211 null as iterations_count
7212 from (
7213 select
7214 calendar_schedule_id,
7215 block_id,
7216 period_offset
7217 from buffer_schedules_824879560
7218 group by
7219 calendar_schedule_id,
7220 block_id,
7221 period_offset
7222 order by null
7223 ) as b1
7224 inner join blocks as b2
7225 on b1.block_id = b2.id
7226 inner join linkage_patterns as lp
7227 on lp.client_id = 6
7228 and b1.calendar_schedule_id = lp.calendar_schedule_id
7229 order by null
7230
7231 (155.2ms) -- Calculate the basic offset ("+" or "-") that will be applied to a linkage pattern if a block and a pattern are starting on different day of week
7232 update buffer_linkage_patterns_824879560
7233 set start_offset = if(
7234 (pattern_start_dow + (case when (pattern_start_dow < block_start_dow) then 7 else 0 end) - block_start_dow) <= days_before_start,
7235 (pattern_start_dow + (case when (pattern_start_dow < block_start_dow) then 7 else 0 end) - block_start_dow),
7236 (block_start_dow + (case when (block_start_dow < pattern_start_dow) then 7 else 0 end) - pattern_start_dow) * (-1)
7237 )
7238
7239 (155.2ms) -- In some cases (when a block and a pattern are starting on different day of week or when a pattern is shorter than a block)
7240 -- a pattern should be repeated couple of times (in order to cover the entire block)
7241 update buffer_linkage_patterns_824879560
7242 set iterations_count =
7243 ceiling(
7244 (
7245 block_length +
7246 case
7247 when (start_offset < 0) then abs(start_offset)
7248 else 0
7249 end
7250 ) * 1.0 / pattern_length
7251 )
7252
7253 (163.6ms) -- Generate an assignments sequence for every linkage pattern
7254 insert into buffer_schedules_linkage_patterns_824879560 (
7255 call_type_id,
7256 staff_id,
7257 schedule_on,
7258 period_offset,
7259 day_of_week_mask,
7260 display_order,
7261 week_number,
7262 should_be_evaluated,
7263 should_be_populated,
7264 linkage_instance_id,
7265 block_id,
7266 calendar_schedule_id
7267 )
7268 select
7269 lps.assignment_id as call_type_id,
7270 null as staff_id,
7271 case
7272 when (lp.start_offset < 0)
7273 then date_add(lp.block_start_date, interval (lp.start_offset + ns.item_number * lp.pattern_length + lps.offset) day)
7274 else
7275 date_add(lp.block_start_date, interval ((lp.start_offset + ns.item_number * lp.pattern_length + lps.offset) mod lp.block_length) day)
7276 end as schedule_on,
7277 lp.period_offset,
7278 null as day_of_week_mask,
7279 null as display_order,
7280 null as week_number,
7281 0 as should_be_evaluated,
7282 0 as should_be_populated,
7283 lp.linkage_pattern_id as linkage_instance_id,
7284 lp.block_id,
7285 lp.calendar_schedule_id
7286 from
7287 numeric_sequence as ns
7288 inner join buffer_linkage_patterns_824879560 as lp
7289 on ns.item_number <= (lp.iterations_count - 1)
7290 inner join linkage_pattern_slots as lps
7291 on lp.linkage_pattern_id = lps.linkage_pattern_id
7292 and lps.assignment_type = 'CallType'
7293 where
7294 case
7295 when (lp.start_offset < 0)
7296 then (lp.start_offset + ns.item_number * lp.pattern_length + lps.offset)
7297 else
7298 (ns.item_number * lp.pattern_length + lps.offset)
7299 end between 0 and (lp.block_length - 1)
7300 order by null
7301
7302 (154.1ms) -- Fill the columns that we left blank in the previous "INSERT"
7303 update
7304 buffer_schedules_linkage_patterns_824879560 as slp
7305 inner join clients as cl
7306 on cl.id = 6
7307 inner join call_types as ct
7308 on slp.call_type_id = ct.id
7309 left join buffer_schedules_824879560 as bs
7310 on slp.schedule_on = bs.schedule_on
7311 and slp.call_type_id = bs.call_type_id
7312 set
7313 slp.day_of_week_mask = (1 << (dayofweek(slp.schedule_on) - 1)),
7314 slp.display_order = ct.display_order,
7315 slp.week_number =
7316 yearweek(
7317 slp.schedule_on,
7318 case
7319 when (cl.start_of_week = 0) then 2
7320 else 7
7321 end
7322 ),
7323 slp.should_be_evaluated = coalesce(bs.should_be_evaluated, 0),
7324 slp.should_be_populated = coalesce(bs.should_be_populated, 0);
7325
7326 (152.9ms) -- Delete linkage patterns that don't have intersection with assignments we should auto-populate
7327 delete slp_1
7328 from
7329 buffer_schedules_linkage_patterns_824879560 as slp_1
7330 inner join (
7331 select linkage_instance_id
7332 from buffer_schedules_linkage_patterns_824879560
7333 group by linkage_instance_id
7334 having
7335 max(should_be_evaluated) = 0
7336 and max(should_be_populated) = 0
7337 order by null
7338 ) as slp_2
7339 on slp_1.linkage_instance_id = slp_2.linkage_instance_id
7340
7341 (153.0ms) -- Use a linkage pattern ID instead of linkage instance ID for those assignments that intersect with linkage patterns
7342 update
7343 buffer_schedules_linkage_patterns_824879560 as slp
7344 inner join buffer_schedules_824879560 as bs_1
7345 on slp.schedule_on = bs_1.schedule_on
7346 and slp.call_type_id = bs_1.call_type_id
7347 inner join buffer_schedules_824879560 as bs_2
7348 on bs_1.linkage_instance_id = bs_2.linkage_instance_id
7349 set bs_2.linkage_instance_id = slp.linkage_instance_id
7350
7351 (152.7ms) -- Linkage pattern slots that don't have intersection with auto-populate assignments but are a part of a pattern that has such intersection
7352 -- should be copied over to the buffer schedules table (used during the auto-populate process)
7353 insert into buffer_schedules_824879560 (
7354 call_type_id,
7355 staff_id,
7356 schedule_on,
7357 period_offset,
7358 day_of_week_mask,
7359 is_weekend,
7360 display_order,
7361 week_number,
7362 should_be_evaluated,
7363 should_be_populated,
7364 linkage_instance_id,
7365 block_id,
7366 calendar_schedule_id
7367 )
7368 select
7369 call_type_id,
7370 staff_id,
7371 schedule_on,
7372 period_offset,
7373 day_of_week_mask,
7374 case
7375 when (day_of_week_mask & 62 > 0) then 0
7376 else 1
7377 end as is_weekend,
7378 display_order,
7379 week_number,
7380 should_be_evaluated,
7381 should_be_populated,
7382 linkage_instance_id,
7383 block_id,
7384 calendar_schedule_id
7385 from buffer_schedules_linkage_patterns_824879560
7386 where
7387 should_be_evaluated = 0
7388 and should_be_populated = 0
7389
7390INFO : (04-03 14:41:22) --> fill: 9 - Scheduler::AutoPopulate::Queries::Query015
7391 (160.2ms) insert into buffer_schedules_824879560 (
7392 call_type_id,
7393 staff_id,
7394 schedule_on,
7395 day_of_week_mask,
7396 is_weekend,
7397 display_order,
7398 should_be_evaluated,
7399 should_be_populated,
7400 linkage_instance_id
7401 )
7402 select distinct
7403 schedules_call_overlap.call_type_id,
7404 schedules_call_overlap.staff_id,
7405 schedules_call_overlap.schedule_on,
7406 (1 << (dayofweek(schedules_call_overlap.schedule_on) - 1)) as day_of_week_mask,
7407 case
7408 when (dayofweek(schedules_call_overlap.schedule_on) between 2 and 6) then 0
7409 else 1
7410 end as is_weekend,
7411 call_types.display_order,
7412 0 as should_be_evaluated,
7413 0 as should_be_populated,
7414 -1 as linkage_instance_id
7415 from (
7416 select schedule_on
7417 from buffer_schedules_824879560
7418 where should_be_evaluated = 1
7419 group by schedule_on
7420 order by null
7421 ) as buffer_schedules_1
7422 inner join schedules as schedules_call_overlap
7423 on schedules_call_overlap.client_id = 6
7424 and buffer_schedules_1.schedule_on = schedules_call_overlap.schedule_on
7425 left join buffer_schedules_824879560 as buffer_schedules_2
7426 on schedules_call_overlap.schedule_on = buffer_schedules_2.schedule_on
7427 and schedules_call_overlap.call_type_id = buffer_schedules_2.call_type_id
7428 inner join call_types
7429 on schedules_call_overlap.call_type_id = call_types.id
7430 where buffer_schedules_2.id is null
7431 order by null
7432
7433INFO : (04-03 14:41:22) --> fill: 10 - Scheduler::AutoPopulate::Queries::Query02
7434INFO : (04-03 14:41:22) --> fill: 11 - Scheduler::AutoPopulate::Queries::Query03
7435INFO : (04-03 14:41:22) --> fill: 12 - Scheduler::AutoPopulate::Queries::Query04
7436INFO : (04-03 14:41:22) --> fill: 13 - Scheduler::AutoPopulate::Queries::Query045
7437INFO : (04-03 14:41:22) --> fill: 14 - Scheduler::AutoPopulate::Queries::QueryA
7438 (161.4ms) insert into buffer_schedules_824879560 (
7439 call_type_id,
7440 staff_id,
7441 schedule_on,
7442 day_of_week_mask,
7443 is_weekend,
7444 display_order,
7445 should_be_evaluated,
7446 should_be_populated,
7447 linkage_instance_id
7448 )
7449 select distinct straight_join
7450 schedules.call_type_id,
7451 schedules.staff_id,
7452 schedules.schedule_on,
7453 (1 << (dayofweek(schedules.schedule_on) - 1)) as day_of_week_mask,
7454 case
7455 when (dayofweek(schedules.schedule_on) between 2 and 6) then 0
7456 else 1
7457 end as is_weekend,
7458 call_types.display_order,
7459 0 as should_be_evaluated,
7460 0 as should_be_populated,
7461 -1 as linkage_instance_id
7462 from
7463 buffer_schedules_824879560 as buffer_schedules_1
7464 inner join negative_links_influences use index (ix_unique_links)
7465 on buffer_schedules_1.day_of_week_mask = negative_links_influences.day_of_week_mask
7466 and buffer_schedules_1.call_type_id = negative_links_influences.source_id
7467 and negative_links_influences.source_type = 'CallType'
7468 and negative_links_influences.target_type = 'CallType'
7469 inner join schedules use index (ix_schedules_call_date)
7470 on date_add(
7471 buffer_schedules_1.schedule_on,
7472 interval negative_links_influences.offset day
7473 ) = schedules.schedule_on
7474 and negative_links_influences.target_id = schedules.call_type_id
7475 left join buffer_schedules_824879560 as buffer_schedules_2 use index (ix_buffer_schedules_composite_1)
7476 on schedules.schedule_on = buffer_schedules_2.schedule_on
7477 and schedules.call_type_id = buffer_schedules_2.call_type_id
7478 inner join call_types
7479 on schedules.call_type_id = call_types.id
7480 where
7481 buffer_schedules_1.linkage_instance_id >= 0
7482 and buffer_schedules_1.should_be_evaluated = 1
7483 and buffer_schedules_2.id is null
7484 order by null
7485
7486INFO : (04-03 14:41:22) --> fill: 15 - Scheduler::AutoPopulate::Queries::QueryB
7487 (155.2ms) insert into buffer_schedules_824879560 (
7488 call_type_id,
7489 staff_id,
7490 schedule_on,
7491 day_of_week_mask,
7492 is_weekend,
7493 display_order,
7494 should_be_evaluated,
7495 should_be_populated,
7496 linkage_instance_id
7497 )
7498 select distinct straight_join
7499 0 as call_type_id,
7500 vacations.staff_id,
7501 vacations.schedule_on,
7502 (1 << (dayofweek(vacations.schedule_on) - 1)) as day_of_week_mask,
7503 vacations.weekend_on as is_weekend,
7504 -1 as display_order,
7505 0 as should_be_evaluated,
7506 0 as should_be_populated,
7507 -1 as linkage_instance_id
7508 from
7509 buffer_schedules_824879560 as buffer_schedules_1
7510 inner join negative_links_influences use index (ix_unique_links)
7511 on buffer_schedules_1.day_of_week_mask = negative_links_influences.day_of_week_mask
7512 and buffer_schedules_1.call_type_id = negative_links_influences.source_id
7513 and negative_links_influences.source_type = 'CallType'
7514 and negative_links_influences.target_id is null
7515 and negative_links_influences.target_type in ('Vacation', 'NonClinicalType')
7516 inner join vacations use index (ix_vacations_on_schedule_and_client)
7517 on vacations.client_id = 6 /* client_id */
7518 and date_add(
7519 buffer_schedules_1.schedule_on,
7520 interval negative_links_influences.offset day
7521 ) = vacations.schedule_on
7522 and negative_links_influences.target_id = vacations.non_clinical_type_id
7523 and vacations.status in (3) /* based on the "non-working requests" settings */
7524 left join buffer_schedules_824879560 as buffer_schedules_2 use index (ix_buffer_schedules_composite_1)
7525 on vacations.staff_id = buffer_schedules_2.staff_id
7526 and vacations.schedule_on = buffer_schedules_2.schedule_on
7527 and (-1 * negative_links_influences.target_id) = buffer_schedules_2.call_type_id
7528 where
7529 buffer_schedules_1.linkage_instance_id >= 0
7530 and buffer_schedules_1.should_be_evaluated = 1
7531 and buffer_schedules_2.id is null
7532 order by null
7533
7534INFO : (04-03 14:41:23) --> fill: 16 - Scheduler::AutoPopulate::Queries::Query05
7535 (156.8ms) insert into buffer_linkages_824879560 (
7536 linkage_instance_id,
7537 slots_count_total,
7538 has_conflicts
7539 )
7540 select straight_join
7541 schedules.linkage_instance_id,
7542 count(1) as slots_count_total,
7543 if(linkage_conflicts.linkage_template_id is not null, 1, 0) as has_conflicts
7544 from
7545 buffer_schedules_824879560 as schedules
7546 left join (
7547 select straight_join
7548 linkage_relations.linkage_template_id
7549 from linkage_relations
7550 inner join negative_links_influences use index (ix_unique_links)
7551 on linkage_relations.day_of_week_mask = negative_links_influences.day_of_week_mask
7552 and linkage_relations.call_type_id = negative_links_influences.source_id
7553 and negative_links_influences.source_type = 'CallType'
7554 and linkage_relations.linked_call_type_id = negative_links_influences.target_id
7555 and negative_links_influences.target_type = 'CallType'
7556 and linkage_relations.distance_in_days = negative_links_influences.offset
7557 where linkage_relations.client_id = 6 /* client_id */
7558 and (
7559 linkage_relations.call_type_id != linkage_relations.linked_call_type_id
7560 or linkage_relations.distance_in_days != 0
7561 )
7562 group by linkage_relations.linkage_template_id
7563 order by null
7564 ) as linkage_conflicts
7565 on (schedules.linkage_instance_id div 1000000) = linkage_conflicts.linkage_template_id
7566 where schedules.linkage_instance_id >= 0
7567 group by
7568 schedules.linkage_instance_id,
7569 has_conflicts
7570 order by null
7571
7572INFO : (04-03 14:41:23) --> fill: 17 - Scheduler::AutoPopulate::Queries::Query06
7573 (157.2ms) insert into buffer_target_assignments_824879560 (
7574 call_type_id,
7575 target_group_id,
7576 assignment_id,
7577 assignment_type
7578 )
7579 select
7580 t1.call_type_id,
7581 ifnull(tg.id, 0) as target_group_id,
7582 if(tg.id is null, t1.call_type_id, tg.id) as assignment_id,
7583 if(tg.id is null, 'CallType', 'TargetGroup') as assignment_type
7584 from (
7585 select ct.id as call_type_id
7586 from
7587 buffer_schedules_824879560 as sc
7588 inner join call_types as ct
7589 on sc.call_type_id = ct.id
7590 and ct.active = 1
7591 and ct.included_in_targets > 0
7592 where linkage_instance_id >= 0
7593 group by ct.id
7594 order by null
7595 ) as t1
7596 left join target_group_calls as tgc
7597 on t1.call_type_id = tgc.call_type_id
7598 left join target_groups as tg
7599 on tgc.target_group_id = tg.id
7600 and tg.active = 1
7601 order by null
7602
7603INFO : (04-03 14:41:23) --> fill: 18 - Scheduler::AutoPopulate::Queries::Query07
7604 (155.9ms) insert into buffer_linkage_targets_824879560 (
7605 linkage_instance_id,
7606 is_weekend,
7607 period_offset,
7608 calendar_schedule_id,
7609 scheduled
7610 )
7611 select
7612 s.linkage_instance_id,
7613 s.is_weekend,
7614 s.period_offset,
7615 s.calendar_schedule_id,
7616 sum(ci.calls) as _scheduled
7617 from
7618 buffer_schedules_824879560 as s
7619 inner join buffer_counter_increments_824879560 as ci
7620 on s.id = ci.schedule_id
7621 where
7622 s.linkage_instance_id >= 0
7623 and s.staff_id is null
7624 group by
7625 s.linkage_instance_id,
7626 s.is_weekend,
7627 s.period_offset,
7628 s.calendar_schedule_id
7629 having _scheduled > 0
7630 order by null
7631
7632 (157.3ms) insert into buffer_linkage_targets_824879560 (
7633 linkage_instance_id,
7634 is_weekend,
7635 period_offset,
7636 calendar_schedule_id,
7637 scheduled
7638 )
7639 select
7640 s.linkage_instance_id,
7641 -1 as is_weekend,
7642 s.period_offset,
7643 s.calendar_schedule_id,
7644 sum(ci.calls) as _scheduled
7645 from
7646 buffer_schedules_824879560 as s
7647 inner join buffer_counter_increments_824879560 as ci
7648 on s.id = ci.schedule_id
7649 where
7650 s.linkage_instance_id >= 0
7651 and s.staff_id is null
7652 group by
7653 s.linkage_instance_id,
7654 s.period_offset,
7655 s.calendar_schedule_id
7656 having _scheduled > 0
7657 order by null
7658
7659 (302.3ms) insert into buffer_linkage_targets_824879560 (
7660 linkage_instance_id,
7661 is_weekend,
7662 period_offset,
7663 calendar_schedule_id,
7664 scheduled
7665 )
7666 select
7667 s.linkage_instance_id,
7668 s.is_weekend,
7669 -1 as period_offset,
7670 s.calendar_schedule_id,
7671 sum(ci.calls) as _scheduled
7672 from
7673 buffer_schedules_824879560 as s
7674 inner join buffer_counter_increments_824879560 as ci
7675 on s.id = ci.schedule_id
7676 and ci.affects_cumulative_targets = 1
7677 where
7678 s.linkage_instance_id >= 0
7679 and s.staff_id is null
7680 group by
7681 s.linkage_instance_id,
7682 s.is_weekend,
7683 s.calendar_schedule_id
7684 having _scheduled > 0
7685 order by null
7686
7687 (157.1ms) insert into buffer_linkage_targets_824879560 (
7688 linkage_instance_id,
7689 is_weekend,
7690 period_offset,
7691 calendar_schedule_id,
7692 scheduled
7693 )
7694 select
7695 s.linkage_instance_id,
7696 -1 as is_weekend,
7697 -1 as period_offset,
7698 s.calendar_schedule_id,
7699 sum(ci.calls) as _scheduled
7700 from
7701 buffer_schedules_824879560 as s
7702 inner join buffer_counter_increments_824879560 as ci
7703 on s.id = ci.schedule_id
7704 and ci.affects_cumulative_targets = 1
7705 where
7706 s.linkage_instance_id >= 0
7707 and s.staff_id is null
7708 group by
7709 s.linkage_instance_id,
7710 s.calendar_schedule_id
7711 having _scheduled > 0
7712 order by null
7713
7714INFO : (04-03 14:41:24) --> fill: 19 - Scheduler::AutoPopulate::Queries::Query0702
7715 (301.5ms) insert into buffer_linkage_call_type_targets_824879560 (
7716 linkage_instance_id,
7717 assignment_id,
7718 assignment_type,
7719 is_weekend,
7720 period_offset,
7721 calendar_schedule_id,
7722 scheduled
7723 )
7724 select
7725 s.linkage_instance_id,
7726 ta.assignment_id,
7727 ta.assignment_type,
7728 s.is_weekend,
7729 s.period_offset,
7730 s.calendar_schedule_id,
7731 sum(ci.calls) as _scheduled
7732 from buffer_schedules_824879560 as s
7733 inner join buffer_target_assignments_824879560 as ta
7734 on s.call_type_id = ta.call_type_id
7735 inner join buffer_counter_increments_824879560 as ci
7736 on s.id = ci.schedule_id
7737 where
7738 s.linkage_instance_id >= 0
7739 and s.staff_id is null
7740 group by
7741 s.linkage_instance_id,
7742 ta.assignment_id,
7743 ta.assignment_type,
7744 s.is_weekend,
7745 s.period_offset,
7746 s.calendar_schedule_id
7747 having _scheduled > 0
7748 order by null
7749
7750 (157.1ms) insert into buffer_linkage_call_type_targets_824879560 (
7751 linkage_instance_id,
7752 assignment_id,
7753 assignment_type,
7754 is_weekend,
7755 period_offset,
7756 calendar_schedule_id,
7757 scheduled
7758 )
7759 select
7760 s.linkage_instance_id,
7761 ta.assignment_id,
7762 ta.assignment_type,
7763 -1 as is_weekend,
7764 s.period_offset,
7765 s.calendar_schedule_id,
7766 sum(ci.calls) as _scheduled
7767 from buffer_schedules_824879560 as s
7768 inner join buffer_target_assignments_824879560 as ta
7769 on s.call_type_id = ta.call_type_id
7770 inner join buffer_counter_increments_824879560 as ci
7771 on s.id = ci.schedule_id
7772 where
7773 s.linkage_instance_id >= 0
7774 and s.staff_id is null
7775 group by
7776 s.linkage_instance_id,
7777 ta.assignment_id,
7778 ta.assignment_type,
7779 s.period_offset,
7780 s.calendar_schedule_id
7781 having _scheduled > 0
7782 order by null
7783
7784 (156.3ms) insert into buffer_linkage_call_type_targets_824879560 (
7785 linkage_instance_id,
7786 assignment_id,
7787 assignment_type,
7788 is_weekend,
7789 period_offset,
7790 calendar_schedule_id,
7791 scheduled
7792 )
7793 select
7794 s.linkage_instance_id,
7795 ta.assignment_id,
7796 ta.assignment_type,
7797 s.is_weekend,
7798 -1 as period_offset,
7799 s.calendar_schedule_id,
7800 sum(ci.calls) as _scheduled
7801 from buffer_schedules_824879560 as s
7802 inner join buffer_target_assignments_824879560 as ta
7803 on s.call_type_id = ta.call_type_id
7804 inner join buffer_counter_increments_824879560 as ci
7805 on s.id = ci.schedule_id
7806 and ci.affects_cumulative_targets = 1
7807 where
7808 s.linkage_instance_id >= 0
7809 and s.staff_id is null
7810 group by
7811 s.linkage_instance_id,
7812 ta.assignment_id,
7813 ta.assignment_type,
7814 s.is_weekend,
7815 s.calendar_schedule_id
7816 having _scheduled > 0
7817 order by null
7818
7819 (156.1ms) insert into buffer_linkage_call_type_targets_824879560 (
7820 linkage_instance_id,
7821 assignment_id,
7822 assignment_type,
7823 is_weekend,
7824 period_offset,
7825 calendar_schedule_id,
7826 scheduled
7827 )
7828 select
7829 s.linkage_instance_id,
7830 ta.assignment_id,
7831 ta.assignment_type,
7832 -1 as is_weekend,
7833 -1 as period_offset,
7834 s.calendar_schedule_id,
7835 sum(ci.calls) as _scheduled
7836 from buffer_schedules_824879560 as s
7837 inner join buffer_target_assignments_824879560 as ta
7838 on s.call_type_id = ta.call_type_id
7839 inner join buffer_counter_increments_824879560 as ci
7840 on s.id = ci.schedule_id
7841 and ci.affects_cumulative_targets = 1
7842 where
7843 s.linkage_instance_id >= 0
7844 and s.staff_id is null
7845 group by
7846 s.linkage_instance_id,
7847 ta.assignment_id,
7848 ta.assignment_type,
7849 s.calendar_schedule_id
7850 having _scheduled > 0
7851 order by null
7852
7853INFO : (04-03 14:41:24) --> fill: 20 - Scheduler::AutoPopulate::Queries::Query0705
7854 (153.7ms) insert into buffer_linkage_call_type_assignments_824879560 (
7855 linkage_instance_id,
7856 call_type_id,
7857 is_weekend,
7858 period_offset,
7859 calendar_schedule_id,
7860 max_assignments,
7861 assignments_count
7862 )
7863 select
7864 s.linkage_instance_id,
7865 s.call_type_id,
7866 s.is_weekend,
7867 s.period_offset,
7868 s.calendar_schedule_id,
7869 case
7870 when (s.is_weekend = 0) then ct.max_weekday_assignments
7871 else ct.max_weekend_assignments
7872 end as _max_assignments,
7873 sum(1) as assignments_count
7874 from buffer_schedules_824879560 as s
7875 inner join call_types as ct
7876 on s.call_type_id = ct.id
7877 and ct.active = 1
7878 and (
7879 ct.max_weekday_assignments is not null
7880 or ct.max_weekend_assignments is not null
7881 )
7882 where s.linkage_instance_id >= 0
7883 and s.staff_id is null
7884 group by
7885 s.linkage_instance_id,
7886 s.call_type_id,
7887 s.is_weekend,
7888 s.period_offset,
7889 s.calendar_schedule_id,
7890 _max_assignments
7891 having _max_assignments >= 0
7892 order by null
7893
7894INFO : (04-03 14:41:25) --> fill: 21 - Scheduler::AutoPopulate::Queries::Query0706
7895 (153.3ms) insert into buffer_call_type_assignments_824879560 (
7896 staff_id,
7897 call_type_id,
7898 is_weekend,
7899 period_offset,
7900 calendar_schedule_id,
7901 assignments_count
7902 )
7903 select straight_join
7904 sc.staff_id,
7905 sc.call_type_id,
7906 sc.weekend_on as is_weekend,
7907 p.period_offset,
7908 p.calendar_schedule_id,
7909 sum(1) as assignments_count
7910 from buffer_periods_824879560 as p
7911 inner join call_types as ct
7912 on p.calendar_schedule_id = ct.calendar_schedule_id
7913 and ct.active = 1
7914 and (
7915 ct.max_weekday_assignments is not null
7916 or ct.max_weekend_assignments is not null
7917 )
7918 inner join schedules as sc
7919 on ct.id = sc.call_type_id
7920 and sc.schedule_on between p.start_date and p.end_date
7921 and sc.staff_id is not null
7922 where p.should_be_evaluated = 1
7923 group by
7924 sc.staff_id,
7925 sc.call_type_id,
7926 sc.weekend_on,
7927 p.period_offset,
7928 p.calendar_schedule_id
7929 order by null
7930
7931INFO : (04-03 14:41:25) --> fill: 22 - Scheduler::AutoPopulate::Queries::Query0707
7932 (157.0ms) insert into buffer_linkage_call_days_targets_824879560 (
7933 linkage_instance_id,
7934 assignment_id,
7935 assignment_type,
7936 day_of_week_mask,
7937 period_offset,
7938 calendar_schedule_id,
7939 scheduled
7940 )
7941 select
7942 s.linkage_instance_id,
7943 ta.assignment_id,
7944 ta.assignment_type,
7945 s.day_of_week_mask,
7946 s.period_offset,
7947 s.calendar_schedule_id,
7948 sum(ci.calls) as _scheduled
7949 from
7950 buffer_schedules_824879560 as s
7951 inner join buffer_target_assignments_824879560 as ta
7952 on s.call_type_id = ta.call_type_id
7953 inner join buffer_counter_increments_824879560 as ci
7954 on s.id = ci.schedule_id
7955 where
7956 s.linkage_instance_id >= 0
7957 and s.staff_id is null
7958 group by
7959 s.linkage_instance_id,
7960 ta.assignment_id,
7961 ta.assignment_type,
7962 s.day_of_week_mask,
7963 s.period_offset,
7964 s.calendar_schedule_id
7965 having _scheduled > 0
7966 order by null
7967
7968 (156.4ms) insert into buffer_linkage_call_days_targets_824879560 (
7969 linkage_instance_id,
7970 assignment_id,
7971 assignment_type,
7972 day_of_week_mask,
7973 period_offset,
7974 calendar_schedule_id,
7975 scheduled
7976 )
7977 select
7978 s.linkage_instance_id,
7979 ta.assignment_id,
7980 ta.assignment_type,
7981 s.day_of_week_mask,
7982 -1 as period_offset,
7983 s.calendar_schedule_id,
7984 sum(ci.calls) as _scheduled
7985 from
7986 buffer_schedules_824879560 as s
7987 inner join buffer_target_assignments_824879560 as ta
7988 on s.call_type_id = ta.call_type_id
7989 inner join buffer_counter_increments_824879560 as ci
7990 on s.id = ci.schedule_id
7991 and ci.affects_cumulative_targets = 1
7992 where
7993 s.linkage_instance_id >= 0
7994 and s.staff_id is null
7995 group by
7996 s.linkage_instance_id,
7997 ta.assignment_id,
7998 ta.assignment_type,
7999 s.day_of_week_mask,
8000 s.calendar_schedule_id
8001 having _scheduled > 0
8002 order by null
8003
8004INFO : (04-03 14:41:25) --> fill: 23 - Scheduler::AutoPopulate::Queries::Query0708
8005 (156.0ms) insert into buffer_linkage_assigned_days_824879560 (
8006 linkage_instance_id,
8007 period_offset,
8008 week_number,
8009 schedule_on,
8010 is_weekend
8011 )
8012 select distinct
8013 sc.linkage_instance_id,
8014 sc.period_offset,
8015 sc.week_number,
8016 sc.schedule_on,
8017 sc.is_weekend
8018 from
8019 buffer_schedules_824879560 as sc
8020 inner join call_types as ct
8021 on sc.call_type_id = ct.id
8022 and ct.unassigned_day = 0
8023 where
8024 sc.linkage_instance_id >= 0
8025 and sc.staff_id is null
8026 order by null
8027
8028INFO : (04-03 14:41:25) --> fill: 24 - Scheduler::AutoPopulate::Queries::Query0709
8029 (157.1ms) /* MonthlyDayOfWeekMixRule */
8030 insert into buffer_linkage_dow_targets_824879560 (
8031 linkage_instance_id,
8032 wday,
8033 period_offset,
8034 calendar_schedule_id,
8035 scheduled
8036 )
8037 select
8038 s.linkage_instance_id,
8039 (dayofweek(s.schedule_on) - 1) as _wday,
8040 s.period_offset,
8041 s.calendar_schedule_id,
8042 sum(ci.calls) as _scheduled
8043 from
8044 buffer_schedules_824879560 as s
8045 inner join buffer_counter_increments_824879560 as ci
8046 on s.id = ci.schedule_id
8047 where
8048 s.linkage_instance_id >= 0
8049 and s.staff_id is null
8050 group by
8051 s.linkage_instance_id,
8052 _wday,
8053 s.period_offset,
8054 s.calendar_schedule_id
8055 having _scheduled > 0
8056 order by null
8057
8058 (156.2ms) /* AnnualDayOfWeekMixRule */
8059 insert into buffer_linkage_dow_targets_824879560 (
8060 linkage_instance_id,
8061 wday,
8062 period_offset,
8063 calendar_schedule_id,
8064 scheduled
8065 )
8066 select
8067 s.linkage_instance_id,
8068 (dayofweek(s.schedule_on) - 1) as _wday,
8069 -1 as period_offset,
8070 s.calendar_schedule_id,
8071 sum(ci.calls) as _scheduled
8072 from
8073 buffer_schedules_824879560 as s
8074 inner join buffer_counter_increments_824879560 as ci
8075 on s.id = ci.schedule_id
8076 and ci.affects_cumulative_targets = 1
8077 where
8078 s.linkage_instance_id >= 0
8079 and s.staff_id is null
8080 group by
8081 s.linkage_instance_id,
8082 _wday,
8083 s.calendar_schedule_id
8084 having _scheduled > 0
8085 order by null
8086
8087INFO : (04-03 14:41:26) --> fill: 25 - Scheduler::AutoPopulate::Queries::Query07_10_AL
8088 (157.8ms) /* AssignmentLimitsPerPeriod, AssignmentLimitsPerWeek, AssignmentLimitsRolling, AssignmentLimitsConsecutive */
8089 insert into buffer_assignment_limit_call_types_824879560 (
8090 assignment_limit_id, call_type_id
8091 )
8092 select al.id as assignment_limit_id, ct.id as call_type_id
8093 from assignment_limits as al
8094 inner join assignment_limit_call_types as alct
8095 on al.id = alct.assignment_limit_id
8096 inner join call_types as ct
8097 on alct.call_type_id = ct.id
8098 and ct.active = 1
8099 where al.client_id = 6
8100 and al.active = 1
8101 union
8102 select al.id as assignment_limit_id, ct.id as call_type_id
8103 from assignment_limits as al
8104 inner join call_types as ct
8105 on al.client_id = ct.client_id
8106 and al.calendar_schedule_id = ct.calendar_schedule_id
8107 and ct.active = 1
8108 where al.client_id = 6
8109 and al.active = 1
8110 and al.all_current_schedule_assignments = 1
8111 union
8112 select al.id as assignment_limit_id, ct.id as call_type_id
8113 from assignment_limits as al
8114 inner join call_types as ct
8115 on al.client_id = ct.client_id
8116 and al.calendar_schedule_id != ct.calendar_schedule_id
8117 and ct.active = 1
8118 where al.client_id = 6
8119 and al.active = 1
8120 and al.all_other_schedule_assignments = 1
8121 order by null
8122
8123 (155.9ms) /* AssignmentLimitsPerPeriod, AssignmentLimitsPerWeek, AssignmentLimitsRolling, AssignmentLimitsConsecutive */
8124 insert into buffer_assignment_limit_staff_types_824879560 (
8125 assignment_limit_id, staff_type_id
8126 )
8127 select al.id as assignment_limit_id, st.id as staff_type_id
8128 from assignment_limits as al
8129 inner join assignment_limit_staff_types as alst
8130 on al.id = alst.assignment_limit_id
8131 inner join staff_types as st
8132 on alst.staff_type_id = st.id
8133 and st.active = 1
8134 where al.client_id = 6
8135 and al.active = 1
8136 union
8137 select al.id as assignment_limit_id, st.id as staff_type_id
8138 from assignment_limits as al
8139 inner join staff_types as st
8140 on al.client_id = st.client_id
8141 and st.active = 1
8142 where al.client_id = 6
8143 and al.active = 1
8144 and al.all_staff_types = 1
8145 order by null
8146
8147INFO : (04-03 14:41:26) --> fill: 26 - Scheduler::AutoPopulate::Queries::Query07_10_AL_01
8148 (154.3ms) /* AssignmentLimitsPerPeriod */
8149 insert into buffer_assignment_limit_periods_824879560 (
8150 assignment_limit_id, period_id, start_date, end_date
8151 )
8152 select
8153 al.id as assignment_limit_id,
8154 if(
8155 bs.blocks_type = 0,
8156 if(
8157 (month(b.start_date) - pt.begin_period) >= 0,
8158 year(b.start_date) * 100 + (month(b.start_date) - pt.begin_period) div pt.timeframe_type + 1,
8159 (year(b.start_date) - 1) * 100 + (month(b.start_date) + 12 - pt.begin_period) div pt.timeframe_type + 1
8160 ),
8161 b.display_order
8162 ) as period_id,
8163 min(b.start_date) as start_date,
8164 max(b.end_date) as end_date
8165 from assignment_limits as al
8166 inner join calendar_schedules as cs
8167 on al.calendar_schedule_id = cs.id
8168 inner join block_schedules as bs
8169 on cs.block_schedule_id = bs.id
8170 inner join blocks as b
8171 on bs.id = b.block_schedule_id
8172 and b.end_date >= date_add(now(), interval -24 month)
8173 inner join population_timeframes as pt
8174 on pt.client_id = 6
8175 and al.timeframe_type = pt.timeframe_type
8176 where al.client_id = 6
8177 and al.active = 1
8178 and al.max_per_period_limit is not null
8179 group by al.id, period_id
8180 order by null
8181
8182 (153.9ms) /* AssignmentLimitsPerPeriod */
8183 insert into buffer_linkage_assignments_count_periods_824879560 (
8184 linkage_instance_id, assignment_limit_id, schedule_on, start_date, end_date, assignments_count
8185 )
8186 select sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on, alp.start_date, alp.end_date,
8187 count(distinct sc.id) as assignments_count
8188 from buffer_schedules_824879560 as sc
8189 inner join buffer_assignment_limit_call_types_824879560 as alct
8190 on sc.call_type_id = alct.call_type_id
8191 inner join assignment_limits as al
8192 on alct.assignment_limit_id = al.id
8193 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
8194 and al.max_per_period_limit is not null
8195 inner join buffer_assignment_limit_periods_824879560 as alp
8196 on alct.assignment_limit_id = alp.assignment_limit_id
8197 and sc.schedule_on between alp.start_date and alp.end_date
8198 where sc.linkage_instance_id >= 0
8199 and sc.staff_id is null
8200 group by sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on, alp.start_date, alp.end_date
8201 order by null
8202
8203INFO : (04-03 14:41:26) --> fill: 27 - Scheduler::AutoPopulate::Queries::Query07_10_AL_02
8204 (153.5ms) /* AssignmentLimitsPerWeek */
8205 insert into buffer_linkage_assignments_count_weeks_824879560 (
8206 linkage_instance_id, assignment_limit_id, schedule_on, start_date, end_date, assignments_count
8207 )
8208 select sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on,
8209 if(
8210 cl.start_of_week = 0,
8211 date_add(sc.schedule_on, interval (1 - dayofweek(sc.schedule_on)) day),
8212 date_add(sc.schedule_on, interval (0 - weekday(sc.schedule_on)) day)
8213 ) as start_date,
8214 if(
8215 cl.start_of_week = 0,
8216 date_add(sc.schedule_on, interval (7 - dayofweek(sc.schedule_on)) day),
8217 date_add(sc.schedule_on, interval (6 - weekday(sc.schedule_on)) day)
8218 ) as end_date,
8219 count(distinct sc.id) as assignments_count
8220 from buffer_schedules_824879560 as sc
8221 inner join buffer_assignment_limit_call_types_824879560 as alct
8222 on sc.call_type_id = alct.call_type_id
8223 inner join assignment_limits as al
8224 on alct.assignment_limit_id = al.id
8225 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
8226 and al.max_weekly_limit is not null
8227 inner join clients as cl
8228 on cl.id = 6
8229 where sc.linkage_instance_id >= 0
8230 and sc.staff_id is null
8231 group by sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on, start_date, end_date
8232 order by null
8233
8234INFO : (04-03 14:41:26) --> fill: 28 - Scheduler::AutoPopulate::Queries::Query07_10_AL_03
8235 (153.6ms) /* AssignmentLimitsRolling */
8236 insert into buffer_linkage_assignments_count_rolling_824879560 (
8237 linkage_instance_id, assignment_limit_id, schedule_on, start_date, end_date, assignments_count
8238 )
8239 select sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on,
8240 date_add(sc.schedule_on, interval (1 - ns.item_number) day) as start_date,
8241 date_add(sc.schedule_on, interval (al.max_rolling_period - ns.item_number) day) as end_date,
8242 count(distinct sc.id) as assignments_count
8243 from buffer_schedules_824879560 as sc
8244 inner join buffer_assignment_limit_call_types_824879560 as alct
8245 on sc.call_type_id = alct.call_type_id
8246 inner join assignment_limits as al
8247 on alct.assignment_limit_id = al.id
8248 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
8249 and al.max_rolling_period is not null
8250 and al.max_rolling_limit is not null
8251 inner join numeric_sequence as ns
8252 on ns.item_number between 1 and al.max_rolling_period
8253 where sc.linkage_instance_id >= 0
8254 and sc.staff_id is null
8255 group by sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on, start_date, end_date
8256 order by null
8257
8258INFO : (04-03 14:41:26) --> fill: 29 - Scheduler::AutoPopulate::Queries::Query07_10_AL_04
8259 (153.0ms) /* AssignmentLimitsConsecutive */
8260 insert into buffer_linkage_assignments_count_consecutive_824879560 (
8261 linkage_instance_id, assignment_limit_id, schedule_on, start_date, end_date
8262 )
8263 select sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on,
8264 date_add(sc.schedule_on, interval (1 - ns.item_number) day) as start_date,
8265 date_add(sc.schedule_on, interval ((al.max_consecutive_limit + 1) - ns.item_number) day) as end_date
8266 from buffer_schedules_824879560 as sc
8267 inner join buffer_assignment_limit_call_types_824879560 as alct
8268 on sc.call_type_id = alct.call_type_id
8269 inner join assignment_limits as al
8270 on alct.assignment_limit_id = al.id
8271 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
8272 and al.max_consecutive_limit is not null
8273 inner join numeric_sequence as ns
8274 on ns.item_number between 1 and (al.max_consecutive_limit + 1)
8275 where sc.linkage_instance_id >= 0
8276 and sc.staff_id is null
8277 group by sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on, start_date, end_date
8278 order by null
8279
8280INFO : (04-03 14:41:27) --> fill: 30 - Scheduler::AutoPopulate::Queries::Query08
8281 (152.9ms) insert into buffer_staff_daily_counts_824879560 (
8282 staff_id, schedule_on, linkage_instance_id, slots_count
8283 )
8284 select staff_id, schedule_on, null as linkage_instance_id,
8285 count(1) as slots_count
8286 from buffer_schedules_824879560
8287 where staff_id is not null
8288 and call_type_id > 0 /* VC */
8289 group by staff_id, schedule_on
8290 order by null
8291
8292 (153.4ms) insert into buffer_staff_daily_counts_824879560 (
8293 staff_id, schedule_on, linkage_instance_id, slots_count
8294 )
8295 select staff_id, schedule_on, linkage_instance_id,
8296 count(1) as slots_count
8297 from buffer_schedules_824879560
8298 where staff_id is not null
8299 and call_type_id > 0 /* VC */
8300 group by staff_id, schedule_on, linkage_instance_id
8301 order by null
8302
8303INFO : (04-03 14:41:27) --> fill: 31 - Scheduler::AutoPopulate::Queries::Query085
8304 (277.3ms) insert into buffer_staff_specializations_824879560 (
8305 staff_id, specialization_id
8306 )
8307 select staff_id, specialization_id
8308 from view_staff_specializations
8309 where client_id = 6
8310 order by null
8311
8312 (154.1ms) insert into buffer_specialization_daily_counts_824879560 (
8313 specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
8314 )
8315 select sp.id as specialization_id,
8316 null as staff_id,
8317 bs_1.schedule_on,
8318 count(distinct st_sp.staff_id) as staffs_scheduled,
8319 sp.max_scheduled,
8320 if(bs_1.day_of_week_mask & sp.days_of_week_mask > 0 or sp.days_of_week_mask = 0, 1, 0) as should_be_evaluated
8321 from (
8322 select schedule_on, day_of_week_mask
8323 from buffer_schedules_824879560
8324 where should_be_evaluated = 1
8325 group by schedule_on, day_of_week_mask
8326 order by null
8327 ) as bs_1
8328 inner join specializations as sp
8329 on sp.client_id = 6
8330 and sp.active = 1
8331 inner join buffer_schedules_824879560 as bs_2
8332 on bs_1.schedule_on = bs_2.schedule_on
8333 and bs_2.call_type_id > 0 /* is not VC */
8334 inner join max_applicable_call_types as mact
8335 on sp.id = mact.specialization_id
8336 and bs_2.call_type_id = mact.call_type_id
8337 left join buffer_staff_specializations_824879560 as st_sp
8338 on bs_2.staff_id = st_sp.staff_id
8339 and sp.id = st_sp.specialization_id
8340 group by sp.id, bs_1.schedule_on, sp.max_scheduled
8341 order by null
8342
8343 (153.5ms) insert into buffer_specialization_daily_counts_824879560 (
8344 specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
8345 )
8346 select sp.id as specialization_id,
8347 st_sp.staff_id,
8348 bs_1.schedule_on,
8349 1 as staffs_scheduled,
8350 sp.max_scheduled,
8351 if(bs_1.day_of_week_mask & sp.days_of_week_mask > 0 or sp.days_of_week_mask = 0, 1, 0) as should_be_evaluated
8352 from (
8353 select schedule_on, day_of_week_mask
8354 from buffer_schedules_824879560
8355 where should_be_evaluated = 1
8356 group by schedule_on, day_of_week_mask
8357 order by null
8358 ) as bs_1
8359 inner join specializations as sp
8360 on sp.client_id = 6
8361 and sp.active = 1
8362 inner join buffer_schedules_824879560 as bs_2
8363 on bs_1.schedule_on = bs_2.schedule_on
8364 and bs_2.call_type_id > 0 /* is not VC */
8365 inner join max_applicable_call_types as mact
8366 on sp.id = mact.specialization_id
8367 and bs_2.call_type_id = mact.call_type_id
8368 inner join buffer_staff_specializations_824879560 as st_sp
8369 on bs_2.staff_id = st_sp.staff_id
8370 and sp.id = st_sp.specialization_id
8371 group by sp.id, st_sp.staff_id, bs_1.schedule_on, sp.max_scheduled
8372 order by null
8373
8374INFO : (04-03 14:41:28) --> fill: 32 - Scheduler::AutoPopulate::Queries::Query09
8375 (155.3ms) truncate table buffer_location_privileges_824879560
8376
8377 (158.1ms) insert into buffer_location_privileges_824879560 (
8378 staff_id,
8379 location_id,
8380 begin_date,
8381 end_date
8382 )
8383 select
8384 s.id as staff_id,
8385 l.location_id,
8386 '0000-00-00' as begin_date,
8387 '9999-12-31' as end_date
8388 from (
8389 select l.id as location_id
8390 from
8391 buffer_schedules_824879560 as sc
8392 inner join call_types as ct
8393 on sc.call_type_id = ct.id
8394 and ct.active = 1
8395 inner join locations as l
8396 on ct.location_id = l.id
8397 and l.active = 1
8398 where sc.linkage_instance_id >= 0
8399 and sc.should_be_evaluated = 1
8400 group by l.id
8401 order by null
8402 ) as l
8403 inner join staffs as s
8404 on s.client_id = 6
8405 and s.active = 1
8406 and s.take_call = 1
8407 left join location_privileges as lp
8408 on s.id = lp.staff_id
8409 where lp.id is null
8410
8411 union
8412
8413 select
8414 lp.staff_id,
8415 lp.location_id,
8416 lp.begin_date,
8417 lp.end_date
8418 from (
8419 select l.id as location_id
8420 from
8421 buffer_schedules_824879560 as sc
8422 inner join call_types as ct
8423 on sc.call_type_id = ct.id
8424 and ct.active = 1
8425 inner join locations as l
8426 on ct.location_id = l.id
8427 and l.active = 1
8428 where sc.linkage_instance_id >= 0
8429 and sc.should_be_evaluated = 1
8430 group by l.id
8431 order by null
8432 ) as l
8433 inner join location_privileges as lp
8434 on l.location_id = lp.location_id
8435 order by null;
8436
8437 (2559.7ms) insert into buffer_static_availabilities_824879560 (
8438 schedule_id,
8439 staff_id,
8440 staff_type_id,
8441 is_primary
8442 )
8443 select
8444 schedules.id as schedule_id,
8445 staffs.id as staff_id,
8446 assign_staff_types.staff_type_id,
8447 if(schedules.day_of_week_mask & staff_call_types.days_of_week_mask & ifnull(rotation_call_types.days_of_week_mask, 127) > 0, 1, 0) as is_primary
8448 from
8449 buffer_schedules_824879560 as schedules
8450 /* AvailabilityRule */
8451 inner join call_types
8452 on schedules.call_type_id = call_types.id
8453 and call_types.active = 1
8454 and schedules.day_of_week_mask & call_types.days_of_week_mask > 0
8455 inner join staff_call_types
8456 on call_types.id = staff_call_types.call_type_id
8457 and schedules.day_of_week_mask & (staff_call_types.days_of_week_mask | staff_call_types.secondary_availability_days_of_week_mask) > 0
8458 inner join staffs
8459 on staff_call_types.staff_id = staffs.id
8460 and staffs.active = 1
8461 and staffs.take_call = 1
8462 and staffs.auto_populatable = 1
8463 inner join buffer_location_privileges_824879560 as location_privileges
8464 on staffs.id = location_privileges.staff_id
8465 and call_types.location_id = location_privileges.location_id
8466 and schedules.schedule_on between location_privileges.begin_date and ifnull(location_privileges.end_date, '9999-12-31')
8467 inner join assign_staff_types
8468 on staffs.id = assign_staff_types.staff_id
8469 and schedules.schedule_on between assign_staff_types.begin_date and ifnull(assign_staff_types.end_date, '9999-12-31')
8470 left join eligible_staff_types
8471 on staff_call_types.call_type_id = eligible_staff_types.call_type_id
8472 and assign_staff_types.staff_type_id = eligible_staff_types.staff_type_id
8473 left join staff_rotations
8474 on staffs.id = staff_rotations.staff_id
8475 and schedules.schedule_on between staff_rotations.start_date and staff_rotations.end_date
8476 left join daily_rotations
8477 on staffs.id = daily_rotations.staff_id
8478 and schedules.schedule_on = daily_rotations.schedule_on
8479 left join rotations
8480 on rotations.id = ifnull(daily_rotations.rotation_id, staff_rotations.rotation_id)
8481 and rotations.active = 1
8482 left join rotation_call_types
8483 on rotations.id = rotation_call_types.rotation_id
8484 and staff_call_types.call_type_id = rotation_call_types.call_type_id
8485 and schedules.day_of_week_mask & (rotation_call_types.days_of_week_mask | rotation_call_types.secondary_availability_days_of_week_mask) > 0
8486 /* RequiredRotationsRule */
8487 left join required_rotations
8488 on staff_call_types.call_type_id = required_rotations.call_type_id
8489 left join staff_rotations as staff_rotations2
8490 on staffs.id = staff_rotations2.staff_id
8491 and required_rotations.rotation_id = staff_rotations2.rotation_id
8492 and schedules.schedule_on >= staff_rotations2.start_date
8493 /* NoCallRequestsHiddenHardRule */
8494 left join request_settings
8495 on assign_staff_types.staff_type_id = request_settings.staff_type_id
8496 left join requests
8497 on schedules.schedule_on = requests.schedule_on
8498 and staffs.id = requests.staff_id
8499 and requests.request_type = 0 /* type = no_call */
8500 and requests.status in (1, 3) /* status = approved or fulfilled */
8501 and call_types.is_no_call_requestable = 1
8502 left join request_call_types
8503 on requests.id = request_call_types.request_id
8504 and schedules.call_type_id = request_call_types.call_type_id
8505 where
8506 schedules.linkage_instance_id >= 0
8507 and schedules.should_be_evaluated = 1
8508 and (
8509 call_types.all_staff_types = 1
8510 or eligible_staff_types.id is not null
8511 )
8512 and (
8513 rotations.id is null
8514 or rotation_call_types.id is not null
8515 )
8516 and (
8517 requests.id is null
8518 or (
8519 requests.all_call_types = 1
8520 and request_settings.call_only_all_call_switch = 1 /* calls only */
8521 and call_types.assignment_type = 1 /* clinical */
8522 )
8523 or (
8524 requests.all_call_types != 1
8525 and request_call_types.id is null
8526 )
8527 )
8528 group by
8529 schedules.id,
8530 staffs.id,
8531 assign_staff_types.staff_type_id,
8532 is_primary
8533 having
8534 sum(if(required_rotations.id is not null and staff_rotations2.id is null, 1, 0)) = 0 /* RequiredRotationsRule */
8535 and is_primary IN (0,1) /* PrimaryAvailabilityRule */
8536 order by null
8537
8538INFO : (04-03 14:41:30) --> fill: 33 - Scheduler::AutoPopulate::Queries::Query092
8539 (161.1ms) /* RotationPostCallRule */
8540 /* Exclude people and slots when a post-call is not allowed on the first day of a rotation */
8541 delete sa
8542 from buffer_static_availabilities_824879560 as sa
8543 inner join buffer_schedules_824879560 as sc
8544 on sa.schedule_id = sc.id
8545 inner join call_types as ct
8546 on sc.call_type_id = ct.id
8547 and ct.assignment_type = 0 /* call */
8548 inner join staff_rotations as sr
8549 on sa.staff_id = sr.staff_id
8550 and date_add(sc.schedule_on, interval 1 day) = sr.start_date
8551 inner join rotations as r
8552 on sr.rotation_id = r.id
8553 and r.post_call_allowed = 0
8554
8555INFO : (04-03 14:41:31) --> fill: 34 - Scheduler::AutoPopulate::Queries::Query093
8556INFO : (04-03 14:41:31) --> fill: 35 - Scheduler::AutoPopulate::Queries::Query095
8557 (161.0ms) insert into buffer_negative_relations_824879560 (
8558 schedule_id,
8559 affected_by_schedule_id,
8560 staff_id
8561 )
8562 select
8563 b_schedules.id as schedule_id,
8564 b_schedules_negative_link.id as affected_by_schedule_id,
8565 b_schedules_negative_link.staff_id
8566 from
8567 buffer_schedules_824879560 as b_schedules
8568 /* NegativeLinkRule */
8569 inner join negative_links_influences
8570 on b_schedules.day_of_week_mask = negative_links_influences.day_of_week_mask
8571 and b_schedules.call_type_id = negative_links_influences.source_id
8572 and negative_links_influences.source_type = 'CallType'
8573 and negative_links_influences.target_type = 'CallType'
8574 inner join buffer_schedules_824879560 as b_schedules_negative_link
8575 on date_add(
8576 b_schedules.schedule_on,
8577 interval negative_links_influences.offset day
8578 ) = b_schedules_negative_link.schedule_on
8579 and negative_links_influences.target_id = b_schedules_negative_link.call_type_id
8580 and b_schedules.id != b_schedules_negative_link.id
8581 where
8582 b_schedules.linkage_instance_id >= 0
8583 and b_schedules.should_be_evaluated = 1
8584 order by null
8585
8586 (157.1ms) insert into buffer_negative_relations_824879560 (
8587 schedule_id,
8588 affected_by_schedule_id,
8589 staff_id
8590 )
8591 select
8592 b_schedules.id as schedule_id,
8593 b_schedules_negative_link.id as affected_by_schedule_id,
8594 b_schedules_negative_link.staff_id
8595 from
8596 buffer_schedules_824879560 as b_schedules
8597 /* NegativeLinkRule */
8598 inner join negative_links_influences
8599 on b_schedules.day_of_week_mask = negative_links_influences.day_of_week_mask
8600 and b_schedules.call_type_id = negative_links_influences.source_id
8601 and negative_links_influences.source_type = 'CallType'
8602 and negative_links_influences.target_type in ('Vacation', 'NonClinicalType')
8603 inner join buffer_schedules_824879560 as b_schedules_negative_link
8604 on date_add(
8605 b_schedules.schedule_on,
8606 interval negative_links_influences.offset day
8607 ) = b_schedules_negative_link.schedule_on
8608 and (-1 * negative_links_influences.target_id) = b_schedules_negative_link.call_type_id
8609 and b_schedules.id != b_schedules_negative_link.id
8610 where
8611 b_schedules.linkage_instance_id >= 0
8612 and b_schedules.should_be_evaluated = 1
8613 order by null
8614
8615 (154.5ms) delete from buffer_schedules_824879560
8616 where call_type_id < 0 /* vacations and non-clinicals */
8617
8618INFO : (04-03 14:41:31) --> fill: 36 - Scheduler::AutoPopulate::Queries::Query097
8619 (188.2ms) insert into buffer_staff_assigned_days_824879560 (
8620 staff_id, period_offset, week_number, schedule_on, is_weekend, is_assigned
8621 )
8622 select staffs.staff_id,
8623 if(days.within_period = 1, days.period_offset, null) as period_offset,
8624 yearweek(days.schedule_on, if(clients.start_of_week = 0, 2, 7)) as week_number,
8625 days.schedule_on,
8626 if(dayofweek(days.schedule_on) in (7, 1), 1, 0) as is_weekend,
8627 if(schedules.staff_id is not null or vacations.staff_id is not null, 1, 0) as is_assigned
8628 from (
8629 select distinct staff_id
8630 from buffer_static_availabilities_824879560
8631 order by null
8632 ) as staffs
8633 inner join (
8634 select p.period_offset,
8635 date_add(date_add(p.start_date, interval -6 day), interval (digits_1.digit * 100 + digits_2.digit * 10 + digits_3.digit) day) as schedule_on,
8636 if((digits_1.digit * 100 + digits_2.digit * 10 + digits_3.digit) - 6 between 0 and datediff(p.end_date, p.start_date), 1, 0) as within_period
8637 from buffer_periods_824879560 as p
8638 inner join (
8639 select 0 as digit union select 1 union select 2 union select 3 union select 4
8640 union select 5 union select 6 union select 7 union select 8 union select 9
8641 ) as digits_1
8642 inner join (
8643 select 0 as digit union select 1 union select 2 union select 3 union select 4
8644 union select 5 union select 6 union select 7 union select 8 union select 9
8645 ) as digits_2
8646 inner join (
8647 select 0 as digit union select 1 union select 2 union select 3 union select 4
8648 union select 5 union select 6 union select 7 union select 8 union select 9
8649 ) as digits_3
8650 where p.calendar_schedule_id = 6
8651 and p.should_be_evaluated = 1
8652 and (digits_1.digit * 100 + digits_2.digit * 10 + digits_3.digit) <= datediff(p.end_date, p.start_date) + 12
8653 order by null
8654 ) as days
8655 inner join (
8656 select min(start_date) as start_date, max(end_date) as end_date
8657 from buffer_periods_824879560
8658 where calendar_schedule_id = 6
8659 and should_be_evaluated = 1
8660 order by null
8661 ) as limits
8662 inner join clients
8663 on clients.id = 6
8664 left join (
8665 select sc.staff_id, sc.schedule_on
8666 from buffer_periods_824879560 as p
8667 inner join schedules as sc
8668 on sc.client_id = 6
8669 and sc.schedule_on between date_add(p.start_date, interval -6 day) and date_add(p.end_date, interval 6 day)
8670 inner join call_types as ct
8671 on sc.call_type_id = ct.id
8672 and ct.unassigned_day = 0
8673 where p.calendar_schedule_id = 6
8674 and p.should_be_evaluated = 1
8675 group by sc.staff_id, sc.schedule_on
8676 order by null
8677 ) as schedules
8678 on staffs.staff_id = schedules.staff_id
8679 and days.schedule_on = schedules.schedule_on
8680 left join (
8681 select v.staff_id, v.schedule_on
8682 from buffer_periods_824879560 as p
8683 inner join vacations as v
8684 on v.client_id = 6
8685 and v.schedule_on between date_add(p.start_date, interval -6 day) and date_add(p.end_date, interval 6 day)
8686 and v.status IN (3)
8687 inner join non_clinical_types as nct
8688 on v.non_clinical_type_id = nct.id
8689 and nct.active = 1
8690 and nct.unassigned_day = 0
8691 where p.calendar_schedule_id = 6
8692 and p.should_be_evaluated = 1
8693 group by v.staff_id, v.schedule_on
8694 order by null
8695 ) as vacations
8696 on staffs.staff_id = vacations.staff_id
8697 and days.schedule_on = vacations.schedule_on
8698 where days.within_period = 1
8699 or yearweek(days.schedule_on, if(clients.start_of_week = 0, 2, 7)) in (
8700 yearweek(limits.start_date, if(clients.start_of_week = 0, 2, 7)),
8701 yearweek(limits.end_date, if(clients.start_of_week = 0, 2, 7))
8702 )
8703 order by null
8704
8705INFO : (04-03 14:41:31) --> fill: 37 - Scheduler::AutoPopulate::Queries::Query098
8706 (162.1ms) insert into buffer_combined_availabilities_824879560 (
8707 schedule_id, staff_id, staff_type_id, is_primary, linkage_instance_id, has_violations
8708 )
8709 select sc.id as schedule_id, sa.staff_id, sa.staff_type_id, sa.is_primary,
8710 sc.linkage_instance_id, 0 as has_violations
8711 from buffer_schedules_824879560 as sc
8712 /* Static availability */
8713 inner join buffer_static_availabilities_824879560 as sa
8714 on sc.id = sa.schedule_id
8715 inner join buffer_linkages_824879560 as l
8716 on sc.linkage_instance_id = l.linkage_instance_id
8717 where sc.should_be_evaluated = 1
8718 and l.has_conflicts = 0
8719
8720 (152.6ms) insert into buffer_schedule_linkages_824879560 (
8721 staff_id, linkage_instance_id, slots_count
8722 )
8723 select staff_id, linkage_instance_id, count(1) as slots_count
8724 from buffer_schedules_824879560 use index (ix_buffer_schedules_composite_2)
8725 where staff_id is not null
8726 and linkage_instance_id >= 0
8727 group by staff_id, linkage_instance_id
8728 order by null
8729
8730INFO : (04-03 14:41:32) --> fill: 38 - Scheduler::AutoPopulate::Queries::Query09_09_AL_01
8731 (154.1ms) /* AssignmentLimitsPerPeriod */
8732 insert into buffer_staff_assignments_count_periods_824879560 (
8733 assignment_limit_id, staff_id, start_date, end_date, assignments_count
8734 )
8735 select straight_join lac.assignment_limit_id, ca.staff_id, lac.start_date, lac.end_date,
8736 count(distinct sc.id) as assignments_count
8737 from (
8738 select linkage_instance_id, assignment_limit_id, start_date, end_date
8739 from buffer_linkage_assignments_count_periods_824879560
8740 group by linkage_instance_id, assignment_limit_id, start_date, end_date
8741 order by null
8742 ) as lac
8743 inner join (
8744 select linkage_instance_id, staff_id
8745 from buffer_combined_availabilities_824879560
8746 group by linkage_instance_id, staff_id
8747 order by null
8748 ) as ca
8749 on lac.linkage_instance_id = ca.linkage_instance_id
8750 inner join assignment_limits as al
8751 on lac.assignment_limit_id = al.id
8752 inner join schedules as sc
8753 on ca.staff_id = sc.staff_id
8754 and sc.schedule_on between lac.start_date and lac.end_date
8755 and ((1 << (dayofweek(sc.schedule_on) - 1)) & al.considered_days_of_week_mask) > 0
8756 inner join buffer_assignment_limit_call_types_824879560 as alct
8757 on lac.assignment_limit_id = alct.assignment_limit_id
8758 and sc.call_type_id = alct.call_type_id
8759 inner join assign_staff_types as ast
8760 on sc.staff_id = ast.staff_id
8761 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
8762 inner join buffer_assignment_limit_staff_types_824879560 as alst
8763 on lac.assignment_limit_id = alst.assignment_limit_id
8764 and ast.staff_type_id = alst.staff_type_id
8765 group by lac.assignment_limit_id, ca.staff_id, lac.start_date, lac.end_date
8766 order by null
8767
8768INFO : (04-03 14:41:32) --> fill: 39 - Scheduler::AutoPopulate::Queries::Query09_09_AL_02
8769 (153.7ms) /* AssignmentLimitsPerWeek */
8770 insert into buffer_staff_assignments_count_weeks_824879560 (
8771 assignment_limit_id, staff_id, start_date, end_date, assignments_count
8772 )
8773 select straight_join lac.assignment_limit_id, ca.staff_id, lac.start_date, lac.end_date,
8774 count(distinct sc.id) as assignments_count
8775 from (
8776 select linkage_instance_id, assignment_limit_id, start_date, end_date
8777 from buffer_linkage_assignments_count_weeks_824879560
8778 group by linkage_instance_id, assignment_limit_id, start_date, end_date
8779 order by null
8780 ) as lac
8781 inner join (
8782 select linkage_instance_id, staff_id
8783 from buffer_combined_availabilities_824879560
8784 group by linkage_instance_id, staff_id
8785 order by null
8786 ) as ca
8787 on lac.linkage_instance_id = ca.linkage_instance_id
8788 inner join assignment_limits as al
8789 on lac.assignment_limit_id = al.id
8790 inner join schedules as sc
8791 on ca.staff_id = sc.staff_id
8792 and sc.schedule_on between lac.start_date and lac.end_date
8793 and ((1 << (dayofweek(sc.schedule_on) - 1)) & al.considered_days_of_week_mask) > 0
8794 inner join buffer_assignment_limit_call_types_824879560 as alct
8795 on lac.assignment_limit_id = alct.assignment_limit_id
8796 and sc.call_type_id = alct.call_type_id
8797 inner join assign_staff_types as ast
8798 on sc.staff_id = ast.staff_id
8799 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
8800 inner join buffer_assignment_limit_staff_types_824879560 as alst
8801 on lac.assignment_limit_id = alst.assignment_limit_id
8802 and ast.staff_type_id = alst.staff_type_id
8803 group by lac.assignment_limit_id, ca.staff_id, lac.start_date, lac.end_date
8804 order by null
8805
8806INFO : (04-03 14:41:32) --> fill: 40 - Scheduler::AutoPopulate::Queries::Query09_09_AL_03
8807 (153.9ms) /* AssignmentLimitsRolling */
8808 insert into buffer_staff_assignments_count_rolling_824879560 (
8809 assignment_limit_id, staff_id, start_date, end_date, assignments_count
8810 )
8811 select straight_join lac.assignment_limit_id, ca.staff_id, lac.start_date, lac.end_date,
8812 count(distinct sc.id) as assignments_count
8813 from (
8814 select linkage_instance_id, assignment_limit_id, start_date, end_date
8815 from buffer_linkage_assignments_count_rolling_824879560
8816 group by linkage_instance_id, assignment_limit_id, start_date, end_date
8817 order by null
8818 ) as lac
8819 inner join (
8820 select linkage_instance_id, staff_id
8821 from buffer_combined_availabilities_824879560
8822 group by linkage_instance_id, staff_id
8823 order by null
8824 ) as ca
8825 on lac.linkage_instance_id = ca.linkage_instance_id
8826 inner join assignment_limits as al
8827 on lac.assignment_limit_id = al.id
8828 inner join schedules as sc
8829 on ca.staff_id = sc.staff_id
8830 and sc.schedule_on between lac.start_date and lac.end_date
8831 and ((1 << (dayofweek(sc.schedule_on) - 1)) & al.considered_days_of_week_mask) > 0
8832 inner join buffer_assignment_limit_call_types_824879560 as alct
8833 on lac.assignment_limit_id = alct.assignment_limit_id
8834 and sc.call_type_id = alct.call_type_id
8835 inner join assign_staff_types as ast
8836 on sc.staff_id = ast.staff_id
8837 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
8838 inner join buffer_assignment_limit_staff_types_824879560 as alst
8839 on lac.assignment_limit_id = alst.assignment_limit_id
8840 and ast.staff_type_id = alst.staff_type_id
8841 group by lac.assignment_limit_id, ca.staff_id, lac.start_date, lac.end_date
8842 order by null
8843
8844INFO : (04-03 14:41:32) --> fill: 41 - Scheduler::AutoPopulate::Queries::Query09_09_AL_04
8845 (153.5ms) /* AssignmentLimitsConsecutive */
8846 insert into buffer_staff_assignments_count_consecutive_824879560 (
8847 assignment_limit_id, staff_id, schedule_on, start_date, end_date
8848 )
8849 select straight_join lac.assignment_limit_id, ca.staff_id, sc.schedule_on, lac.start_date, lac.end_date
8850 from (
8851 select linkage_instance_id, assignment_limit_id, start_date, end_date
8852 from buffer_linkage_assignments_count_consecutive_824879560
8853 group by linkage_instance_id, assignment_limit_id, start_date, end_date
8854 order by null
8855 ) as lac
8856 inner join (
8857 select linkage_instance_id, staff_id
8858 from buffer_combined_availabilities_824879560
8859 group by linkage_instance_id, staff_id
8860 order by null
8861 ) as ca
8862 on lac.linkage_instance_id = ca.linkage_instance_id
8863 inner join assignment_limits as al
8864 on lac.assignment_limit_id = al.id
8865 inner join schedules as sc
8866 on ca.staff_id = sc.staff_id
8867 and sc.schedule_on between lac.start_date and lac.end_date
8868 and ((1 << (dayofweek(sc.schedule_on) - 1)) & al.considered_days_of_week_mask) > 0
8869 inner join buffer_assignment_limit_call_types_824879560 as alct
8870 on lac.assignment_limit_id = alct.assignment_limit_id
8871 and sc.call_type_id = alct.call_type_id
8872 inner join assign_staff_types as ast
8873 on sc.staff_id = ast.staff_id
8874 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
8875 inner join buffer_assignment_limit_staff_types_824879560 as alst
8876 on lac.assignment_limit_id = alst.assignment_limit_id
8877 and ast.staff_type_id = alst.staff_type_id
8878 group by lac.assignment_limit_id, ca.staff_id, sc.schedule_on, lac.start_date, lac.end_date
8879 order by null
8880
8881INFO : (04-03 14:41:32) --> fill: 42 - Scheduler::AutoPopulate::Queries::Query09_12_Points
8882 (201.9ms) insert into buffer_linkage_point_targets_824879560 (
8883 linkage_instance_id,
8884 staff_id,
8885 is_weekend,
8886 period_offset,
8887 calendar_schedule_id,
8888 scheduled
8889 )
8890 select
8891 sc.linkage_instance_id,
8892 ca.staff_id,
8893 part_of_week.is_weekend,
8894 periods.period_offset,
8895 sc.calendar_schedule_id,
8896 sum(ci.points) as scheduled
8897 from
8898 buffer_combined_availabilities_824879560 as ca
8899 inner join buffer_schedules_824879560 as sc
8900 on ca.schedule_id = sc.id
8901 inner join buffer_counter_increments_824879560 as ci
8902 on sc.id = ci.schedule_id
8903 and ci.points != 0
8904 inner join staff_types as st
8905 on ca.staff_type_id = st.id
8906 and sc.calendar_schedule_id = st.point_hour_schedule_id
8907 inner join (
8908 select 0 as is_weekend
8909 union select 1
8910 union select -1
8911 ) as part_of_week
8912 on sc.is_weekend = part_of_week.is_weekend
8913 or part_of_week.is_weekend = -1
8914 inner join (
8915 select period_offset
8916 from buffer_periods_824879560
8917 union select -1 as period_offset
8918 order by null
8919 ) as periods
8920 on sc.period_offset = periods.period_offset
8921 or periods.period_offset = -1
8922 group by
8923 sc.linkage_instance_id,
8924 ca.staff_id,
8925 part_of_week.is_weekend,
8926 periods.period_offset,
8927 sc.calendar_schedule_id
8928 having sum(abs(ci.points)) > 0
8929 order by null
8930
8931INFO : (04-03 14:41:32) --> fill: 43 - Scheduler::AutoPopulate::Queries::Query09_12_Hours
8932 (195.1ms) insert into buffer_linkage_hour_targets_824879560 (
8933 linkage_instance_id,
8934 staff_id,
8935 is_weekend,
8936 period_offset,
8937 calendar_schedule_id,
8938 scheduled
8939 )
8940 select
8941 sc.linkage_instance_id,
8942 ca.staff_id,
8943 part_of_week.is_weekend,
8944 periods.period_offset,
8945 sc.calendar_schedule_id,
8946 sum(ci.hours) as _scheduled
8947 from
8948 buffer_combined_availabilities_824879560 as ca
8949 inner join buffer_schedules_824879560 as sc
8950 on ca.schedule_id = sc.id
8951 inner join buffer_counter_increments_824879560 as ci
8952 on sc.id = ci.schedule_id
8953 and ci.hours > 0
8954 inner join staff_types as st
8955 on ca.staff_type_id = st.id
8956 and sc.calendar_schedule_id = st.point_hour_schedule_id
8957 inner join (
8958 select 0 as is_weekend
8959 union select 1
8960 union select -1
8961 ) as part_of_week
8962 on sc.is_weekend = part_of_week.is_weekend
8963 or part_of_week.is_weekend = -1
8964 inner join (
8965 select period_offset
8966 from buffer_periods_824879560
8967 union select -1 as period_offset
8968 order by null
8969 ) as periods
8970 on sc.period_offset = periods.period_offset
8971 or periods.period_offset = -1
8972 group by
8973 sc.linkage_instance_id,
8974 ca.staff_id,
8975 part_of_week.is_weekend,
8976 periods.period_offset,
8977 sc.calendar_schedule_id
8978 having _scheduled > 0
8979 order by null
8980
8981INFO : (04-03 14:41:33) --> fill: 44 - Scheduler::AutoPopulate::Queries::Query10
8982 RuleSet Load (153.1ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
8983 Client Load (156.0ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
8984 RuleSet Load (154.0ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
8985 Client Load (155.9ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
8986 RuleSet Load (157.2ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
8987 Client Load (155.6ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
8988 RuleSet Load (153.2ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
8989 Client Load (155.7ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
8990 RuleSet Load (152.7ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
8991 Client Load (155.0ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
8992 RuleSet Load (158.8ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
8993 Client Load (156.7ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
8994 RuleSet Load (152.7ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
8995 Client Load (155.4ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
8996 RuleSet Load (164.5ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
8997 Client Load (156.6ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
8998 RuleSet Load (159.2ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
8999 Client Load (157.4ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
9000 RuleSet Load (154.9ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
9001 Client Load (156.6ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
9002 RuleSet Load (153.1ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
9003 Client Load (155.1ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
9004 RuleSet Load (164.4ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
9005 Client Load (156.2ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
9006 RuleSet Load (152.6ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
9007 Client Load (155.5ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
9008 RuleSet Load (164.1ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
9009 Client Load (158.6ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
9010 RuleSet Load (152.2ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
9011 Client Load (155.3ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
9012 RuleSet Load (162.3ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
9013 Client Load (155.6ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
9014 RuleSet Load (152.2ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
9015 Client Load (154.8ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
9016 RuleSet Load (154.9ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
9017 Client Load (155.8ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
9018 RuleSet Load (153.3ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
9019 Client Load (156.1ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
9020 RuleSet Load (162.2ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1528 LIMIT 1
9021 Client Load (155.3ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
9022 (153.9ms) /* SpecializationOverlapRule */
9023 delete ca
9024 from buffer_combined_availabilities_824879560 as ca use index (ix_buffer_combined_availabilities_composite_1)
9025 inner join buffer_schedules_824879560 as sc
9026 on ca.schedule_id = sc.id
9027 inner join buffer_staff_specializations_824879560 as ssp
9028 on ca.staff_id = ssp.staff_id
9029 inner join max_applicable_call_types as mact
9030 on ssp.specialization_id = mact.specialization_id
9031 and sc.call_type_id = mact.call_type_id
9032 inner join buffer_specialization_daily_counts_824879560 as sdc use index (ix_buffer_specialization_daily_counts_composite_1)
9033 on ssp.specialization_id = sdc.specialization_id
9034 and sc.schedule_on = sdc.schedule_on
9035 and sdc.staff_id is null
9036 left join buffer_specialization_daily_counts_824879560 as sdc_2 use index (ix_buffer_specialization_daily_counts_composite_1)
9037 on ssp.specialization_id = sdc_2.specialization_id
9038 and sc.schedule_on = sdc_2.schedule_on
9039 and ca.staff_id = sdc_2.staff_id
9040 where sdc.should_be_evaluated = 1
9041 and (sdc.staffs_scheduled + if(sdc_2.id is null, 1, 0)) > sdc.max_scheduled
9042
9043 (160.0ms) /* CumulativeWeeklyOverallTargetsRule */
9044 delete ca
9045 from
9046 buffer_combined_availabilities_824879560 as ca
9047 inner join buffer_schedules_824879560 as sc
9048 on ca.schedule_id = sc.id
9049 inner join buffer_linkage_targets_824879560 as lt
9050 on sc.linkage_instance_id = lt.linkage_instance_id
9051 and lt.is_weekend = -1
9052 and lt.period_offset = -1
9053 and sc.calendar_schedule_id = lt.calendar_schedule_id
9054 inner join buffer_current_oa_targets_824879560 as t
9055 on ca.staff_id = t.staff_id
9056 and t.is_weekend = -1
9057 and sc.calendar_schedule_id = t.calendar_schedule_id
9058 where (t.scheduled + lt.scheduled) > (round(t.adjusted_target /* raw_target | adjusted_target */, 2));
9059
9060 (173.1ms) /* CumulativeCallDaysTargetsRule */
9061 delete ca
9062 from
9063 buffer_combined_availabilities_824879560 as ca
9064 inner join buffer_schedules_824879560 as sc
9065 on ca.schedule_id = sc.id
9066 inner join buffer_target_assignments_824879560 as ta
9067 on sc.call_type_id = ta.call_type_id
9068 inner join buffer_linkage_call_days_targets_824879560 as lcdt
9069 on sc.linkage_instance_id = lcdt.linkage_instance_id
9070 and ta.assignment_id = lcdt.assignment_id
9071 and ta.assignment_type = lcdt.assignment_type
9072 and sc.day_of_week_mask = lcdt.day_of_week_mask
9073 and lcdt.period_offset = -1
9074 and sc.calendar_schedule_id = lcdt.calendar_schedule_id
9075 inner join buffer_cumulative_cd_targets_824879560 as cdt
9076 on ca.staff_id = cdt.staff_id
9077 and ta.assignment_id = cdt.assignment_id
9078 and ta.assignment_type = cdt.assignment_type
9079 and sc.day_of_week_mask = cdt.day_of_week_mask
9080 and sc.calendar_schedule_id = cdt.calendar_schedule_id
9081 where
9082 (sc.day_of_week_mask & 127 /* CumulativeCallDaysTargetsRule days_of_week_mask */) > 0
9083 and (cdt.scheduled + lcdt.scheduled) > (round(cdt.adjusted_target /* raw_target | adjusted_target */, 2));
9084
9085 (167.9ms) /* AnnualDayOfWeekMixRule */
9086 delete ca
9087 from
9088 buffer_combined_availabilities_824879560 as ca
9089 inner join buffer_schedules_824879560 as sc
9090 on ca.schedule_id = sc.id
9091 inner join buffer_linkage_dow_targets_824879560 as ldowt
9092 on sc.linkage_instance_id = ldowt.linkage_instance_id
9093 and (dayofweek(sc.schedule_on) - 1) = ldowt.wday
9094 and ldowt.period_offset = -1
9095 and sc.calendar_schedule_id = ldowt.calendar_schedule_id
9096 inner join buffer_cumulative_dow_targets_824879560 as dowt
9097 on ca.staff_id = dowt.staff_id
9098 and (dayofweek(sc.schedule_on) - 1) = dowt.wday
9099 and sc.calendar_schedule_id = dowt.calendar_schedule_id
9100 where
9101 (sc.day_of_week_mask & 127 /* AnnualDayOfWeekMixRule "days of week selection" */) > 0
9102 and (dowt.scheduled + ldowt.scheduled) > ceiling(round(dowt.adjusted_target /* raw_target | adjusted_target */, 2));
9103
9104 (161.1ms) /* CumulativeWeeklyHourTargetsRule */
9105 delete ca
9106 from
9107 buffer_combined_availabilities_824879560 as ca
9108 inner join buffer_schedules_824879560 as sc
9109 on ca.schedule_id = sc.id
9110 inner join buffer_linkage_hour_targets_824879560 as lht
9111 on sc.linkage_instance_id = lht.linkage_instance_id
9112 and ca.staff_id = lht.staff_id
9113 and lht.is_weekend = -1
9114 and lht.period_offset = -1
9115 and sc.calendar_schedule_id = lht.calendar_schedule_id
9116 inner join buffer_cumulative_hour_targets_824879560 as ht
9117 on ca.staff_id = ht.staff_id
9118 and ht.is_weekend = -1
9119 and sc.calendar_schedule_id = ht.calendar_schedule_id
9120 where (ht.scheduled + lht.scheduled) > (ht.adjusted_target /* raw_target | adjusted_target */ * (1 + 15 /* hours threshold */ / 100.0));
9121
9122 (157.3ms) /* CumulativeWeeklyPointTargetsRule */
9123 delete ca
9124 from
9125 buffer_combined_availabilities_824879560 as ca
9126 inner join buffer_schedules_824879560 as sc
9127 on ca.schedule_id = sc.id
9128 inner join buffer_linkage_point_targets_824879560 as lpt
9129 on sc.linkage_instance_id = lpt.linkage_instance_id
9130 and ca.staff_id = lpt.staff_id
9131 and lpt.is_weekend = -1
9132 and lpt.period_offset = -1
9133 and sc.calendar_schedule_id = lpt.calendar_schedule_id
9134 inner join buffer_cumulative_point_targets_824879560 as pt
9135 on ca.staff_id = pt.staff_id
9136 and pt.is_weekend = -1
9137 and sc.calendar_schedule_id = pt.calendar_schedule_id
9138 where (pt.scheduled + lpt.scheduled) > (pt.adjusted_target /* raw_target | adjusted_target */ * (1 + 10 /* points threshold */ / 100.0));
9139
9140 (165.7ms) delete ca
9141 from
9142 buffer_combined_availabilities_824879560 as ca
9143 inner join buffer_schedules_824879560 as sc
9144 on ca.schedule_id = sc.id
9145 inner join buffer_target_assignments_824879560 as ta
9146 on sc.call_type_id = ta.call_type_id
9147 inner join buffer_linkage_call_type_targets_824879560 as lctt
9148 on sc.linkage_instance_id = lctt.linkage_instance_id
9149 and ta.assignment_id = lctt.assignment_id
9150 and ta.assignment_type = lctt.assignment_type
9151 and sc.is_weekend = lctt.is_weekend
9152 and lctt.period_offset = -1
9153 and sc.calendar_schedule_id = lctt.calendar_schedule_id
9154 inner join buffer_cumulative_ct_targets_824879560 as ctt
9155 on ca.staff_id = ctt.staff_id
9156 and ta.assignment_id = ctt.assignment_id
9157 and ta.assignment_type = ctt.assignment_type
9158 and sc.is_weekend = ctt.is_weekend
9159 and sc.calendar_schedule_id = ctt.calendar_schedule_id
9160 where
9161 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
9162 and (ctt.scheduled + lctt.scheduled) > ceiling(round(ctt.adjusted_target /* raw_target | adjusted_target */, 2));
9163
9164 (153.7ms) delete ca
9165 from
9166 buffer_combined_availabilities_824879560 as ca
9167 inner join buffer_schedules_824879560 as sc
9168 on ca.schedule_id = sc.id
9169 inner join buffer_linkage_targets_824879560 as lt
9170 on sc.linkage_instance_id = lt.linkage_instance_id
9171 and sc.is_weekend = lt.is_weekend
9172 and lt.period_offset = -1
9173 and sc.calendar_schedule_id = lt.calendar_schedule_id
9174 inner join buffer_cumulative_oa_targets_824879560 as t
9175 on ca.staff_id = t.staff_id
9176 and sc.is_weekend = t.is_weekend
9177 and sc.calendar_schedule_id = t.calendar_schedule_id
9178 where
9179 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
9180 and (t.scheduled + lt.scheduled) > ceiling(round(t.adjusted_target /* raw_target | adjusted_target */, 2));
9181
9182 (158.2ms) /* CumulativeHourTargetsRule */
9183 delete ca
9184 from
9185 buffer_combined_availabilities_824879560 as ca
9186 inner join buffer_schedules_824879560 as sc
9187 on ca.schedule_id = sc.id
9188 inner join buffer_linkage_hour_targets_824879560 as lht
9189 on sc.linkage_instance_id = lht.linkage_instance_id
9190 and ca.staff_id = lht.staff_id
9191 and sc.is_weekend = lht.is_weekend
9192 and lht.period_offset = -1
9193 and sc.calendar_schedule_id = lht.calendar_schedule_id
9194 inner join buffer_cumulative_hour_targets_824879560 as ht
9195 on ca.staff_id = ht.staff_id
9196 and sc.is_weekend = ht.is_weekend
9197 and sc.calendar_schedule_id = ht.calendar_schedule_id
9198 where
9199 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
9200 and (ht.scheduled + lht.scheduled) > (ht.adjusted_target /* raw_target | adjusted_target */ * (1 + 0 /* hours threshold */ / 100.0))
9201
9202 (158.3ms) delete ca
9203 from
9204 buffer_combined_availabilities_824879560 as ca
9205 inner join buffer_schedules_824879560 as sc
9206 on ca.schedule_id = sc.id
9207 inner join buffer_linkage_point_targets_824879560 as lpt
9208 on sc.linkage_instance_id = lpt.linkage_instance_id
9209 and ca.staff_id = lpt.staff_id
9210 and sc.is_weekend = lpt.is_weekend
9211 and lpt.period_offset = -1
9212 and sc.calendar_schedule_id = lpt.calendar_schedule_id
9213 inner join buffer_cumulative_point_targets_824879560 as pt
9214 on ca.staff_id = pt.staff_id
9215 and sc.is_weekend = pt.is_weekend
9216 and sc.calendar_schedule_id = pt.calendar_schedule_id
9217 where
9218 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
9219 and (pt.scheduled + lpt.scheduled) > (pt.adjusted_target /* raw_target | adjusted_target */ * (1 + 0 /* hours threshold */ / 100.0));
9220
9221 (162.2ms) /* CurrentWeeklyCallTypeTargetsRule */
9222 delete ca
9223 from
9224 buffer_combined_availabilities_824879560 as ca
9225 inner join buffer_schedules_824879560 as sc
9226 on ca.schedule_id = sc.id
9227 inner join buffer_target_assignments_824879560 as ta
9228 on sc.call_type_id = ta.call_type_id
9229 inner join buffer_linkage_call_type_targets_824879560 as lctt
9230 on sc.linkage_instance_id = lctt.linkage_instance_id
9231 and ta.assignment_id = lctt.assignment_id
9232 and ta.assignment_type = lctt.assignment_type
9233 and lctt.is_weekend = -1
9234 and sc.period_offset = lctt.period_offset
9235 and sc.calendar_schedule_id = lctt.calendar_schedule_id
9236 inner join buffer_current_ct_targets_824879560 as ctt
9237 on ca.staff_id = ctt.staff_id
9238 and ta.assignment_id = ctt.assignment_id
9239 and ta.assignment_type = ctt.assignment_type
9240 and ctt.is_weekend = -1
9241 and sc.period_offset = ctt.period_offset
9242 and sc.calendar_schedule_id = ctt.calendar_schedule_id
9243 where (ctt.scheduled + lctt.scheduled) > ceiling(round(ctt.adjusted_target, 2));
9244
9245 (155.2ms) /* CurrentWeeklyOverallTargetsRule */
9246 delete ca
9247 from
9248 buffer_combined_availabilities_824879560 as ca
9249 inner join buffer_schedules_824879560 as sc
9250 on ca.schedule_id = sc.id
9251 inner join buffer_linkage_targets_824879560 as lt
9252 on sc.linkage_instance_id = lt.linkage_instance_id
9253 and lt.is_weekend = -1
9254 and sc.period_offset = lt.period_offset
9255 and sc.calendar_schedule_id = lt.calendar_schedule_id
9256 inner join buffer_current_oa_targets_824879560 as t
9257 on ca.staff_id = t.staff_id
9258 and t.is_weekend = -1
9259 and sc.period_offset = t.period_offset
9260 and sc.calendar_schedule_id = t.calendar_schedule_id
9261 where (t.scheduled + lt.scheduled) > (round(t.adjusted_target, 2));
9262
9263 (154.3ms) /* CurrentCallDaysTargetsRule */
9264 delete ca
9265 from
9266 buffer_combined_availabilities_824879560 as ca
9267 inner join buffer_schedules_824879560 as sc
9268 on ca.schedule_id = sc.id
9269 inner join buffer_target_assignments_824879560 as ta
9270 on sc.call_type_id = ta.call_type_id
9271 inner join buffer_linkage_call_days_targets_824879560 as lcdt
9272 on sc.linkage_instance_id = lcdt.linkage_instance_id
9273 and ta.assignment_id = lcdt.assignment_id
9274 and ta.assignment_type = lcdt.assignment_type
9275 and sc.day_of_week_mask = lcdt.day_of_week_mask
9276 and sc.period_offset = lcdt.period_offset
9277 and sc.calendar_schedule_id = lcdt.calendar_schedule_id
9278 inner join buffer_current_cd_targets_824879560 as cdt
9279 on ca.staff_id = cdt.staff_id
9280 and ta.assignment_id = cdt.assignment_id
9281 and ta.assignment_type = cdt.assignment_type
9282 and sc.day_of_week_mask = cdt.day_of_week_mask
9283 and sc.period_offset = cdt.period_offset
9284 and sc.calendar_schedule_id = cdt.calendar_schedule_id
9285 where
9286 (sc.day_of_week_mask & 127 /* CurrentCallDaysTargetsRule days_of_week_mask */) > 0
9287 and (cdt.scheduled + lcdt.scheduled) > ceiling(round(cdt.adjusted_target, 2));
9288
9289 (163.5ms) /* MonthlyDayOfWeekMixRule */
9290 delete ca
9291 from
9292 buffer_combined_availabilities_824879560 as ca
9293 inner join buffer_schedules_824879560 as sc
9294 on ca.schedule_id = sc.id
9295 inner join buffer_linkage_dow_targets_824879560 as ldowt
9296 on sc.linkage_instance_id = ldowt.linkage_instance_id
9297 and (dayofweek(sc.schedule_on) - 1) = ldowt.wday
9298 and sc.period_offset = ldowt.period_offset
9299 and sc.calendar_schedule_id = ldowt.calendar_schedule_id
9300 inner join buffer_current_dow_targets_824879560 as dowt
9301 on ca.staff_id = dowt.staff_id
9302 and (dayofweek(sc.schedule_on) - 1) = dowt.wday
9303 and sc.period_offset = dowt.period_offset
9304 and sc.calendar_schedule_id = dowt.calendar_schedule_id
9305 where
9306 (sc.day_of_week_mask & 127 /* MonthlyDayOfWeekMixRule "days of week selection" */) > 0
9307 and (dowt.scheduled + ldowt.scheduled) > (round(dowt.adjusted_target, 2));
9308
9309 (188.2ms) /* CurrentWeeklyHourTargetsRule */
9310 delete ca
9311 from
9312 buffer_combined_availabilities_824879560 as ca
9313 inner join buffer_schedules_824879560 as sc
9314 on ca.schedule_id = sc.id
9315 inner join buffer_linkage_hour_targets_824879560 as lht
9316 on sc.linkage_instance_id = lht.linkage_instance_id
9317 and ca.staff_id = lht.staff_id
9318 and lht.is_weekend = -1
9319 and sc.period_offset = lht.period_offset
9320 and sc.calendar_schedule_id = lht.calendar_schedule_id
9321 inner join buffer_current_hour_targets_824879560 as ht
9322 on ca.staff_id = ht.staff_id
9323 and ht.is_weekend = -1
9324 and sc.period_offset = ht.period_offset
9325 and sc.calendar_schedule_id = ht.calendar_schedule_id
9326 where (ht.scheduled + lht.scheduled) > (ht.adjusted_target * (1 + 5 /* hours threshold */ / 100.0));
9327
9328 (153.0ms) delete ca
9329 from
9330 buffer_combined_availabilities_824879560 as ca
9331 inner join buffer_schedules_824879560 as sc
9332 on ca.schedule_id = sc.id
9333 inner join buffer_linkage_point_targets_824879560 as lpt
9334 on sc.linkage_instance_id = lpt.linkage_instance_id
9335 and ca.staff_id = lpt.staff_id
9336 and lpt.is_weekend = -1
9337 and sc.period_offset = lpt.period_offset
9338 and sc.calendar_schedule_id = lpt.calendar_schedule_id
9339 inner join buffer_current_point_targets_824879560 as pt
9340 on ca.staff_id = pt.staff_id
9341 and pt.is_weekend = -1
9342 and sc.period_offset = pt.period_offset
9343 and sc.calendar_schedule_id = pt.calendar_schedule_id
9344 where (pt.scheduled + lpt.scheduled) > (pt.adjusted_target * (1 + 0 /* points threshold */ / 100.0));
9345
9346 (153.7ms) /* MonthlyCallMixRule */
9347 delete ca
9348 from
9349 buffer_combined_availabilities_824879560 as ca
9350 inner join buffer_schedules_824879560 as sc
9351 on ca.schedule_id = sc.id
9352 inner join buffer_target_assignments_824879560 as ta
9353 on sc.call_type_id = ta.call_type_id
9354 inner join buffer_linkage_call_type_targets_824879560 as lctt use index (ix_buffer_linkage_call_type_targets_composite_1)
9355 on sc.linkage_instance_id = lctt.linkage_instance_id
9356 and ta.assignment_id = lctt.assignment_id
9357 and ta.assignment_type = lctt.assignment_type
9358 and sc.is_weekend = lctt.is_weekend
9359 and sc.period_offset = lctt.period_offset
9360 and sc.calendar_schedule_id = lctt.calendar_schedule_id
9361 inner join buffer_current_ct_targets_824879560 as ctt
9362 on ca.staff_id = ctt.staff_id
9363 and ta.assignment_id = ctt.assignment_id
9364 and ta.assignment_type = ctt.assignment_type
9365 and sc.is_weekend = ctt.is_weekend
9366 and sc.period_offset = ctt.period_offset
9367 and sc.calendar_schedule_id = ctt.calendar_schedule_id
9368 where
9369 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
9370 and (ctt.scheduled + lctt.scheduled) > (round(ctt.adjusted_target, 2));
9371
9372 (153.6ms) /* StaffCapacityRule */
9373 delete ca
9374 from
9375 buffer_combined_availabilities_824879560 as ca
9376 inner join buffer_schedules_824879560 as sc
9377 on ca.schedule_id = sc.id
9378 inner join buffer_linkage_targets_824879560 as lt
9379 on sc.linkage_instance_id = lt.linkage_instance_id
9380 and sc.is_weekend = lt.is_weekend
9381 and sc.period_offset = lt.period_offset
9382 and sc.calendar_schedule_id = lt.calendar_schedule_id
9383 inner join buffer_current_oa_targets_824879560 as t
9384 on ca.staff_id = t.staff_id
9385 and sc.is_weekend = t.is_weekend
9386 and sc.period_offset = t.period_offset
9387 and sc.calendar_schedule_id = t.calendar_schedule_id
9388 where
9389 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
9390 and (t.scheduled + lt.scheduled) > ceiling(round(t.adjusted_target, 2));
9391
9392 (154.3ms) /* CurrentHourTargetsRule */
9393 delete ca
9394 from
9395 buffer_combined_availabilities_824879560 as ca
9396 inner join buffer_schedules_824879560 as sc
9397 on ca.schedule_id = sc.id
9398 inner join buffer_linkage_hour_targets_824879560 as lht
9399 on sc.linkage_instance_id = lht.linkage_instance_id
9400 and ca.staff_id = lht.staff_id
9401 and sc.is_weekend = lht.is_weekend
9402 and sc.period_offset = lht.period_offset
9403 and sc.calendar_schedule_id = lht.calendar_schedule_id
9404 inner join buffer_current_hour_targets_824879560 as ht
9405 on ca.staff_id = ht.staff_id
9406 and sc.is_weekend = ht.is_weekend
9407 and sc.period_offset = ht.period_offset
9408 and sc.calendar_schedule_id = ht.calendar_schedule_id
9409 where
9410 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
9411 and (ht.scheduled + lht.scheduled) > (ht.adjusted_target * (1 + 10 /* hours threshold */ / 100.0))
9412
9413 (153.1ms) delete ca
9414 from
9415 buffer_combined_availabilities_824879560 as ca
9416 inner join buffer_schedules_824879560 as sc
9417 on ca.schedule_id = sc.id
9418 inner join buffer_linkage_point_targets_824879560 as lpt
9419 on sc.linkage_instance_id = lpt.linkage_instance_id
9420 and ca.staff_id = lpt.staff_id
9421 and sc.is_weekend = lpt.is_weekend
9422 and sc.period_offset = lpt.period_offset
9423 and sc.calendar_schedule_id = lpt.calendar_schedule_id
9424 inner join buffer_current_point_targets_824879560 as pt
9425 on ca.staff_id = pt.staff_id
9426 and sc.is_weekend = pt.is_weekend
9427 and sc.period_offset = pt.period_offset
9428 and sc.calendar_schedule_id = pt.calendar_schedule_id
9429 where
9430 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
9431 and (pt.scheduled + lpt.scheduled) > (pt.adjusted_target * (1 + 10 /* points threshold */ / 100.0));
9432
9433 (153.5ms) delete ca
9434 from buffer_combined_availabilities_824879560 as ca
9435 inner join (
9436 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
9437 sum(lac.assignments_count) as assignments_count
9438 from (
9439 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
9440 from buffer_combined_availabilities_824879560 as ca
9441 inner join buffer_schedules_824879560 as sc
9442 on ca.schedule_id = sc.id
9443 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
9444 order by null
9445 ) as ca_sc
9446 inner join buffer_linkage_assignments_count_weeks_824879560 as lac
9447 on ca_sc.linkage_instance_id = lac.linkage_instance_id
9448 and ca_sc.schedule_on = lac.schedule_on
9449 inner join buffer_assignment_limit_staff_types_824879560 as alst
9450 on lac.assignment_limit_id = alst.assignment_limit_id
9451 and ca_sc.staff_type_id = alst.staff_type_id
9452 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
9453 order by null
9454 ) as lac
9455 on ca.linkage_instance_id = lac.linkage_instance_id
9456 and ca.staff_id = lac.staff_id
9457 inner join assignment_limits as al
9458 on lac.assignment_limit_id = al.id
9459 left join buffer_staff_assignments_count_weeks_824879560 as sac
9460 on lac.assignment_limit_id = sac.assignment_limit_id
9461 and lac.staff_id = sac.staff_id
9462 and lac.start_date = sac.start_date
9463 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_weekly_limit
9464
9465 (153.1ms) delete ca
9466 from buffer_combined_availabilities_824879560 as ca
9467 inner join (
9468 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
9469 sum(lac.assignments_count) as assignments_count
9470 from (
9471 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
9472 from buffer_combined_availabilities_824879560 as ca
9473 inner join buffer_schedules_824879560 as sc
9474 on ca.schedule_id = sc.id
9475 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
9476 order by null
9477 ) as ca_sc
9478 inner join buffer_linkage_assignments_count_periods_824879560 as lac
9479 on ca_sc.linkage_instance_id = lac.linkage_instance_id
9480 and ca_sc.schedule_on = lac.schedule_on
9481 inner join buffer_assignment_limit_staff_types_824879560 as alst
9482 on lac.assignment_limit_id = alst.assignment_limit_id
9483 and ca_sc.staff_type_id = alst.staff_type_id
9484 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
9485 order by null
9486 ) as lac
9487 on ca.linkage_instance_id = lac.linkage_instance_id
9488 and ca.staff_id = lac.staff_id
9489 inner join assignment_limits as al
9490 on lac.assignment_limit_id = al.id
9491 left join buffer_staff_assignments_count_periods_824879560 as sac
9492 on lac.assignment_limit_id = sac.assignment_limit_id
9493 and lac.staff_id = sac.staff_id
9494 and lac.start_date = sac.start_date
9495 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_per_period_limit
9496
9497 (153.1ms) delete ca
9498 from buffer_combined_availabilities_824879560 as ca
9499 inner join (
9500 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
9501 sum(lac.assignments_count) as assignments_count
9502 from (
9503 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
9504 from buffer_combined_availabilities_824879560 as ca
9505 inner join buffer_schedules_824879560 as sc
9506 on ca.schedule_id = sc.id
9507 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
9508 order by null
9509 ) as ca_sc
9510 inner join buffer_linkage_assignments_count_rolling_824879560 as lac
9511 on ca_sc.linkage_instance_id = lac.linkage_instance_id
9512 and ca_sc.schedule_on = lac.schedule_on
9513 inner join buffer_assignment_limit_staff_types_824879560 as alst
9514 on lac.assignment_limit_id = alst.assignment_limit_id
9515 and ca_sc.staff_type_id = alst.staff_type_id
9516 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
9517 order by null
9518 ) as lac
9519 on ca.linkage_instance_id = lac.linkage_instance_id
9520 and ca.staff_id = lac.staff_id
9521 inner join assignment_limits as al
9522 on lac.assignment_limit_id = al.id
9523 left join buffer_staff_assignments_count_rolling_824879560 as sac
9524 on lac.assignment_limit_id = sac.assignment_limit_id
9525 and lac.staff_id = sac.staff_id
9526 and lac.start_date = sac.start_date
9527 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_rolling_limit
9528
9529 (154.1ms) delete ca
9530 from buffer_combined_availabilities_824879560 as ca
9531 inner join (
9532 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
9533 count(distinct if(sac.id is null, lac.schedule_on, null)) as assignments_count
9534 from (
9535 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
9536 from buffer_combined_availabilities_824879560 as ca
9537 inner join buffer_schedules_824879560 as sc
9538 on ca.schedule_id = sc.id
9539 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
9540 order by null
9541 ) as ca_sc
9542 inner join buffer_linkage_assignments_count_consecutive_824879560 as lac
9543 on ca_sc.linkage_instance_id = lac.linkage_instance_id
9544 and ca_sc.schedule_on = lac.schedule_on
9545 inner join buffer_assignment_limit_staff_types_824879560 as alst
9546 on lac.assignment_limit_id = alst.assignment_limit_id
9547 and ca_sc.staff_type_id = alst.staff_type_id
9548 left join buffer_staff_assignments_count_consecutive_824879560 as sac
9549 on lac.assignment_limit_id = sac.assignment_limit_id
9550 and ca_sc.staff_id = sac.staff_id
9551 and lac.schedule_on = sac.schedule_on
9552 and lac.start_date = sac.start_date
9553 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
9554 order by null
9555 ) as lac
9556 on ca.linkage_instance_id = lac.linkage_instance_id
9557 and ca.staff_id = lac.staff_id
9558 inner join assignment_limits as al
9559 on lac.assignment_limit_id = al.id
9560 left join (
9561 select assignment_limit_id, staff_id, start_date,
9562 count(schedule_on) as assignments_count
9563 from buffer_staff_assignments_count_consecutive_824879560
9564 group by assignment_limit_id, staff_id, start_date
9565 ) as sac
9566 on lac.assignment_limit_id = sac.assignment_limit_id
9567 and lac.staff_id = sac.staff_id
9568 and lac.start_date = sac.start_date
9569 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_consecutive_limit
9570
9571 (156.0ms) /* CumulativeWeeklyCallTypeTargetsRule */
9572 delete ca
9573 from
9574 buffer_combined_availabilities_824879560 as ca
9575 inner join buffer_schedules_824879560 as sc
9576 on ca.schedule_id = sc.id
9577 inner join buffer_target_assignments_824879560 as ta
9578 on sc.call_type_id = ta.call_type_id
9579 inner join buffer_linkage_call_type_targets_824879560 as lctt
9580 on sc.linkage_instance_id = lctt.linkage_instance_id
9581 and ta.assignment_id = lctt.assignment_id
9582 and ta.assignment_type = lctt.assignment_type
9583 and lctt.is_weekend = -1
9584 and lctt.period_offset = -1
9585 and sc.calendar_schedule_id = lctt.calendar_schedule_id
9586 inner join buffer_cumulative_ct_targets_824879560 as ctt
9587 on ca.staff_id = ctt.staff_id
9588 and ta.assignment_id = ctt.assignment_id
9589 and ta.assignment_type = ctt.assignment_type
9590 and ctt.is_weekend = -1
9591 and sc.calendar_schedule_id = ctt.calendar_schedule_id
9592 where (ctt.scheduled + lctt.scheduled) > (round(ctt.adjusted_target /* raw_target | adjusted_target */, 2));
9593
9594 (153.9ms) /* MaxAssignmentsRule */
9595 delete ca
9596 from buffer_combined_availabilities_824879560 as ca
9597 inner join buffer_schedules_824879560 as sc
9598 on ca.schedule_id = sc.id
9599 inner join buffer_linkage_call_type_assignments_824879560 as lcta
9600 on sc.linkage_instance_id = lcta.linkage_instance_id
9601 and sc.call_type_id = lcta.call_type_id
9602 and sc.is_weekend = lcta.is_weekend
9603 and sc.period_offset = lcta.period_offset
9604 and sc.calendar_schedule_id = lcta.calendar_schedule_id
9605 left join buffer_call_type_assignments_824879560 as cta
9606 on ca.staff_id = cta.staff_id
9607 and sc.call_type_id = cta.call_type_id
9608 and sc.is_weekend = cta.is_weekend
9609 and sc.period_offset = cta.period_offset
9610 and sc.calendar_schedule_id = cta.calendar_schedule_id
9611 where
9612 sc.is_weekend in (NULL) /* "weekday (0), weekend (1)" checkboxes */
9613 and (coalesce(cta.assignments_count, 0) + lcta.assignments_count) > lcta.max_assignments;
9614
9615 (153.2ms) /* NegativeLinkRule */
9616 delete ca
9617 from buffer_combined_availabilities_824879560 as ca use index (ix_buffer_combined_availabilities_composite_1)
9618 inner join buffer_negative_relations_824879560 as nr use index (ix_buffer_negative_relations_composite_1)
9619 on ca.schedule_id = nr.schedule_id
9620 and ca.staff_id = nr.staff_id
9621
9622 (154.6ms) /* BrokenLinkageRule */
9623 truncate table buffer_combined_availability_linkages_824879560
9624
9625 (155.5ms) insert into buffer_combined_availability_linkages_824879560 (
9626 staff_id,
9627 linkage_instance_id,
9628 slots_count,
9629 is_primary,
9630 has_violations
9631 )
9632 select
9633 staff_id,
9634 linkage_instance_id,
9635 count(1) as slots_count,
9636 min(is_primary) as is_primary,
9637 max(has_violations) as has_violations
9638 from buffer_combined_availabilities_824879560 use index (ix_buffer_combined_availabilities_composite_2)
9639 group by
9640 staff_id,
9641 linkage_instance_id
9642 order by null
9643
9644 (153.1ms) delete ca
9645 from
9646 buffer_combined_availabilities_824879560 as ca use index (ix_buffer_combined_availabilities_composite_1)
9647 inner join buffer_schedules_824879560 as sc
9648 on ca.schedule_id = sc.id
9649 inner join buffer_linkages_824879560 as l
9650 on sc.linkage_instance_id = l.linkage_instance_id
9651 inner join buffer_combined_availability_linkages_824879560 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
9652 on ca.staff_id = ls_1.staff_id
9653 and sc.linkage_instance_id = ls_1.linkage_instance_id
9654 left join buffer_schedule_linkages_824879560 as ls_2 use index (ix_buffer_schedule_linkages_composite_1)
9655 on ca.staff_id = ls_2.staff_id
9656 and sc.linkage_instance_id = ls_2.linkage_instance_id
9657 where (ls_1.slots_count + coalesce(ls_2.slots_count, 0)) < l.slots_count_total /* not covering the whole chain */;
9658
9659INFO : (04-03 14:41:44) --> fill: 45 - Scheduler::AutoPopulate::Queries::QueryScore02
9660INFO : (04-03 14:41:44) --> fill: 46 - Scheduler::AutoPopulate::Queries::QueryScore03
9661INFO : (04-03 14:41:44) --> fill: 47 - Scheduler::AutoPopulate::Queries::QueryScore04
9662INFO : (04-03 14:41:44) --> fill: 48 - Scheduler::AutoPopulate::Queries::Query11
9663 (155.9ms) update buffer_schedules_824879560 as sc
9664 left join buffer_combined_availabilities_824879560 as ca
9665 on sc.id = ca.schedule_id
9666 set sc.should_be_evaluated = 0,
9667 sc.should_be_populated = 0
9668 where sc.should_be_evaluated = 1
9669 and ca.id is null
9670
9671INFO : (04-03 14:41:44) --> fill: 49 - Scheduler::AutoPopulate::Queries::DropTables
9672INFO : (04-03 14:41:44) Setting up lists...
9673 (155.0ms) select b_schedules.schedule_on, b_schedules.call_type_id, b_schedules.linkage_instance_id, schedules.id as schedule_id
9674 from buffer_schedules_824879560 as b_schedules
9675 left join schedules
9676 on schedules.client_id = 6
9677 and schedules.call_type_id = b_schedules.call_type_id
9678 and schedules.schedule_on = b_schedules.schedule_on
9679 where b_schedules.linkage_instance_id != -1
9680 order by b_schedules.linkage_instance_id, b_schedules.schedule_on
9681
9682INFO : (04-03 14:41:44) Begin to populate. Pre-set: 0. Unscheduled: 128.
9683INFO : (04-03 14:41:44) plan unit: [id:201740] [2017-10-01 - OR]
9684INFO : (04-03 14:41:44) plan unit: [id:201741] [2017-10-08 - OR]
9685INFO : (04-03 14:41:44) plan unit: [id:201742] [2017-10-15 - OR]
9686INFO : (04-03 14:41:44) plan unit: [id:201743] [2017-10-22 - OR]
9687INFO : (04-03 14:41:44) plan unit: [id:201744] [2017-10-29 - OR]
9688INFO : (04-03 14:41:44) plan unit: [id:1201740] [2017-10-01 - OB]
9689INFO : (04-03 14:41:44) plan unit: [id:1201741] [2017-10-08 - OB]
9690INFO : (04-03 14:41:44) plan unit: [id:1201742] [2017-10-15 - OB]
9691INFO : (04-03 14:41:44) plan unit: [id:1201743] [2017-10-22 - OB]
9692INFO : (04-03 14:41:44) plan unit: [id:1201744] [2017-10-29 - OB]
9693INFO : (04-03 14:41:44) plan unit: [id:2201740] [2017-10-02 - OR]
9694INFO : (04-03 14:41:44) plan unit: [id:2201741] [2017-10-09 - OR]
9695INFO : (04-03 14:41:44) plan unit: [id:2201742] [2017-10-16 - OR]
9696INFO : (04-03 14:41:44) plan unit: [id:2201743] [2017-10-23 - OR]
9697INFO : (04-03 14:41:44) plan unit: [id:2201744] [2017-10-30 - OR]
9698INFO : (04-03 14:41:44) plan unit: [id:3201740] [2017-10-02 - BU]
9699INFO : (04-03 14:41:44) plan unit: [id:3201741] [2017-10-09 - BU]
9700INFO : (04-03 14:41:44) plan unit: [id:3201742] [2017-10-16 - BU]
9701INFO : (04-03 14:41:44) plan unit: [id:3201743] [2017-10-23 - BU]
9702INFO : (04-03 14:41:44) plan unit: [id:3201744] [2017-10-30 - BU]
9703INFO : (04-03 14:41:44) plan unit: [id:4201740] [2017-10-02 - OB]
9704INFO : (04-03 14:41:44) plan unit: [id:4201741] [2017-10-09 - OB]
9705INFO : (04-03 14:41:44) plan unit: [id:4201742] [2017-10-16 - OB]
9706INFO : (04-03 14:41:44) plan unit: [id:4201743] [2017-10-23 - OB]
9707INFO : (04-03 14:41:44) plan unit: [id:4201744] [2017-10-30 - OB]
9708INFO : (04-03 14:41:44) plan unit: [id:5201740] [2017-10-02 - GI1]
9709INFO : (04-03 14:41:44) plan unit: [id:5201741] [2017-10-09 - GI1]
9710INFO : (04-03 14:41:44) plan unit: [id:5201742] [2017-10-16 - GI1]
9711INFO : (04-03 14:41:44) plan unit: [id:5201743] [2017-10-23 - GI1]
9712INFO : (04-03 14:41:44) plan unit: [id:5201744] [2017-10-30 - GI1]
9713INFO : (04-03 14:41:44) plan unit: [id:6201740] [2017-10-02 - PR]
9714INFO : (04-03 14:41:44) plan unit: [id:6201741] [2017-10-09 - PR]
9715INFO : (04-03 14:41:44) plan unit: [id:6201742] [2017-10-16 - PR]
9716INFO : (04-03 14:41:44) plan unit: [id:6201743] [2017-10-23 - PR]
9717INFO : (04-03 14:41:44) plan unit: [id:6201744] [2017-10-30 - PR]
9718INFO : (04-03 14:41:44) plan unit: [id:11201740] [2017-10-03 - OR]
9719INFO : (04-03 14:41:44) plan unit: [id:11201741] [2017-10-10 - OR]
9720INFO : (04-03 14:41:44) plan unit: [id:11201742] [2017-10-17 - OR]
9721INFO : (04-03 14:41:44) plan unit: [id:11201743] [2017-10-24 - OR]
9722INFO : (04-03 14:41:44) plan unit: [id:11201744] [2017-10-31 - OR]
9723INFO : (04-03 14:41:44) plan unit: [id:12201740] [2017-10-03 - BU]
9724INFO : (04-03 14:41:44) plan unit: [id:12201741] [2017-10-10 - BU]
9725INFO : (04-03 14:41:44) plan unit: [id:12201742] [2017-10-17 - BU]
9726INFO : (04-03 14:41:44) plan unit: [id:12201743] [2017-10-24 - BU]
9727INFO : (04-03 14:41:44) plan unit: [id:12201744] [2017-10-31 - BU]
9728INFO : (04-03 14:41:44) plan unit: [id:13201740] [2017-10-03 - OB]
9729INFO : (04-03 14:41:44) plan unit: [id:13201741] [2017-10-10 - OB]
9730INFO : (04-03 14:41:44) plan unit: [id:13201742] [2017-10-17 - OB]
9731INFO : (04-03 14:41:44) plan unit: [id:13201743] [2017-10-24 - OB]
9732INFO : (04-03 14:41:44) plan unit: [id:13201744] [2017-10-31 - OB]
9733INFO : (04-03 14:41:44) plan unit: [id:14201740] [2017-10-03 - GI1]
9734INFO : (04-03 14:41:44) plan unit: [id:14201741] [2017-10-10 - GI1]
9735INFO : (04-03 14:41:44) plan unit: [id:14201742] [2017-10-17 - GI1]
9736INFO : (04-03 14:41:44) plan unit: [id:14201743] [2017-10-24 - GI1]
9737INFO : (04-03 14:41:44) plan unit: [id:14201744] [2017-10-31 - GI1]
9738INFO : (04-03 14:41:44) plan unit: [id:15201740] [2017-10-03 - PR]
9739INFO : (04-03 14:41:44) plan unit: [id:15201741] [2017-10-10 - PR]
9740INFO : (04-03 14:41:44) plan unit: [id:15201742] [2017-10-17 - PR]
9741INFO : (04-03 14:41:44) plan unit: [id:15201743] [2017-10-24 - PR]
9742INFO : (04-03 14:41:44) plan unit: [id:15201744] [2017-10-31 - PR]
9743INFO : (04-03 14:41:44) plan unit: [id:20201740] [2017-10-04 - OR]
9744INFO : (04-03 14:41:44) plan unit: [id:20201741] [2017-10-11 - OR]
9745INFO : (04-03 14:41:44) plan unit: [id:20201742] [2017-10-18 - OR]
9746INFO : (04-03 14:41:44) plan unit: [id:20201743] [2017-10-25 - OR]
9747INFO : (04-03 14:41:44) plan unit: [id:21201740] [2017-10-04 - BU]
9748INFO : (04-03 14:41:44) plan unit: [id:21201741] [2017-10-11 - BU]
9749INFO : (04-03 14:41:44) plan unit: [id:21201742] [2017-10-18 - BU]
9750INFO : (04-03 14:41:44) plan unit: [id:21201743] [2017-10-25 - BU]
9751INFO : (04-03 14:41:44) plan unit: [id:22201740] [2017-10-04 - OB]
9752INFO : (04-03 14:41:44) plan unit: [id:22201741] [2017-10-11 - OB]
9753INFO : (04-03 14:41:44) plan unit: [id:22201742] [2017-10-18 - OB]
9754INFO : (04-03 14:41:44) plan unit: [id:22201743] [2017-10-25 - OB]
9755INFO : (04-03 14:41:44) plan unit: [id:23201740] [2017-10-04 - GI1]
9756INFO : (04-03 14:41:44) plan unit: [id:23201741] [2017-10-11 - GI1]
9757INFO : (04-03 14:41:44) plan unit: [id:23201742] [2017-10-18 - GI1]
9758INFO : (04-03 14:41:44) plan unit: [id:23201743] [2017-10-25 - GI1]
9759INFO : (04-03 14:41:44) plan unit: [id:24201740] [2017-10-04 - PR]
9760INFO : (04-03 14:41:44) plan unit: [id:24201741] [2017-10-11 - PR]
9761INFO : (04-03 14:41:44) plan unit: [id:24201742] [2017-10-18 - PR]
9762INFO : (04-03 14:41:44) plan unit: [id:24201743] [2017-10-25 - PR]
9763INFO : (04-03 14:41:44) plan unit: [id:29201740] [2017-10-05 - OR]
9764INFO : (04-03 14:41:44) plan unit: [id:29201741] [2017-10-12 - OR]
9765INFO : (04-03 14:41:44) plan unit: [id:29201742] [2017-10-19 - OR]
9766INFO : (04-03 14:41:44) plan unit: [id:29201743] [2017-10-26 - OR]
9767INFO : (04-03 14:41:44) plan unit: [id:30201740] [2017-10-05 - BU]
9768INFO : (04-03 14:41:44) plan unit: [id:30201741] [2017-10-12 - BU]
9769INFO : (04-03 14:41:44) plan unit: [id:30201742] [2017-10-19 - BU]
9770INFO : (04-03 14:41:44) plan unit: [id:30201743] [2017-10-26 - BU]
9771INFO : (04-03 14:41:44) plan unit: [id:31201740] [2017-10-05 - OB]
9772INFO : (04-03 14:41:44) plan unit: [id:31201741] [2017-10-12 - OB]
9773INFO : (04-03 14:41:44) plan unit: [id:31201742] [2017-10-19 - OB]
9774INFO : (04-03 14:41:44) plan unit: [id:31201743] [2017-10-26 - OB]
9775INFO : (04-03 14:41:44) plan unit: [id:32201740] [2017-10-05 - GI1]
9776INFO : (04-03 14:41:44) plan unit: [id:32201741] [2017-10-12 - GI1]
9777INFO : (04-03 14:41:44) plan unit: [id:32201742] [2017-10-19 - GI1]
9778INFO : (04-03 14:41:44) plan unit: [id:32201743] [2017-10-26 - GI1]
9779INFO : (04-03 14:41:44) plan unit: [id:33201740] [2017-10-05 - PR]
9780INFO : (04-03 14:41:44) plan unit: [id:33201741] [2017-10-12 - PR]
9781INFO : (04-03 14:41:44) plan unit: [id:33201742] [2017-10-19 - PR]
9782INFO : (04-03 14:41:44) plan unit: [id:33201743] [2017-10-26 - PR]
9783INFO : (04-03 14:41:44) plan unit: [id:38201740] [2017-10-06 - OR]
9784INFO : (04-03 14:41:44) plan unit: [id:38201741] [2017-10-13 - OR]
9785INFO : (04-03 14:41:44) plan unit: [id:38201742] [2017-10-20 - OR]
9786INFO : (04-03 14:41:44) plan unit: [id:38201743] [2017-10-27 - OR]
9787INFO : (04-03 14:41:44) plan unit: [id:39201740] [2017-10-06 - BU]
9788INFO : (04-03 14:41:44) plan unit: [id:39201741] [2017-10-13 - BU]
9789INFO : (04-03 14:41:44) plan unit: [id:39201742] [2017-10-20 - BU]
9790INFO : (04-03 14:41:44) plan unit: [id:39201743] [2017-10-27 - BU]
9791INFO : (04-03 14:41:44) plan unit: [id:40201740] [2017-10-06 - OB]
9792INFO : (04-03 14:41:44) plan unit: [id:40201741] [2017-10-13 - OB]
9793INFO : (04-03 14:41:44) plan unit: [id:40201742] [2017-10-20 - OB]
9794INFO : (04-03 14:41:44) plan unit: [id:40201743] [2017-10-27 - OB]
9795INFO : (04-03 14:41:44) plan unit: [id:41201740] [2017-10-06 - GI1]
9796INFO : (04-03 14:41:44) plan unit: [id:41201741] [2017-10-13 - GI1]
9797INFO : (04-03 14:41:44) plan unit: [id:41201742] [2017-10-20 - GI1]
9798INFO : (04-03 14:41:44) plan unit: [id:41201743] [2017-10-27 - GI1]
9799INFO : (04-03 14:41:44) plan unit: [id:42201740] [2017-10-06 - PR]
9800INFO : (04-03 14:41:44) plan unit: [id:42201741] [2017-10-13 - PR]
9801INFO : (04-03 14:41:44) plan unit: [id:42201742] [2017-10-20 - PR]
9802INFO : (04-03 14:41:44) plan unit: [id:42201743] [2017-10-27 - PR]
9803INFO : (04-03 14:41:44) plan unit: [id:47201740] [2017-10-07 - OR]
9804INFO : (04-03 14:41:44) plan unit: [id:47201741] [2017-10-14 - OR]
9805INFO : (04-03 14:41:44) plan unit: [id:47201742] [2017-10-21 - OR]
9806INFO : (04-03 14:41:44) plan unit: [id:47201743] [2017-10-28 - OR]
9807INFO : (04-03 14:41:44) plan unit: [id:48201740] [2017-10-07 - OB]
9808INFO : (04-03 14:41:44) plan unit: [id:48201741] [2017-10-14 - OB]
9809INFO : (04-03 14:41:44) plan unit: [id:48201742] [2017-10-21 - OB]
9810INFO : (04-03 14:41:44) plan unit: [id:48201743] [2017-10-28 - OB]
9811 NegativeLink Load (153.5ms) SELECT `negative_links`.* FROM `negative_links` WHERE `negative_links`.`client_id` = 6
9812 (153.4ms) /* SpecializationOverlapRule */
9813 delete ca
9814 from buffer_combined_availabilities_824879560 as ca use index (ix_buffer_combined_availabilities_composite_1)
9815 inner join buffer_schedules_824879560 as sc
9816 on ca.schedule_id = sc.id
9817 inner join buffer_staff_specializations_824879560 as ssp
9818 on ca.staff_id = ssp.staff_id
9819 inner join max_applicable_call_types as mact
9820 on ssp.specialization_id = mact.specialization_id
9821 and sc.call_type_id = mact.call_type_id
9822 inner join buffer_specialization_daily_counts_824879560 as sdc use index (ix_buffer_specialization_daily_counts_composite_1)
9823 on ssp.specialization_id = sdc.specialization_id
9824 and sc.schedule_on = sdc.schedule_on
9825 and sdc.staff_id is null
9826 left join buffer_specialization_daily_counts_824879560 as sdc_2 use index (ix_buffer_specialization_daily_counts_composite_1)
9827 on ssp.specialization_id = sdc_2.specialization_id
9828 and sc.schedule_on = sdc_2.schedule_on
9829 and ca.staff_id = sdc_2.staff_id
9830 where sdc.should_be_evaluated = 1
9831 and (sdc.staffs_scheduled + if(sdc_2.id is null, 1, 0)) > sdc.max_scheduled
9832
9833 (152.9ms) /* CumulativeWeeklyOverallTargetsRule */
9834 delete ca
9835 from
9836 buffer_combined_availabilities_824879560 as ca
9837 inner join buffer_schedules_824879560 as sc
9838 on ca.schedule_id = sc.id
9839 inner join buffer_linkage_targets_824879560 as lt
9840 on sc.linkage_instance_id = lt.linkage_instance_id
9841 and lt.is_weekend = -1
9842 and lt.period_offset = -1
9843 and sc.calendar_schedule_id = lt.calendar_schedule_id
9844 inner join buffer_current_oa_targets_824879560 as t
9845 on ca.staff_id = t.staff_id
9846 and t.is_weekend = -1
9847 and sc.calendar_schedule_id = t.calendar_schedule_id
9848 where (t.scheduled + lt.scheduled) > (round(t.adjusted_target /* raw_target | adjusted_target */, 2));
9849
9850 (153.6ms) /* CumulativeCallDaysTargetsRule */
9851 delete ca
9852 from
9853 buffer_combined_availabilities_824879560 as ca
9854 inner join buffer_schedules_824879560 as sc
9855 on ca.schedule_id = sc.id
9856 inner join buffer_target_assignments_824879560 as ta
9857 on sc.call_type_id = ta.call_type_id
9858 inner join buffer_linkage_call_days_targets_824879560 as lcdt
9859 on sc.linkage_instance_id = lcdt.linkage_instance_id
9860 and ta.assignment_id = lcdt.assignment_id
9861 and ta.assignment_type = lcdt.assignment_type
9862 and sc.day_of_week_mask = lcdt.day_of_week_mask
9863 and lcdt.period_offset = -1
9864 and sc.calendar_schedule_id = lcdt.calendar_schedule_id
9865 inner join buffer_cumulative_cd_targets_824879560 as cdt
9866 on ca.staff_id = cdt.staff_id
9867 and ta.assignment_id = cdt.assignment_id
9868 and ta.assignment_type = cdt.assignment_type
9869 and sc.day_of_week_mask = cdt.day_of_week_mask
9870 and sc.calendar_schedule_id = cdt.calendar_schedule_id
9871 where
9872 (sc.day_of_week_mask & 127 /* CumulativeCallDaysTargetsRule days_of_week_mask */) > 0
9873 and (cdt.scheduled + lcdt.scheduled) > (round(cdt.adjusted_target /* raw_target | adjusted_target */, 2));
9874
9875 (153.1ms) /* AnnualDayOfWeekMixRule */
9876 delete ca
9877 from
9878 buffer_combined_availabilities_824879560 as ca
9879 inner join buffer_schedules_824879560 as sc
9880 on ca.schedule_id = sc.id
9881 inner join buffer_linkage_dow_targets_824879560 as ldowt
9882 on sc.linkage_instance_id = ldowt.linkage_instance_id
9883 and (dayofweek(sc.schedule_on) - 1) = ldowt.wday
9884 and ldowt.period_offset = -1
9885 and sc.calendar_schedule_id = ldowt.calendar_schedule_id
9886 inner join buffer_cumulative_dow_targets_824879560 as dowt
9887 on ca.staff_id = dowt.staff_id
9888 and (dayofweek(sc.schedule_on) - 1) = dowt.wday
9889 and sc.calendar_schedule_id = dowt.calendar_schedule_id
9890 where
9891 (sc.day_of_week_mask & 127 /* AnnualDayOfWeekMixRule "days of week selection" */) > 0
9892 and (dowt.scheduled + ldowt.scheduled) > ceiling(round(dowt.adjusted_target /* raw_target | adjusted_target */, 2));
9893
9894 (301.5ms) /* CumulativeWeeklyHourTargetsRule */
9895 delete ca
9896 from
9897 buffer_combined_availabilities_824879560 as ca
9898 inner join buffer_schedules_824879560 as sc
9899 on ca.schedule_id = sc.id
9900 inner join buffer_linkage_hour_targets_824879560 as lht
9901 on sc.linkage_instance_id = lht.linkage_instance_id
9902 and ca.staff_id = lht.staff_id
9903 and lht.is_weekend = -1
9904 and lht.period_offset = -1
9905 and sc.calendar_schedule_id = lht.calendar_schedule_id
9906 inner join buffer_cumulative_hour_targets_824879560 as ht
9907 on ca.staff_id = ht.staff_id
9908 and ht.is_weekend = -1
9909 and sc.calendar_schedule_id = ht.calendar_schedule_id
9910 where (ht.scheduled + lht.scheduled) > (ht.adjusted_target /* raw_target | adjusted_target */ * (1 + 15 /* hours threshold */ / 100.0));
9911
9912 (154.0ms) /* CumulativeWeeklyPointTargetsRule */
9913 delete ca
9914 from
9915 buffer_combined_availabilities_824879560 as ca
9916 inner join buffer_schedules_824879560 as sc
9917 on ca.schedule_id = sc.id
9918 inner join buffer_linkage_point_targets_824879560 as lpt
9919 on sc.linkage_instance_id = lpt.linkage_instance_id
9920 and ca.staff_id = lpt.staff_id
9921 and lpt.is_weekend = -1
9922 and lpt.period_offset = -1
9923 and sc.calendar_schedule_id = lpt.calendar_schedule_id
9924 inner join buffer_cumulative_point_targets_824879560 as pt
9925 on ca.staff_id = pt.staff_id
9926 and pt.is_weekend = -1
9927 and sc.calendar_schedule_id = pt.calendar_schedule_id
9928 where (pt.scheduled + lpt.scheduled) > (pt.adjusted_target /* raw_target | adjusted_target */ * (1 + 10 /* points threshold */ / 100.0));
9929
9930 (154.2ms) delete ca
9931 from
9932 buffer_combined_availabilities_824879560 as ca
9933 inner join buffer_schedules_824879560 as sc
9934 on ca.schedule_id = sc.id
9935 inner join buffer_target_assignments_824879560 as ta
9936 on sc.call_type_id = ta.call_type_id
9937 inner join buffer_linkage_call_type_targets_824879560 as lctt
9938 on sc.linkage_instance_id = lctt.linkage_instance_id
9939 and ta.assignment_id = lctt.assignment_id
9940 and ta.assignment_type = lctt.assignment_type
9941 and sc.is_weekend = lctt.is_weekend
9942 and lctt.period_offset = -1
9943 and sc.calendar_schedule_id = lctt.calendar_schedule_id
9944 inner join buffer_cumulative_ct_targets_824879560 as ctt
9945 on ca.staff_id = ctt.staff_id
9946 and ta.assignment_id = ctt.assignment_id
9947 and ta.assignment_type = ctt.assignment_type
9948 and sc.is_weekend = ctt.is_weekend
9949 and sc.calendar_schedule_id = ctt.calendar_schedule_id
9950 where
9951 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
9952 and (ctt.scheduled + lctt.scheduled) > ceiling(round(ctt.adjusted_target /* raw_target | adjusted_target */, 2));
9953
9954 (302.3ms) delete ca
9955 from
9956 buffer_combined_availabilities_824879560 as ca
9957 inner join buffer_schedules_824879560 as sc
9958 on ca.schedule_id = sc.id
9959 inner join buffer_linkage_targets_824879560 as lt
9960 on sc.linkage_instance_id = lt.linkage_instance_id
9961 and sc.is_weekend = lt.is_weekend
9962 and lt.period_offset = -1
9963 and sc.calendar_schedule_id = lt.calendar_schedule_id
9964 inner join buffer_cumulative_oa_targets_824879560 as t
9965 on ca.staff_id = t.staff_id
9966 and sc.is_weekend = t.is_weekend
9967 and sc.calendar_schedule_id = t.calendar_schedule_id
9968 where
9969 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
9970 and (t.scheduled + lt.scheduled) > ceiling(round(t.adjusted_target /* raw_target | adjusted_target */, 2));
9971
9972 (155.9ms) /* CumulativeHourTargetsRule */
9973 delete ca
9974 from
9975 buffer_combined_availabilities_824879560 as ca
9976 inner join buffer_schedules_824879560 as sc
9977 on ca.schedule_id = sc.id
9978 inner join buffer_linkage_hour_targets_824879560 as lht
9979 on sc.linkage_instance_id = lht.linkage_instance_id
9980 and ca.staff_id = lht.staff_id
9981 and sc.is_weekend = lht.is_weekend
9982 and lht.period_offset = -1
9983 and sc.calendar_schedule_id = lht.calendar_schedule_id
9984 inner join buffer_cumulative_hour_targets_824879560 as ht
9985 on ca.staff_id = ht.staff_id
9986 and sc.is_weekend = ht.is_weekend
9987 and sc.calendar_schedule_id = ht.calendar_schedule_id
9988 where
9989 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
9990 and (ht.scheduled + lht.scheduled) > (ht.adjusted_target /* raw_target | adjusted_target */ * (1 + 0 /* hours threshold */ / 100.0))
9991
9992 (153.6ms) delete ca
9993 from
9994 buffer_combined_availabilities_824879560 as ca
9995 inner join buffer_schedules_824879560 as sc
9996 on ca.schedule_id = sc.id
9997 inner join buffer_linkage_point_targets_824879560 as lpt
9998 on sc.linkage_instance_id = lpt.linkage_instance_id
9999 and ca.staff_id = lpt.staff_id
10000 and sc.is_weekend = lpt.is_weekend
10001 and lpt.period_offset = -1
10002 and sc.calendar_schedule_id = lpt.calendar_schedule_id
10003 inner join buffer_cumulative_point_targets_824879560 as pt
10004 on ca.staff_id = pt.staff_id
10005 and sc.is_weekend = pt.is_weekend
10006 and sc.calendar_schedule_id = pt.calendar_schedule_id
10007 where
10008 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
10009 and (pt.scheduled + lpt.scheduled) > (pt.adjusted_target /* raw_target | adjusted_target */ * (1 + 0 /* hours threshold */ / 100.0));
10010
10011 (153.7ms) /* CurrentWeeklyCallTypeTargetsRule */
10012 delete ca
10013 from
10014 buffer_combined_availabilities_824879560 as ca
10015 inner join buffer_schedules_824879560 as sc
10016 on ca.schedule_id = sc.id
10017 inner join buffer_target_assignments_824879560 as ta
10018 on sc.call_type_id = ta.call_type_id
10019 inner join buffer_linkage_call_type_targets_824879560 as lctt
10020 on sc.linkage_instance_id = lctt.linkage_instance_id
10021 and ta.assignment_id = lctt.assignment_id
10022 and ta.assignment_type = lctt.assignment_type
10023 and lctt.is_weekend = -1
10024 and sc.period_offset = lctt.period_offset
10025 and sc.calendar_schedule_id = lctt.calendar_schedule_id
10026 inner join buffer_current_ct_targets_824879560 as ctt
10027 on ca.staff_id = ctt.staff_id
10028 and ta.assignment_id = ctt.assignment_id
10029 and ta.assignment_type = ctt.assignment_type
10030 and ctt.is_weekend = -1
10031 and sc.period_offset = ctt.period_offset
10032 and sc.calendar_schedule_id = ctt.calendar_schedule_id
10033 where (ctt.scheduled + lctt.scheduled) > ceiling(round(ctt.adjusted_target, 2));
10034
10035 (152.8ms) /* CurrentWeeklyOverallTargetsRule */
10036 delete ca
10037 from
10038 buffer_combined_availabilities_824879560 as ca
10039 inner join buffer_schedules_824879560 as sc
10040 on ca.schedule_id = sc.id
10041 inner join buffer_linkage_targets_824879560 as lt
10042 on sc.linkage_instance_id = lt.linkage_instance_id
10043 and lt.is_weekend = -1
10044 and sc.period_offset = lt.period_offset
10045 and sc.calendar_schedule_id = lt.calendar_schedule_id
10046 inner join buffer_current_oa_targets_824879560 as t
10047 on ca.staff_id = t.staff_id
10048 and t.is_weekend = -1
10049 and sc.period_offset = t.period_offset
10050 and sc.calendar_schedule_id = t.calendar_schedule_id
10051 where (t.scheduled + lt.scheduled) > (round(t.adjusted_target, 2));
10052
10053 (153.7ms) /* CurrentCallDaysTargetsRule */
10054 delete ca
10055 from
10056 buffer_combined_availabilities_824879560 as ca
10057 inner join buffer_schedules_824879560 as sc
10058 on ca.schedule_id = sc.id
10059 inner join buffer_target_assignments_824879560 as ta
10060 on sc.call_type_id = ta.call_type_id
10061 inner join buffer_linkage_call_days_targets_824879560 as lcdt
10062 on sc.linkage_instance_id = lcdt.linkage_instance_id
10063 and ta.assignment_id = lcdt.assignment_id
10064 and ta.assignment_type = lcdt.assignment_type
10065 and sc.day_of_week_mask = lcdt.day_of_week_mask
10066 and sc.period_offset = lcdt.period_offset
10067 and sc.calendar_schedule_id = lcdt.calendar_schedule_id
10068 inner join buffer_current_cd_targets_824879560 as cdt
10069 on ca.staff_id = cdt.staff_id
10070 and ta.assignment_id = cdt.assignment_id
10071 and ta.assignment_type = cdt.assignment_type
10072 and sc.day_of_week_mask = cdt.day_of_week_mask
10073 and sc.period_offset = cdt.period_offset
10074 and sc.calendar_schedule_id = cdt.calendar_schedule_id
10075 where
10076 (sc.day_of_week_mask & 127 /* CurrentCallDaysTargetsRule days_of_week_mask */) > 0
10077 and (cdt.scheduled + lcdt.scheduled) > ceiling(round(cdt.adjusted_target, 2));
10078
10079 (153.1ms) /* MonthlyDayOfWeekMixRule */
10080 delete ca
10081 from
10082 buffer_combined_availabilities_824879560 as ca
10083 inner join buffer_schedules_824879560 as sc
10084 on ca.schedule_id = sc.id
10085 inner join buffer_linkage_dow_targets_824879560 as ldowt
10086 on sc.linkage_instance_id = ldowt.linkage_instance_id
10087 and (dayofweek(sc.schedule_on) - 1) = ldowt.wday
10088 and sc.period_offset = ldowt.period_offset
10089 and sc.calendar_schedule_id = ldowt.calendar_schedule_id
10090 inner join buffer_current_dow_targets_824879560 as dowt
10091 on ca.staff_id = dowt.staff_id
10092 and (dayofweek(sc.schedule_on) - 1) = dowt.wday
10093 and sc.period_offset = dowt.period_offset
10094 and sc.calendar_schedule_id = dowt.calendar_schedule_id
10095 where
10096 (sc.day_of_week_mask & 127 /* MonthlyDayOfWeekMixRule "days of week selection" */) > 0
10097 and (dowt.scheduled + ldowt.scheduled) > (round(dowt.adjusted_target, 2));
10098
10099 (152.7ms) /* CurrentWeeklyHourTargetsRule */
10100 delete ca
10101 from
10102 buffer_combined_availabilities_824879560 as ca
10103 inner join buffer_schedules_824879560 as sc
10104 on ca.schedule_id = sc.id
10105 inner join buffer_linkage_hour_targets_824879560 as lht
10106 on sc.linkage_instance_id = lht.linkage_instance_id
10107 and ca.staff_id = lht.staff_id
10108 and lht.is_weekend = -1
10109 and sc.period_offset = lht.period_offset
10110 and sc.calendar_schedule_id = lht.calendar_schedule_id
10111 inner join buffer_current_hour_targets_824879560 as ht
10112 on ca.staff_id = ht.staff_id
10113 and ht.is_weekend = -1
10114 and sc.period_offset = ht.period_offset
10115 and sc.calendar_schedule_id = ht.calendar_schedule_id
10116 where (ht.scheduled + lht.scheduled) > (ht.adjusted_target * (1 + 5 /* hours threshold */ / 100.0));
10117
10118 (154.2ms) delete ca
10119 from
10120 buffer_combined_availabilities_824879560 as ca
10121 inner join buffer_schedules_824879560 as sc
10122 on ca.schedule_id = sc.id
10123 inner join buffer_linkage_point_targets_824879560 as lpt
10124 on sc.linkage_instance_id = lpt.linkage_instance_id
10125 and ca.staff_id = lpt.staff_id
10126 and lpt.is_weekend = -1
10127 and sc.period_offset = lpt.period_offset
10128 and sc.calendar_schedule_id = lpt.calendar_schedule_id
10129 inner join buffer_current_point_targets_824879560 as pt
10130 on ca.staff_id = pt.staff_id
10131 and pt.is_weekend = -1
10132 and sc.period_offset = pt.period_offset
10133 and sc.calendar_schedule_id = pt.calendar_schedule_id
10134 where (pt.scheduled + lpt.scheduled) > (pt.adjusted_target * (1 + 0 /* points threshold */ / 100.0));
10135
10136 (153.3ms) /* MonthlyCallMixRule */
10137 delete ca
10138 from
10139 buffer_combined_availabilities_824879560 as ca
10140 inner join buffer_schedules_824879560 as sc
10141 on ca.schedule_id = sc.id
10142 inner join buffer_target_assignments_824879560 as ta
10143 on sc.call_type_id = ta.call_type_id
10144 inner join buffer_linkage_call_type_targets_824879560 as lctt use index (ix_buffer_linkage_call_type_targets_composite_1)
10145 on sc.linkage_instance_id = lctt.linkage_instance_id
10146 and ta.assignment_id = lctt.assignment_id
10147 and ta.assignment_type = lctt.assignment_type
10148 and sc.is_weekend = lctt.is_weekend
10149 and sc.period_offset = lctt.period_offset
10150 and sc.calendar_schedule_id = lctt.calendar_schedule_id
10151 inner join buffer_current_ct_targets_824879560 as ctt
10152 on ca.staff_id = ctt.staff_id
10153 and ta.assignment_id = ctt.assignment_id
10154 and ta.assignment_type = ctt.assignment_type
10155 and sc.is_weekend = ctt.is_weekend
10156 and sc.period_offset = ctt.period_offset
10157 and sc.calendar_schedule_id = ctt.calendar_schedule_id
10158 where
10159 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
10160 and (ctt.scheduled + lctt.scheduled) > (round(ctt.adjusted_target, 2));
10161
10162 (153.3ms) /* StaffCapacityRule */
10163 delete ca
10164 from
10165 buffer_combined_availabilities_824879560 as ca
10166 inner join buffer_schedules_824879560 as sc
10167 on ca.schedule_id = sc.id
10168 inner join buffer_linkage_targets_824879560 as lt
10169 on sc.linkage_instance_id = lt.linkage_instance_id
10170 and sc.is_weekend = lt.is_weekend
10171 and sc.period_offset = lt.period_offset
10172 and sc.calendar_schedule_id = lt.calendar_schedule_id
10173 inner join buffer_current_oa_targets_824879560 as t
10174 on ca.staff_id = t.staff_id
10175 and sc.is_weekend = t.is_weekend
10176 and sc.period_offset = t.period_offset
10177 and sc.calendar_schedule_id = t.calendar_schedule_id
10178 where
10179 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
10180 and (t.scheduled + lt.scheduled) > ceiling(round(t.adjusted_target, 2));
10181
10182 (155.1ms) /* CurrentHourTargetsRule */
10183 delete ca
10184 from
10185 buffer_combined_availabilities_824879560 as ca
10186 inner join buffer_schedules_824879560 as sc
10187 on ca.schedule_id = sc.id
10188 inner join buffer_linkage_hour_targets_824879560 as lht
10189 on sc.linkage_instance_id = lht.linkage_instance_id
10190 and ca.staff_id = lht.staff_id
10191 and sc.is_weekend = lht.is_weekend
10192 and sc.period_offset = lht.period_offset
10193 and sc.calendar_schedule_id = lht.calendar_schedule_id
10194 inner join buffer_current_hour_targets_824879560 as ht
10195 on ca.staff_id = ht.staff_id
10196 and sc.is_weekend = ht.is_weekend
10197 and sc.period_offset = ht.period_offset
10198 and sc.calendar_schedule_id = ht.calendar_schedule_id
10199 where
10200 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
10201 and (ht.scheduled + lht.scheduled) > (ht.adjusted_target * (1 + 10 /* hours threshold */ / 100.0))
10202
10203 (153.1ms) delete ca
10204 from
10205 buffer_combined_availabilities_824879560 as ca
10206 inner join buffer_schedules_824879560 as sc
10207 on ca.schedule_id = sc.id
10208 inner join buffer_linkage_point_targets_824879560 as lpt
10209 on sc.linkage_instance_id = lpt.linkage_instance_id
10210 and ca.staff_id = lpt.staff_id
10211 and sc.is_weekend = lpt.is_weekend
10212 and sc.period_offset = lpt.period_offset
10213 and sc.calendar_schedule_id = lpt.calendar_schedule_id
10214 inner join buffer_current_point_targets_824879560 as pt
10215 on ca.staff_id = pt.staff_id
10216 and sc.is_weekend = pt.is_weekend
10217 and sc.period_offset = pt.period_offset
10218 and sc.calendar_schedule_id = pt.calendar_schedule_id
10219 where
10220 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
10221 and (pt.scheduled + lpt.scheduled) > (pt.adjusted_target * (1 + 10 /* points threshold */ / 100.0));
10222
10223 (154.4ms) delete ca
10224 from buffer_combined_availabilities_824879560 as ca
10225 inner join (
10226 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
10227 sum(lac.assignments_count) as assignments_count
10228 from (
10229 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
10230 from buffer_combined_availabilities_824879560 as ca
10231 inner join buffer_schedules_824879560 as sc
10232 on ca.schedule_id = sc.id
10233 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
10234 order by null
10235 ) as ca_sc
10236 inner join buffer_linkage_assignments_count_weeks_824879560 as lac
10237 on ca_sc.linkage_instance_id = lac.linkage_instance_id
10238 and ca_sc.schedule_on = lac.schedule_on
10239 inner join buffer_assignment_limit_staff_types_824879560 as alst
10240 on lac.assignment_limit_id = alst.assignment_limit_id
10241 and ca_sc.staff_type_id = alst.staff_type_id
10242 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
10243 order by null
10244 ) as lac
10245 on ca.linkage_instance_id = lac.linkage_instance_id
10246 and ca.staff_id = lac.staff_id
10247 inner join assignment_limits as al
10248 on lac.assignment_limit_id = al.id
10249 left join buffer_staff_assignments_count_weeks_824879560 as sac
10250 on lac.assignment_limit_id = sac.assignment_limit_id
10251 and lac.staff_id = sac.staff_id
10252 and lac.start_date = sac.start_date
10253 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_weekly_limit
10254
10255 (153.6ms) delete ca
10256 from buffer_combined_availabilities_824879560 as ca
10257 inner join (
10258 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
10259 sum(lac.assignments_count) as assignments_count
10260 from (
10261 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
10262 from buffer_combined_availabilities_824879560 as ca
10263 inner join buffer_schedules_824879560 as sc
10264 on ca.schedule_id = sc.id
10265 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
10266 order by null
10267 ) as ca_sc
10268 inner join buffer_linkage_assignments_count_periods_824879560 as lac
10269 on ca_sc.linkage_instance_id = lac.linkage_instance_id
10270 and ca_sc.schedule_on = lac.schedule_on
10271 inner join buffer_assignment_limit_staff_types_824879560 as alst
10272 on lac.assignment_limit_id = alst.assignment_limit_id
10273 and ca_sc.staff_type_id = alst.staff_type_id
10274 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
10275 order by null
10276 ) as lac
10277 on ca.linkage_instance_id = lac.linkage_instance_id
10278 and ca.staff_id = lac.staff_id
10279 inner join assignment_limits as al
10280 on lac.assignment_limit_id = al.id
10281 left join buffer_staff_assignments_count_periods_824879560 as sac
10282 on lac.assignment_limit_id = sac.assignment_limit_id
10283 and lac.staff_id = sac.staff_id
10284 and lac.start_date = sac.start_date
10285 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_per_period_limit
10286
10287 (153.2ms) delete ca
10288 from buffer_combined_availabilities_824879560 as ca
10289 inner join (
10290 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
10291 sum(lac.assignments_count) as assignments_count
10292 from (
10293 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
10294 from buffer_combined_availabilities_824879560 as ca
10295 inner join buffer_schedules_824879560 as sc
10296 on ca.schedule_id = sc.id
10297 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
10298 order by null
10299 ) as ca_sc
10300 inner join buffer_linkage_assignments_count_rolling_824879560 as lac
10301 on ca_sc.linkage_instance_id = lac.linkage_instance_id
10302 and ca_sc.schedule_on = lac.schedule_on
10303 inner join buffer_assignment_limit_staff_types_824879560 as alst
10304 on lac.assignment_limit_id = alst.assignment_limit_id
10305 and ca_sc.staff_type_id = alst.staff_type_id
10306 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
10307 order by null
10308 ) as lac
10309 on ca.linkage_instance_id = lac.linkage_instance_id
10310 and ca.staff_id = lac.staff_id
10311 inner join assignment_limits as al
10312 on lac.assignment_limit_id = al.id
10313 left join buffer_staff_assignments_count_rolling_824879560 as sac
10314 on lac.assignment_limit_id = sac.assignment_limit_id
10315 and lac.staff_id = sac.staff_id
10316 and lac.start_date = sac.start_date
10317 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_rolling_limit
10318
10319 (153.6ms) delete ca
10320 from buffer_combined_availabilities_824879560 as ca
10321 inner join (
10322 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
10323 count(distinct if(sac.id is null, lac.schedule_on, null)) as assignments_count
10324 from (
10325 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
10326 from buffer_combined_availabilities_824879560 as ca
10327 inner join buffer_schedules_824879560 as sc
10328 on ca.schedule_id = sc.id
10329 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
10330 order by null
10331 ) as ca_sc
10332 inner join buffer_linkage_assignments_count_consecutive_824879560 as lac
10333 on ca_sc.linkage_instance_id = lac.linkage_instance_id
10334 and ca_sc.schedule_on = lac.schedule_on
10335 inner join buffer_assignment_limit_staff_types_824879560 as alst
10336 on lac.assignment_limit_id = alst.assignment_limit_id
10337 and ca_sc.staff_type_id = alst.staff_type_id
10338 left join buffer_staff_assignments_count_consecutive_824879560 as sac
10339 on lac.assignment_limit_id = sac.assignment_limit_id
10340 and ca_sc.staff_id = sac.staff_id
10341 and lac.schedule_on = sac.schedule_on
10342 and lac.start_date = sac.start_date
10343 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
10344 order by null
10345 ) as lac
10346 on ca.linkage_instance_id = lac.linkage_instance_id
10347 and ca.staff_id = lac.staff_id
10348 inner join assignment_limits as al
10349 on lac.assignment_limit_id = al.id
10350 left join (
10351 select assignment_limit_id, staff_id, start_date,
10352 count(schedule_on) as assignments_count
10353 from buffer_staff_assignments_count_consecutive_824879560
10354 group by assignment_limit_id, staff_id, start_date
10355 ) as sac
10356 on lac.assignment_limit_id = sac.assignment_limit_id
10357 and lac.staff_id = sac.staff_id
10358 and lac.start_date = sac.start_date
10359 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_consecutive_limit
10360
10361 (164.1ms) /* CumulativeWeeklyCallTypeTargetsRule */
10362 delete ca
10363 from
10364 buffer_combined_availabilities_824879560 as ca
10365 inner join buffer_schedules_824879560 as sc
10366 on ca.schedule_id = sc.id
10367 inner join buffer_target_assignments_824879560 as ta
10368 on sc.call_type_id = ta.call_type_id
10369 inner join buffer_linkage_call_type_targets_824879560 as lctt
10370 on sc.linkage_instance_id = lctt.linkage_instance_id
10371 and ta.assignment_id = lctt.assignment_id
10372 and ta.assignment_type = lctt.assignment_type
10373 and lctt.is_weekend = -1
10374 and lctt.period_offset = -1
10375 and sc.calendar_schedule_id = lctt.calendar_schedule_id
10376 inner join buffer_cumulative_ct_targets_824879560 as ctt
10377 on ca.staff_id = ctt.staff_id
10378 and ta.assignment_id = ctt.assignment_id
10379 and ta.assignment_type = ctt.assignment_type
10380 and ctt.is_weekend = -1
10381 and sc.calendar_schedule_id = ctt.calendar_schedule_id
10382 where (ctt.scheduled + lctt.scheduled) > (round(ctt.adjusted_target /* raw_target | adjusted_target */, 2));
10383
10384 (152.8ms) /* MaxAssignmentsRule */
10385 delete ca
10386 from buffer_combined_availabilities_824879560 as ca
10387 inner join buffer_schedules_824879560 as sc
10388 on ca.schedule_id = sc.id
10389 inner join buffer_linkage_call_type_assignments_824879560 as lcta
10390 on sc.linkage_instance_id = lcta.linkage_instance_id
10391 and sc.call_type_id = lcta.call_type_id
10392 and sc.is_weekend = lcta.is_weekend
10393 and sc.period_offset = lcta.period_offset
10394 and sc.calendar_schedule_id = lcta.calendar_schedule_id
10395 left join buffer_call_type_assignments_824879560 as cta
10396 on ca.staff_id = cta.staff_id
10397 and sc.call_type_id = cta.call_type_id
10398 and sc.is_weekend = cta.is_weekend
10399 and sc.period_offset = cta.period_offset
10400 and sc.calendar_schedule_id = cta.calendar_schedule_id
10401 where
10402 sc.is_weekend in (NULL) /* "weekday (0), weekend (1)" checkboxes */
10403 and (coalesce(cta.assignments_count, 0) + lcta.assignments_count) > lcta.max_assignments;
10404
10405 (152.9ms) /* NegativeLinkRule */
10406 delete ca
10407 from buffer_combined_availabilities_824879560 as ca use index (ix_buffer_combined_availabilities_composite_1)
10408 inner join buffer_negative_relations_824879560 as nr use index (ix_buffer_negative_relations_composite_1)
10409 on ca.schedule_id = nr.schedule_id
10410 and ca.staff_id = nr.staff_id
10411
10412 (154.4ms) /* BrokenLinkageRule */
10413 truncate table buffer_combined_availability_linkages_824879560
10414
10415 (155.5ms) insert into buffer_combined_availability_linkages_824879560 (
10416 staff_id,
10417 linkage_instance_id,
10418 slots_count,
10419 is_primary,
10420 has_violations
10421 )
10422 select
10423 staff_id,
10424 linkage_instance_id,
10425 count(1) as slots_count,
10426 min(is_primary) as is_primary,
10427 max(has_violations) as has_violations
10428 from buffer_combined_availabilities_824879560 use index (ix_buffer_combined_availabilities_composite_2)
10429 group by
10430 staff_id,
10431 linkage_instance_id
10432 order by null
10433
10434 (153.3ms) delete ca
10435 from
10436 buffer_combined_availabilities_824879560 as ca use index (ix_buffer_combined_availabilities_composite_1)
10437 inner join buffer_schedules_824879560 as sc
10438 on ca.schedule_id = sc.id
10439 inner join buffer_linkages_824879560 as l
10440 on sc.linkage_instance_id = l.linkage_instance_id
10441 inner join buffer_combined_availability_linkages_824879560 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
10442 on ca.staff_id = ls_1.staff_id
10443 and sc.linkage_instance_id = ls_1.linkage_instance_id
10444 left join buffer_schedule_linkages_824879560 as ls_2 use index (ix_buffer_schedule_linkages_composite_1)
10445 on ca.staff_id = ls_2.staff_id
10446 and sc.linkage_instance_id = ls_2.linkage_instance_id
10447 where (ls_1.slots_count + coalesce(ls_2.slots_count, 0)) < l.slots_count_total /* not covering the whole chain */;
10448
10449 (154.3ms) select straight_join
10450 sc.schedule_on,
10451 sc.call_type_id,
10452 count(distinct ca.staff_id) as available_members_count,
10453 group_concat(
10454 distinct concat(if(ls_1.is_primary = 1, 'p', 's'), ca.staff_id)
10455 order by ls_1.is_primary desc, ca.staff_id
10456 separator ', '
10457 ) as available_members_ids,
10458 sc.linkage_instance_id,
10459 l.slots_count_total as linkage_slots_count
10460 from buffer_combined_availabilities_824879560 as ca
10461 inner join buffer_schedules_824879560 as sc
10462 on ca.schedule_id = sc.id
10463 inner join buffer_linkages_824879560 as l
10464 on sc.linkage_instance_id = l.linkage_instance_id
10465 inner join buffer_combined_availability_linkages_824879560 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
10466 on ca.staff_id = ls_1.staff_id
10467 and sc.linkage_instance_id = ls_1.linkage_instance_id
10468 and ls_1.has_violations = 0
10469 where sc.should_be_evaluated = 1
10470 and sc.should_be_populated = 1
10471 group by sc.schedule_on, sc.call_type_id, sc.linkage_instance_id, l.slots_count_total
10472 order by available_members_count, sc.schedule_on, sc.display_order
10473 limit 1
10474
10475 (155.4ms) truncate table buffer_rule_scores_824879560
10476
10477 (155.0ms) truncate table buffer_rule_calc_filters_824879560
10478
10479 (155.1ms) insert into buffer_rule_calc_filters_824879560 (
10480 linkage_instance_id,
10481 staff_id
10482 ) values (21201740, 68)
10483
10484 (155.7ms) /* CurrentPointTargetsRule */
10485 insert into buffer_rule_scores_824879560 (
10486 linkage_instance_id,
10487 schedule_id,
10488 staff_id,
10489 rule_name,
10490 value
10491 )
10492 select
10493 b_schedules.linkage_instance_id,
10494 b_schedules.id as schedule_id,
10495 availabilities.staff_id,
10496 'CurrentPointTargetsRule' as rule_name,
10497 ((b_targets.adjusted_target - b_targets.scheduled) / b_targets.adjusted_target) as value
10498 from
10499 buffer_rule_calc_filters_824879560 as filters
10500 inner join buffer_schedules_824879560 as b_schedules
10501 on filters.linkage_instance_id = b_schedules.linkage_instance_id
10502 inner join buffer_combined_availabilities_824879560 as availabilities
10503 on b_schedules.id = availabilities.schedule_id
10504 and filters.staff_id = availabilities.staff_id
10505 inner join buffer_current_point_targets_824879560 as b_targets
10506 on availabilities.staff_id = b_targets.staff_id
10507 and b_schedules.is_weekend = b_targets.is_weekend
10508 and b_schedules.period_offset = b_targets.period_offset
10509 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
10510 order by null
10511
10512 (156.3ms) /* CumulativeWeeklyOverallTargetsRule */
10513 insert into buffer_rule_scores_824879560 (
10514 linkage_instance_id,
10515 schedule_id,
10516 staff_id,
10517 rule_name,
10518 value
10519 )
10520 select
10521 b_schedules.linkage_instance_id,
10522 b_schedules.id as schedule_id,
10523 availabilities.staff_id,
10524 'CumulativeWeeklyOverallTargetsRule' as rule_name,
10525 (
10526 (b_targets.adjusted_target /* depends on a cumulative targets period */ - b_targets.scheduled) /
10527 b_targets.adjusted_target /* depends on a cumulative targets period */
10528 ) as value
10529 from
10530 buffer_rule_calc_filters_824879560 as filters
10531 inner join buffer_schedules_824879560 as b_schedules
10532 on filters.linkage_instance_id = b_schedules.linkage_instance_id
10533 inner join buffer_combined_availabilities_824879560 as availabilities
10534 on b_schedules.id = availabilities.schedule_id
10535 and filters.staff_id = availabilities.staff_id
10536 inner join call_types
10537 on b_schedules.call_type_id = call_types.id
10538 and call_types.active = 1
10539 and call_types.included_in_targets > 0
10540 inner join buffer_cumulative_oa_targets_824879560 as b_targets
10541 on availabilities.staff_id = b_targets.staff_id
10542 and b_targets.is_weekend = -1
10543 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
10544 order by null
10545
10546 (155.4ms) /* CumulativeCallDaysTargetsRule */
10547 insert into buffer_rule_scores_824879560 (
10548 linkage_instance_id,
10549 schedule_id,
10550 staff_id,
10551 rule_name,
10552 value
10553 )
10554 select
10555 b_schedules.linkage_instance_id,
10556 b_schedules.id as schedule_id,
10557 availabilities.staff_id,
10558 'CumulativeCallDaysTargetsRule' as rule_name,
10559 (
10560 (b_targets.adjusted_target /* depends on a cumulative targets period */ - b_targets.scheduled) /
10561 b_targets.adjusted_target /* depends on a cumulative targets period */
10562 ) as value
10563 from
10564 buffer_rule_calc_filters_824879560 as filters
10565 inner join buffer_schedules_824879560 as b_schedules
10566 on filters.linkage_instance_id = b_schedules.linkage_instance_id
10567 inner join buffer_combined_availabilities_824879560 as availabilities
10568 on b_schedules.id = availabilities.schedule_id
10569 and filters.staff_id = availabilities.staff_id
10570 inner join buffer_target_assignments_824879560 as target_assignments
10571 on b_schedules.call_type_id = target_assignments.call_type_id
10572 inner join buffer_cumulative_cd_targets_824879560 as b_targets
10573 on availabilities.staff_id = b_targets.staff_id
10574 and target_assignments.assignment_id = b_targets.assignment_id
10575 and target_assignments.assignment_type = b_targets.assignment_type
10576 and b_schedules.day_of_week_mask = b_targets.day_of_week_mask
10577 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
10578 order by null
10579
10580 (155.3ms) /* AnnualDayOfWeekMixRule */
10581 insert into buffer_rule_scores_824879560 (
10582 linkage_instance_id,
10583 schedule_id,
10584 staff_id,
10585 rule_name,
10586 value
10587 )
10588 select
10589 b_schedules.linkage_instance_id,
10590 b_schedules.id as schedule_id,
10591 availabilities.staff_id,
10592 'AnnualDayOfWeekMixRule' as rule_name,
10593 (
10594 (b_targets.adjusted_target /* depends on a cumulative targets period */ - b_targets.scheduled) /
10595 b_targets.adjusted_target /* depends on a cumulative targets period */
10596 ) as value
10597 from
10598 buffer_rule_calc_filters_824879560 as filters
10599 inner join buffer_schedules_824879560 as b_schedules
10600 on filters.linkage_instance_id = b_schedules.linkage_instance_id
10601 inner join buffer_combined_availabilities_824879560 as availabilities
10602 on b_schedules.id = availabilities.schedule_id
10603 and filters.staff_id = availabilities.staff_id
10604 inner join call_types
10605 on b_schedules.call_type_id = call_types.id
10606 and call_types.included_in_targets > 0
10607 inner join buffer_cumulative_dow_targets_824879560 as b_targets
10608 on availabilities.staff_id = b_targets.staff_id
10609 and (dayofweek(b_schedules.schedule_on) - 1) = b_targets.wday
10610 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
10611 order by null
10612
10613 (156.4ms) /* CumulativeWeeklyHourTargetsRule */
10614 insert into buffer_rule_scores_824879560 (
10615 linkage_instance_id,
10616 schedule_id,
10617 staff_id,
10618 rule_name,
10619 value
10620 )
10621 select
10622 b_schedules.linkage_instance_id,
10623 b_schedules.id as schedule_id,
10624 availabilities.staff_id,
10625 'CumulativeWeeklyHourTargetsRule' as rule_name,
10626 ((b_targets.adjusted_target - b_targets.scheduled) /
10627 b_targets.adjusted_target) as value
10628 from
10629 buffer_rule_calc_filters_824879560 as filters
10630 inner join buffer_schedules_824879560 as b_schedules
10631 on filters.linkage_instance_id = b_schedules.linkage_instance_id
10632 inner join buffer_combined_availabilities_824879560 as availabilities
10633 on b_schedules.id = availabilities.schedule_id
10634 and filters.staff_id = availabilities.staff_id
10635 inner join buffer_cumulative_hour_targets_824879560 as b_targets
10636 on availabilities.staff_id = b_targets.staff_id
10637 and b_targets.is_weekend = -1
10638 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
10639 order by null
10640
10641 (157.8ms) /* CumulativeWeeklyPointTargetsRule */
10642 insert into buffer_rule_scores_824879560 (
10643 linkage_instance_id,
10644 schedule_id,
10645 staff_id,
10646 rule_name,
10647 value
10648 )
10649 select
10650 b_schedules.linkage_instance_id,
10651 b_schedules.id as schedule_id,
10652 availabilities.staff_id,
10653 'CumulativeWeeklyPointTargetsRule' as rule_name,
10654 ((b_targets.adjusted_target - b_targets.scheduled) /
10655 b_targets.adjusted_target) as value
10656 from
10657 buffer_rule_calc_filters_824879560 as filters
10658 inner join buffer_schedules_824879560 as b_schedules
10659 on filters.linkage_instance_id = b_schedules.linkage_instance_id
10660 inner join buffer_combined_availabilities_824879560 as availabilities
10661 on b_schedules.id = availabilities.schedule_id
10662 and filters.staff_id = availabilities.staff_id
10663 inner join buffer_cumulative_point_targets_824879560 as b_targets
10664 on availabilities.staff_id = b_targets.staff_id
10665 and b_targets.is_weekend = -1
10666 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
10667 order by null
10668
10669 (155.4ms) /* AnnualCallMixRule */
10670 insert into buffer_rule_scores_824879560 (
10671 linkage_instance_id,
10672 schedule_id,
10673 staff_id,
10674 rule_name,
10675 value
10676 )
10677 select
10678 b_schedules.linkage_instance_id,
10679 b_schedules.id as schedule_id,
10680 availabilities.staff_id,
10681 'AnnualCallMixRule' as rule_name,
10682 (
10683 (b_targets.adjusted_target /* depends on a cumulative targets period */ - b_targets.scheduled) /
10684 b_targets.adjusted_target /* depends on a cumulative targets period */
10685 ) as value
10686 from
10687 buffer_rule_calc_filters_824879560 as filters
10688 inner join buffer_schedules_824879560 as b_schedules
10689 on filters.linkage_instance_id = b_schedules.linkage_instance_id
10690 inner join buffer_combined_availabilities_824879560 as availabilities
10691 on b_schedules.id = availabilities.schedule_id
10692 and filters.staff_id = availabilities.staff_id
10693 inner join buffer_target_assignments_824879560 as target_assignments
10694 on b_schedules.call_type_id = target_assignments.call_type_id
10695 inner join buffer_cumulative_ct_targets_824879560 as b_targets
10696 on availabilities.staff_id = b_targets.staff_id
10697 and target_assignments.assignment_id = b_targets.assignment_id
10698 and target_assignments.assignment_type = b_targets.assignment_type
10699 and b_schedules.is_weekend = b_targets.is_weekend
10700 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
10701 order by null
10702
10703 (155.3ms) /* AnnualTargetsRule */
10704 insert into buffer_rule_scores_824879560 (
10705 linkage_instance_id,
10706 schedule_id,
10707 staff_id,
10708 rule_name,
10709 value
10710 )
10711 select
10712 b_schedules.linkage_instance_id,
10713 b_schedules.id as schedule_id,
10714 availabilities.staff_id,
10715 'AnnualTargetsRule' as rule_name,
10716 (
10717 (b_targets.adjusted_target /* depends on a cumulative targets period */ - b_targets.scheduled) /
10718 b_targets.adjusted_target /* depends on a cumulative targets period */
10719 ) as value
10720 from
10721 buffer_rule_calc_filters_824879560 as filters
10722 inner join buffer_schedules_824879560 as b_schedules
10723 on filters.linkage_instance_id = b_schedules.linkage_instance_id
10724 inner join buffer_combined_availabilities_824879560 as availabilities
10725 on b_schedules.id = availabilities.schedule_id
10726 and filters.staff_id = availabilities.staff_id
10727 inner join call_types
10728 on b_schedules.call_type_id = call_types.id
10729 and call_types.active = 1
10730 and call_types.included_in_targets > 0
10731 inner join buffer_cumulative_oa_targets_824879560 as b_targets
10732 on availabilities.staff_id = b_targets.staff_id
10733 and b_schedules.is_weekend = b_targets.is_weekend
10734 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
10735 order by null
10736
10737 (155.1ms) /* CumulativeHourTargetsRule */
10738 insert into buffer_rule_scores_824879560 (
10739 linkage_instance_id,
10740 schedule_id,
10741 staff_id,
10742 rule_name,
10743 value
10744 )
10745 select
10746 b_schedules.linkage_instance_id,
10747 b_schedules.id as schedule_id,
10748 availabilities.staff_id,
10749 'CumulativeHourTargetsRule' as rule_name,
10750 ((b_targets.adjusted_target - b_targets.scheduled) /
10751 b_targets.adjusted_target) as value
10752 from
10753 buffer_rule_calc_filters_824879560 as filters
10754 inner join buffer_schedules_824879560 as b_schedules
10755 on filters.linkage_instance_id = b_schedules.linkage_instance_id
10756 inner join buffer_combined_availabilities_824879560 as availabilities
10757 on b_schedules.id = availabilities.schedule_id
10758 and filters.staff_id = availabilities.staff_id
10759 inner join buffer_cumulative_hour_targets_824879560 as b_targets
10760 on availabilities.staff_id = b_targets.staff_id
10761 and b_schedules.is_weekend = b_targets.is_weekend
10762 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
10763 order by null
10764
10765 (157.8ms) /* CumulativePointTargetsRule */
10766 insert into buffer_rule_scores_824879560 (
10767 linkage_instance_id,
10768 schedule_id,
10769 staff_id,
10770 rule_name,
10771 value
10772 )
10773 select
10774 b_schedules.linkage_instance_id,
10775 b_schedules.id as schedule_id,
10776 availabilities.staff_id,
10777 'CumulativePointTargetsRule' as rule_name,
10778 ((b_targets.adjusted_target - b_targets.scheduled - b_targets.scheduled) /
10779 b_targets.adjusted_target) as value
10780 from
10781 buffer_rule_calc_filters_824879560 as filters
10782 inner join buffer_schedules_824879560 as b_schedules
10783 on filters.linkage_instance_id = b_schedules.linkage_instance_id
10784 inner join buffer_combined_availabilities_824879560 as availabilities
10785 on b_schedules.id = availabilities.schedule_id
10786 and filters.staff_id = availabilities.staff_id
10787 inner join buffer_cumulative_point_targets_824879560 as b_targets
10788 on availabilities.staff_id = b_targets.staff_id
10789 and b_schedules.is_weekend = b_targets.is_weekend
10790 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
10791 order by null;
10792
10793 (155.4ms) /* CurrentWeeklyCallTypeTargetsRule */
10794 insert into buffer_rule_scores_824879560 (
10795 linkage_instance_id,
10796 schedule_id,
10797 staff_id,
10798 rule_name,
10799 value
10800 )
10801 select
10802 b_schedules.linkage_instance_id,
10803 b_schedules.id as schedule_id,
10804 availabilities.staff_id,
10805 'CurrentWeeklyCallTypeTargetsRule' as rule_name,
10806 ((b_targets.adjusted_target - b_targets.scheduled) / b_targets.adjusted_target) as value
10807 from
10808 buffer_rule_calc_filters_824879560 as filters
10809 inner join buffer_schedules_824879560 as b_schedules
10810 on filters.linkage_instance_id = b_schedules.linkage_instance_id
10811 inner join buffer_combined_availabilities_824879560 as availabilities
10812 on b_schedules.id = availabilities.schedule_id
10813 and filters.staff_id = availabilities.staff_id
10814 inner join buffer_target_assignments_824879560 as target_assignments
10815 on b_schedules.call_type_id = target_assignments.call_type_id
10816 inner join buffer_current_ct_targets_824879560 as b_targets
10817 on availabilities.staff_id = b_targets.staff_id
10818 and target_assignments.assignment_id = b_targets.assignment_id
10819 and target_assignments.assignment_type = b_targets.assignment_type
10820 and b_targets.is_weekend = -1
10821 and b_schedules.period_offset = b_targets.period_offset
10822 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
10823 order by null
10824
10825 (157.2ms) /* CurrentWeeklyOverallTargetsRule */
10826 insert into buffer_rule_scores_824879560 (
10827 linkage_instance_id,
10828 schedule_id,
10829 staff_id,
10830 rule_name,
10831 value
10832 )
10833 select
10834 b_schedules.linkage_instance_id,
10835 b_schedules.id as schedule_id,
10836 availabilities.staff_id,
10837 'CurrentWeeklyOverallTargetsRule' as rule_name,
10838 ((b_targets.adjusted_target - b_targets.scheduled) / b_targets.adjusted_target) as value
10839 from
10840 buffer_rule_calc_filters_824879560 as filters
10841 inner join buffer_schedules_824879560 as b_schedules
10842 on filters.linkage_instance_id = b_schedules.linkage_instance_id
10843 inner join buffer_combined_availabilities_824879560 as availabilities
10844 on b_schedules.id = availabilities.schedule_id
10845 and filters.staff_id = availabilities.staff_id
10846 inner join call_types
10847 on b_schedules.call_type_id = call_types.id
10848 and call_types.active = 1
10849 and call_types.included_in_targets > 0
10850 inner join buffer_current_oa_targets_824879560 as b_targets
10851 on availabilities.staff_id = b_targets.staff_id
10852 and b_targets.is_weekend = -1
10853 and b_schedules.period_offset = b_targets.period_offset
10854 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
10855 order by null
10856
10857 (155.6ms) /* CurrentCallDaysTargetsRule */
10858 insert into buffer_rule_scores_824879560 (
10859 linkage_instance_id,
10860 schedule_id,
10861 staff_id,
10862 rule_name,
10863 value
10864 )
10865 select
10866 b_schedules.linkage_instance_id,
10867 b_schedules.id as schedule_id,
10868 availabilities.staff_id,
10869 'CurrentCallDaysTargetsRule' as rule_name,
10870 ((b_targets.adjusted_target - b_targets.scheduled) / b_targets.adjusted_target) as value
10871 from
10872 buffer_rule_calc_filters_824879560 as filters
10873 inner join buffer_schedules_824879560 as b_schedules
10874 on filters.linkage_instance_id = b_schedules.linkage_instance_id
10875 inner join buffer_combined_availabilities_824879560 as availabilities
10876 on b_schedules.id = availabilities.schedule_id
10877 and filters.staff_id = availabilities.staff_id
10878 inner join buffer_target_assignments_824879560 as target_assignments
10879 on b_schedules.call_type_id = target_assignments.call_type_id
10880 inner join buffer_current_cd_targets_824879560 as b_targets
10881 on availabilities.staff_id = b_targets.staff_id
10882 and target_assignments.assignment_id = b_targets.assignment_id
10883 and target_assignments.assignment_type = b_targets.assignment_type
10884 and b_schedules.day_of_week_mask = b_targets.day_of_week_mask
10885 and b_schedules.period_offset = b_targets.period_offset
10886 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
10887 order by null
10888
10889 (155.5ms) /* MonthlyDayOfWeekMixRule */
10890 insert into buffer_rule_scores_824879560 (
10891 linkage_instance_id,
10892 schedule_id,
10893 staff_id,
10894 rule_name,
10895 value
10896 )
10897 select
10898 b_schedules.linkage_instance_id,
10899 b_schedules.id as schedule_id,
10900 availabilities.staff_id,
10901 'MonthlyDayOfWeekMixRule' as rule_name,
10902 ((b_targets.adjusted_target - b_targets.scheduled) / b_targets.adjusted_target) as value
10903 from
10904 buffer_rule_calc_filters_824879560 as filters
10905 inner join buffer_schedules_824879560 as b_schedules
10906 on filters.linkage_instance_id = b_schedules.linkage_instance_id
10907 inner join buffer_combined_availabilities_824879560 as availabilities
10908 on b_schedules.id = availabilities.schedule_id
10909 and filters.staff_id = availabilities.staff_id
10910 inner join call_types
10911 on b_schedules.call_type_id = call_types.id
10912 and call_types.included_in_targets > 0
10913 inner join buffer_current_dow_targets_824879560 as b_targets
10914 on availabilities.staff_id = b_targets.staff_id
10915 and (dayofweek(b_schedules.schedule_on) - 1) = b_targets.wday
10916 and b_schedules.period_offset = b_targets.period_offset
10917 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
10918 order by null
10919
10920 (155.0ms) /* CurrentWeeklyHourTargetsRule */
10921 insert into buffer_rule_scores_824879560 (
10922 linkage_instance_id,
10923 schedule_id,
10924 staff_id,
10925 rule_name,
10926 value
10927 )
10928 select
10929 b_schedules.linkage_instance_id,
10930 b_schedules.id as schedule_id,
10931 availabilities.staff_id,
10932 'CurrentWeeklyHourTargetsRule' as rule_name,
10933 ((b_targets.adjusted_target - b_targets.scheduled) / b_targets.adjusted_target) as value
10934 from
10935 buffer_rule_calc_filters_824879560 as filters
10936 inner join buffer_schedules_824879560 as b_schedules
10937 on filters.linkage_instance_id = b_schedules.linkage_instance_id
10938 inner join buffer_combined_availabilities_824879560 as availabilities
10939 on b_schedules.id = availabilities.schedule_id
10940 and filters.staff_id = availabilities.staff_id
10941 inner join buffer_current_hour_targets_824879560 as b_targets
10942 on availabilities.staff_id = b_targets.staff_id
10943 and b_targets.is_weekend = -1
10944 and b_schedules.period_offset = b_targets.period_offset
10945 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
10946 order by null
10947
10948 (157.0ms) /* CurrentWeeklyPointTargetsRule */
10949 insert into buffer_rule_scores_824879560 (
10950 linkage_instance_id,
10951 schedule_id,
10952 staff_id,
10953 rule_name,
10954 value
10955 )
10956 select straight_join
10957 b_schedules.linkage_instance_id,
10958 b_schedules.id as schedule_id,
10959 availabilities.staff_id,
10960 'CurrentWeeklyPointTargetsRule' as rule_name,
10961 ((b_targets.adjusted_target - b_targets.scheduled) / b_targets.adjusted_target) as value
10962 from
10963 buffer_rule_calc_filters_824879560 as filters
10964 inner join buffer_schedules_824879560 as b_schedules
10965 on filters.linkage_instance_id = b_schedules.linkage_instance_id
10966 inner join buffer_combined_availabilities_824879560 as availabilities
10967 on b_schedules.id = availabilities.schedule_id
10968 and filters.staff_id = availabilities.staff_id
10969 inner join buffer_current_point_targets_824879560 as b_targets
10970 on availabilities.staff_id = b_targets.staff_id
10971 and b_targets.is_weekend = -1
10972 and b_schedules.period_offset = b_targets.period_offset
10973 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
10974 order by null;
10975
10976 (155.5ms) /* MonthlyCallMixRule */
10977 insert into buffer_rule_scores_824879560 (
10978 linkage_instance_id,
10979 schedule_id,
10980 staff_id,
10981 rule_name,
10982 value
10983 )
10984 select
10985 b_schedules.linkage_instance_id,
10986 b_schedules.id as schedule_id,
10987 availabilities.staff_id,
10988 'MonthlyCallMixRule' as rule_name,
10989 ((b_targets.adjusted_target - b_targets.scheduled) / b_targets.adjusted_target) as value
10990 from
10991 buffer_rule_calc_filters_824879560 as filters
10992 inner join buffer_schedules_824879560 as b_schedules
10993 on filters.linkage_instance_id = b_schedules.linkage_instance_id
10994 inner join buffer_combined_availabilities_824879560 as availabilities
10995 on b_schedules.id = availabilities.schedule_id
10996 and filters.staff_id = availabilities.staff_id
10997 inner join buffer_target_assignments_824879560 as target_assignments
10998 on b_schedules.call_type_id = target_assignments.call_type_id
10999 inner join buffer_current_ct_targets_824879560 as b_targets
11000 on availabilities.staff_id = b_targets.staff_id
11001 and target_assignments.assignment_id = b_targets.assignment_id
11002 and target_assignments.assignment_type = b_targets.assignment_type
11003 and b_schedules.is_weekend = b_targets.is_weekend
11004 and b_schedules.period_offset = b_targets.period_offset
11005 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
11006 order by null
11007
11008 (155.5ms) /* StaffCapacityRule */
11009 insert into buffer_rule_scores_824879560 (
11010 linkage_instance_id,
11011 schedule_id,
11012 staff_id,
11013 rule_name,
11014 value
11015 )
11016 select
11017 b_schedules.linkage_instance_id,
11018 b_schedules.id as schedule_id,
11019 availabilities.staff_id,
11020 'StaffCapacityRule' as rule_name,
11021 ((b_targets.adjusted_target - b_targets.scheduled) / b_targets.adjusted_target) as value
11022 from
11023 buffer_rule_calc_filters_824879560 as filters
11024 inner join buffer_schedules_824879560 as b_schedules
11025 on filters.linkage_instance_id = b_schedules.linkage_instance_id
11026 inner join buffer_combined_availabilities_824879560 as availabilities
11027 on b_schedules.id = availabilities.schedule_id
11028 and filters.staff_id = availabilities.staff_id
11029 inner join call_types
11030 on b_schedules.call_type_id = call_types.id
11031 and call_types.active = 1
11032 and call_types.included_in_targets > 0
11033 inner join buffer_current_oa_targets_824879560 as b_targets
11034 on availabilities.staff_id = b_targets.staff_id
11035 and b_schedules.is_weekend = b_targets.is_weekend
11036 and b_schedules.period_offset = b_targets.period_offset
11037 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
11038 order by null
11039
11040 (155.1ms) /* CurrentHourTargetsRule */
11041 insert into buffer_rule_scores_824879560 (
11042 linkage_instance_id,
11043 schedule_id,
11044 staff_id,
11045 rule_name,
11046 value
11047 )
11048 select
11049 b_schedules.linkage_instance_id,
11050 b_schedules.id as schedule_id,
11051 availabilities.staff_id,
11052 'CurrentHourTargetsRule' as rule_name,
11053 ((b_targets.adjusted_target - b_targets.scheduled) / b_targets.adjusted_target) as value
11054 from
11055 buffer_rule_calc_filters_824879560 as filters
11056 inner join buffer_schedules_824879560 as b_schedules
11057 on filters.linkage_instance_id = b_schedules.linkage_instance_id
11058 inner join buffer_combined_availabilities_824879560 as availabilities
11059 on b_schedules.id = availabilities.schedule_id
11060 and filters.staff_id = availabilities.staff_id
11061 inner join buffer_current_hour_targets_824879560 as b_targets
11062 on availabilities.staff_id = b_targets.staff_id
11063 and b_schedules.is_weekend = b_targets.is_weekend
11064 and b_schedules.period_offset = b_targets.period_offset
11065 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
11066 order by null
11067
11068 (156.4ms) /* CumulativeWeeklyCallTypeTargetsRule */
11069 insert into buffer_rule_scores_824879560 (
11070 linkage_instance_id,
11071 schedule_id,
11072 staff_id,
11073 rule_name,
11074 value
11075 )
11076 select
11077 b_schedules.linkage_instance_id,
11078 b_schedules.id as schedule_id,
11079 availabilities.staff_id,
11080 'CumulativeWeeklyCallTypeTargetsRule' as rule_name,
11081 (
11082 (b_targets.adjusted_target /* depends on a cumulative targets period */ - b_targets.scheduled) /
11083 b_targets.adjusted_target /* depends on a cumulative targets period */
11084 ) as value
11085 from
11086 buffer_rule_calc_filters_824879560 as filters
11087 inner join buffer_schedules_824879560 as b_schedules
11088 on filters.linkage_instance_id = b_schedules.linkage_instance_id
11089 inner join buffer_combined_availabilities_824879560 as availabilities
11090 on b_schedules.id = availabilities.schedule_id
11091 and filters.staff_id = availabilities.staff_id
11092 inner join buffer_target_assignments_824879560 as target_assignments
11093 on b_schedules.call_type_id = target_assignments.call_type_id
11094 inner join buffer_cumulative_ct_targets_824879560 as b_targets
11095 on availabilities.staff_id = b_targets.staff_id
11096 and target_assignments.assignment_id = b_targets.assignment_id
11097 and target_assignments.assignment_type = b_targets.assignment_type
11098 and b_targets.is_weekend = -1
11099 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
11100 order by null
11101
11102 (155.0ms) truncate table buffer_rule_scores_with_corrections_824879560
11103
11104 (155.6ms) insert into buffer_rule_scores_with_corrections_824879560 (
11105 linkage_instance_id, schedule_id, staff_id, rule_name, value
11106 )
11107 select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id, rule_scores.rule_name,
11108 ifnull(rule_scores.value, max_values.max_value + 1) as value
11109 from buffer_rule_scores_824879560 as rule_scores
11110 inner join (
11111 select rule_name, max(value) as max_value
11112 from buffer_rule_scores_824879560
11113 group by rule_name
11114 order by null
11115 ) as max_values
11116 on rule_scores.rule_name = max_values.rule_name
11117 order by null
11118
11119 (153.9ms) select linkage_instance_id, staff_id, avg(slot_scores) as scores
11120 from (
11121 select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id,
11122 sum(
11123 if((total_values.total_value > 0), (rule_scores.value / total_values.total_value), 0) *
11124 rules.weight *
11125 total_values.slots_count
11126 ) as slot_scores
11127 from buffer_rule_scores_with_corrections_824879560 as rule_scores
11128 inner join (
11129 select rule_name, sum(abs(value)) as total_value,
11130 count(distinct schedule_id) as slots_count
11131 from buffer_rule_scores_with_corrections_824879560
11132 group by rule_name
11133 order by null
11134 ) as total_values
11135 on rule_scores.rule_name = total_values.rule_name
11136 inner join rules
11137 on rule_scores.rule_name = rules.type
11138 where rules.rule_set_id = 1528
11139 and rules.applied = 1
11140 group by rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id
11141 order by null
11142 ) as staff_scores
11143 group by linkage_instance_id, staff_id
11144 order by round(avg(slot_scores), 5) desc, rand()
11145 limit 1
11146
11147 PublishedBlock Load (154.7ms) SELECT `published_blocks`.* FROM `published_blocks` INNER JOIN `blocks` ON `blocks`.`id` = `published_blocks`.`block_id` WHERE `published_blocks`.`client_id` = 6 AND ('2017-10-04' BETWEEN blocks.start_date AND blocks.end_date) AND `published_blocks`.`calendar_schedule_id` = 6 ORDER BY `published_blocks`.`id` ASC LIMIT 1
11148 (152.3ms) BEGIN
11149 (155.3ms) SELECT COALESCE(pb.updated_at, pbct.updated_at)
11150 FROM call_types AS ct
11151 INNER JOIN calendar_schedules AS cs
11152 ON ct.calendar_schedule_id = cs.id
11153 INNER JOIN blocks AS b
11154 ON b.client_id = ct.client_id
11155 AND b.block_schedule_id = cs.block_schedule_id
11156 AND '2017-10-04' BETWEEN b.start_date AND b.end_date
11157 INNER JOIN published_blocks AS pb
11158 ON pb.client_id = ct.client_id
11159 AND pb.block_id = b.id
11160 AND pb.calendar_schedule_id = cs.id
11161 LEFT JOIN published_block_call_types AS pbct
11162 ON pbct.client_id = ct.client_id
11163 AND pbct.assignment_id = ct.id
11164 AND pbct.assignment_type = 'CallType'
11165 AND pbct.block_id = b.id
11166 AND (
11167 (1 << (DAYOFWEEK('2017-10-04') - 1) & pbct.days_of_week_mask) > 0
11168 )
11169 WHERE ct.id = 47
11170 AND (
11171 (
11172 pb.assignment_ids IS NULL
11173 AND (1 << (DAYOFWEEK('2017-10-04') - 1) & pb.days_of_week_mask) > 0
11174 )
11175 OR pbct.id IS NOT NULL
11176 )
11177
11178 CallType Load (153.7ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 47 LIMIT 1
11179 Client Load (155.2ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
11180 Staff Load (153.3ms) SELECT `staffs`.* FROM `staffs` WHERE `staffs`.`id` = 68 LIMIT 1
11181 Schedule Exists (158.7ms) SELECT 1 AS one FROM `schedules` WHERE `schedules`.`call_type_id` = 47 AND `schedules`.`client_id` = 6 AND `schedules`.`schedule_on` = '2017-10-04' LIMIT 1
11182 SQL (177.0ms) INSERT INTO `schedules` (`client_id`, `call_type_id`, `staff_id`, `schedule_on`, `created_at`, `updated_at`, `weekend_on`, `dayofweek_on`, `populate_method`, `creator_id`) VALUES (6, 47, 68, '2017-10-04', '2018-04-03 14:41:55', '2018-04-03 14:41:55', 0, 4, 'auto_populate_step', 166)
11183 VisibleAssignment Load (153.1ms) SELECT `visible_assignments`.* FROM `visible_assignments` WHERE `visible_assignments`.`client_id` = 6 AND `visible_assignments`.`date` = '2017-10-04' AND `visible_assignments`.`assignment_type` = 'CallType' AND `visible_assignments`.`assignment_id` = 47 ORDER BY `visible_assignments`.`id` ASC LIMIT 1
11184 DailyListSlot Load (154.5ms) SELECT `daily_list_slots`.* FROM `daily_list_slots` WHERE `daily_list_slots`.`schedule_on` = '2017-10-04' AND `daily_list_slots`.`staff_id` = 68 AND `daily_list_slots`.`call_type_id` = 47 ORDER BY daily_list_slots.position asc LIMIT 1
11185 (155.4ms) COMMIT
11186FLUSHED: nil:nil
11187 (155.3ms) UPDATE buffer_schedules_824879560
11188 SET staff_id = 68,
11189 should_be_populated = 0,
11190 should_be_evaluated = 0
11191 WHERE
11192 call_type_id = 47
11193 AND schedule_on = '2017-10-04'
11194
11195 (154.5ms) delete from buffer_combined_availabilities_824879560
11196 where linkage_instance_id = 21201740
11197
11198 (153.0ms) UPDATE buffer_rule_calc_schedules_824879560
11199 SET staff_id = 68
11200 WHERE call_type_id = 47
11201 AND schedule_on = '2017-10-04'
11202
11203 (154.7ms) INSERT INTO buffer_rule_calc_schedules_824879560
11204 SET staff_id = 68,
11205 call_type_id = 47,
11206 schedule_on = '2017-10-04',
11207 day_of_week_mask = 8
11208
11209 (153.6ms) /* NegativeLinkRule */
11210 UPDATE buffer_negative_relations_824879560
11211 SET staff_id = 68
11212 WHERE affected_by_schedule_id = (
11213 SELECT id
11214 FROM buffer_schedules_824879560
11215 WHERE schedule_on = '2017-10-04'
11216 AND call_type_id = 47
11217 )
11218
11219 (162.4ms) /* SpecializationOverlapRule */
11220 update buffer_staff_specializations_824879560 as st_sp
11221 inner join max_applicable_call_types as mact
11222 on st_sp.specialization_id = mact.specialization_id
11223 and mact.call_type_id = 47
11224 inner join buffer_specialization_daily_counts_824879560 as sp_dc
11225 on st_sp.specialization_id = sp_dc.specialization_id
11226 and sp_dc.staff_id is null
11227 and sp_dc.schedule_on = '2017-10-04'
11228 left join buffer_specialization_daily_counts_824879560 as sp_dc_2
11229 on st_sp.specialization_id = sp_dc_2.specialization_id
11230 and st_sp.staff_id = sp_dc_2.staff_id
11231 and sp_dc_2.schedule_on = '2017-10-04'
11232 set sp_dc.staffs_scheduled = sp_dc.staffs_scheduled + 1
11233 where st_sp.staff_id = 68
11234 and sp_dc_2.id is null
11235
11236 (153.5ms) insert into buffer_specialization_daily_counts_824879560 (
11237 specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
11238 )
11239 select sp.id as specialization_id,
11240 68 as staff_id,
11241 '2017-10-04' as schedule_on,
11242 1 as staffs_scheduled,
11243 sp.max_scheduled,
11244 sp_dc.should_be_evaluated
11245 from buffer_staff_specializations_824879560 as st_sp
11246 inner join specializations as sp
11247 on st_sp.specialization_id = sp.id
11248 inner join max_applicable_call_types as mact
11249 on st_sp.specialization_id = mact.specialization_id
11250 and mact.call_type_id = 47
11251 inner join buffer_specialization_daily_counts_824879560 as sp_dc
11252 on st_sp.specialization_id = sp_dc.specialization_id
11253 and sp_dc.staff_id is null
11254 and sp_dc.schedule_on = '2017-10-04'
11255 left join buffer_specialization_daily_counts_824879560 as sp_dc_2
11256 on st_sp.specialization_id = sp_dc_2.specialization_id
11257 and st_sp.staff_id = sp_dc_2.staff_id
11258 and sp_dc_2.schedule_on = '2017-10-04'
11259 where st_sp.staff_id = 68
11260 and sp_dc_2.id is null
11261
11262 (154.9ms) /* MaxAssignmentsRule */
11263 delete from buffer_linkage_call_type_assignments_824879560
11264 where linkage_instance_id = 21201740;
11265
11266 (153.2ms) /* MaxAssignmentsRule */
11267 update
11268 buffer_schedules_824879560 as sc
11269 inner join call_types as ct
11270 on sc.call_type_id = ct.id
11271 and ct.active = 1
11272 inner join buffer_call_type_assignments_824879560 as cta
11273 on sc.staff_id = cta.staff_id
11274 and sc.call_type_id = cta.call_type_id
11275 and sc.is_weekend = cta.is_weekend
11276 and sc.period_offset = cta.period_offset
11277 and sc.calendar_schedule_id = cta.calendar_schedule_id
11278 set cta.assignments_count = cta.assignments_count + 1
11279 where
11280 sc.schedule_on = '2017-10-04'
11281 and sc.call_type_id = 47
11282 and sc.staff_id = 68
11283
11284 (155.2ms) insert into buffer_call_type_assignments_824879560 (
11285 staff_id,
11286 call_type_id,
11287 is_weekend,
11288 period_offset,
11289 calendar_schedule_id,
11290 assignments_count
11291 )
11292 select
11293 sc.staff_id,
11294 sc.call_type_id,
11295 sc.is_weekend,
11296 sc.period_offset,
11297 sc.calendar_schedule_id,
11298 1 as assignments_count
11299 from buffer_schedules_824879560 as sc
11300 where
11301 sc.staff_id = 68
11302 and sc.schedule_on = '2017-10-04'
11303 and sc.call_type_id = 47
11304
11305 (154.9ms) /* UnassignedDaysRule */
11306 delete from buffer_linkage_assigned_days_824879560
11307 where linkage_instance_id = 21201740
11308
11309 (155.6ms) /* UnassignedDaysRule */
11310 UPDATE buffer_staff_assigned_days_824879560 as sad
11311 inner join call_types as ct
11312 on ct.id = 47
11313 and ct.unassigned_day = 0
11314 SET sad.is_assigned = 1
11315 WHERE sad.staff_id = 68
11316 AND sad.schedule_on = '2017-10-04'
11317
11318 (155.1ms) /* CurrentCallDaysTargetsRule, CumulativeCallDaysTargetsRule */
11319 delete from buffer_linkage_call_days_targets_824879560
11320 where linkage_instance_id = 21201740
11321
11322 (158.1ms) /* CurrentCallDaysTargetsRule */
11323 update buffer_schedules_824879560 as sc
11324 inner join buffer_counter_increments_824879560 as ci
11325 on sc.id = ci.schedule_id
11326 and ci.calls > 0
11327 inner join buffer_target_assignments_824879560 as ta
11328 on sc.call_type_id = ta.call_type_id
11329 inner join buffer_current_cd_targets_824879560 as t
11330 on sc.staff_id = t.staff_id
11331 and ta.assignment_id = t.assignment_id
11332 and ta.assignment_type = t.assignment_type
11333 and sc.day_of_week_mask = t.day_of_week_mask
11334 and sc.period_offset = t.period_offset
11335 and sc.calendar_schedule_id = t.calendar_schedule_id
11336 set t.scheduled = t.scheduled + ci.calls
11337 where sc.schedule_on = '2017-10-04'
11338 and sc.call_type_id = 47
11339 and sc.staff_id = 68
11340
11341 (155.8ms) /* CumulativeCallDaysTargetsRule */
11342 update buffer_schedules_824879560 as sc
11343 inner join buffer_counter_increments_824879560 as ci
11344 on sc.id = ci.schedule_id
11345 and ci.affects_cumulative_targets = 1
11346 and ci.calls > 0
11347 inner join buffer_target_assignments_824879560 as ta
11348 on sc.call_type_id = ta.call_type_id
11349 inner join buffer_cumulative_cd_targets_824879560 as t
11350 on sc.staff_id = t.staff_id
11351 and ta.assignment_id = t.assignment_id
11352 and ta.assignment_type = t.assignment_type
11353 and sc.day_of_week_mask = t.day_of_week_mask
11354 and sc.calendar_schedule_id = t.calendar_schedule_id
11355 set t.scheduled = t.scheduled + ci.calls
11356 where sc.schedule_on = '2017-10-04'
11357 and sc.call_type_id = 47
11358 and sc.staff_id = 68
11359
11360 (154.7ms) /* MonthlyCallMixRule, CurrentWeeklyCallTypeTargetsRule, AnnualCallMixRule, CumulativeWeeklyCallTypeTargetsRule */
11361 delete from buffer_linkage_call_type_targets_824879560
11362 where linkage_instance_id = 21201740
11363
11364 (155.7ms) /* MonthlyCallMixRule, CurrentWeeklyCallTypeTargetsRule */
11365 update buffer_schedules_824879560 as sc
11366 inner join buffer_counter_increments_824879560 as ci
11367 on sc.id = ci.schedule_id
11368 and ci.calls > 0
11369 inner join buffer_target_assignments_824879560 as ta
11370 on sc.call_type_id = ta.call_type_id
11371 inner join buffer_current_ct_targets_824879560 as t
11372 on sc.staff_id = t.staff_id
11373 and ta.assignment_id = t.assignment_id
11374 and ta.assignment_type = t.assignment_type
11375 and (
11376 sc.is_weekend = t.is_weekend or t.is_weekend = -1
11377 )
11378 and sc.period_offset = t.period_offset
11379 and sc.calendar_schedule_id = t.calendar_schedule_id
11380 set t.scheduled = t.scheduled + ci.calls
11381 where sc.schedule_on = '2017-10-04'
11382 and sc.call_type_id = 47
11383 and sc.staff_id = 68
11384
11385 (180.6ms) /* AnnualCallMixRule, CumulativeWeeklyCallTypeTargetsRule */
11386 update buffer_schedules_824879560 as sc
11387 inner join buffer_counter_increments_824879560 as ci
11388 on sc.id = ci.schedule_id
11389 and ci.affects_cumulative_targets = 1
11390 and ci.calls > 0
11391 inner join buffer_target_assignments_824879560 as ta
11392 on sc.call_type_id = ta.call_type_id
11393 inner join buffer_cumulative_ct_targets_824879560 as t
11394 on sc.staff_id = t.staff_id
11395 and ta.assignment_id = t.assignment_id
11396 and ta.assignment_type = t.assignment_type
11397 and (
11398 sc.is_weekend = t.is_weekend or t.is_weekend = -1
11399 )
11400 and sc.calendar_schedule_id = t.calendar_schedule_id
11401 set t.scheduled = t.scheduled + ci.calls
11402 where sc.schedule_on = '2017-10-04'
11403 and sc.call_type_id = 47
11404 and sc.staff_id = 68
11405
11406 (154.8ms) /* StaffCapacityRule, CurrentWeeklyOverallTargetsRule, AnnualTargetsRule, CumulativeWeeklyOverallTargetsRule */
11407 delete from buffer_linkage_targets_824879560
11408 where linkage_instance_id = 21201740
11409
11410 (155.3ms) /* StaffCapacityRule, CurrentWeeklyOverallTargetsRule */
11411 update buffer_schedules_824879560 as sc
11412 inner join buffer_counter_increments_824879560 as ci
11413 on sc.id = ci.schedule_id
11414 and ci.calls > 0
11415 inner join buffer_current_oa_targets_824879560 as t
11416 on sc.staff_id = t.staff_id
11417 and (
11418 sc.is_weekend = t.is_weekend or t.is_weekend = -1
11419 )
11420 and sc.period_offset = t.period_offset
11421 and sc.calendar_schedule_id = t.calendar_schedule_id
11422 set t.scheduled = t.scheduled + ci.calls
11423 where sc.schedule_on = '2017-10-04'
11424 and sc.call_type_id = 47
11425 and sc.staff_id = 68
11426
11427 (155.6ms) /* AnnualTargetsRule, CumulativeWeeklyOverallTargetsRule */
11428 update buffer_schedules_824879560 as sc
11429 inner join buffer_counter_increments_824879560 as ci
11430 on sc.id = ci.schedule_id
11431 and ci.affects_cumulative_targets = 1
11432 and ci.calls > 0
11433 inner join buffer_cumulative_oa_targets_824879560 as t
11434 on sc.staff_id = t.staff_id
11435 and (
11436 sc.is_weekend = t.is_weekend or t.is_weekend = -1
11437 )
11438 and sc.calendar_schedule_id = t.calendar_schedule_id
11439 set t.scheduled = t.scheduled + ci.calls
11440 where sc.schedule_on = '2017-10-04'
11441 and sc.call_type_id = 47
11442 and sc.staff_id = 68
11443
11444 (155.0ms) /* MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule */
11445 delete from buffer_linkage_dow_targets_824879560
11446 where linkage_instance_id = 21201740
11447
11448 (155.6ms) /* MonthlyDayOfWeekMixRule */
11449 update buffer_schedules_824879560 as sc
11450 inner join buffer_counter_increments_824879560 as ci
11451 on sc.id = ci.schedule_id
11452 and ci.calls > 0
11453 inner join buffer_current_dow_targets_824879560 as t
11454 on sc.staff_id = t.staff_id
11455 and (dayofweek(sc.schedule_on) - 1) = t.wday
11456 and sc.period_offset = t.period_offset
11457 and sc.calendar_schedule_id = t.calendar_schedule_id
11458 set t.scheduled = t.scheduled + ci.calls
11459 where sc.schedule_on = '2017-10-04'
11460 and sc.call_type_id = 47
11461 and sc.staff_id = 68
11462
11463 (155.3ms) /* AnnualDayOfWeekMixRule */
11464 update buffer_schedules_824879560 as sc
11465 inner join buffer_counter_increments_824879560 as ci
11466 on sc.id = ci.schedule_id
11467 and ci.affects_cumulative_targets = 1
11468 and ci.calls > 0
11469 inner join buffer_cumulative_dow_targets_824879560 as t
11470 on sc.staff_id = t.staff_id
11471 and (dayofweek(sc.schedule_on) - 1) = t.wday
11472 and sc.calendar_schedule_id = t.calendar_schedule_id
11473 set t.scheduled = t.scheduled + ci.calls
11474 where sc.schedule_on = '2017-10-04'
11475 and sc.call_type_id = 47
11476 and sc.staff_id = 68
11477
11478 (157.7ms) delete
11479 from buffer_linkage_point_targets_824879560
11480 where linkage_instance_id = 21201740
11481
11482 (157.4ms) truncate table buffer_tmp_targets_scheduled_824879560
11483
11484 (155.4ms) insert into buffer_tmp_targets_scheduled_824879560 (
11485 block_id,
11486 calendar_schedule_id,
11487 staff_id,
11488 assignment_id,
11489 assignment_type,
11490 day_of_week_mask,
11491 is_weekend,
11492 scheduled,
11493 other_scheduled
11494 )
11495 select
11496 pt.block_id,
11497 pt.calendar_schedule_id,
11498 pt.staff_id,
11499 0 as assignment_id,
11500 '' as assignment_type,
11501 0 as day_of_week_mask,
11502 pt.is_weekend,
11503 case
11504 when (sc.calendar_schedule_id = pt.calendar_schedule_id) then ci.points
11505 else 0.0
11506 end as scheduled,
11507 case
11508 when (sc.calendar_schedule_id != pt.calendar_schedule_id) then ci.points
11509 else 0.0
11510 end as other_scheduled
11511 from
11512 buffer_schedules_824879560 as sc
11513 inner join buffer_counter_increments_824879560 as ci
11514 on sc.id = ci.schedule_id
11515 and ci.points != 0
11516 inner join assign_staff_types as ast
11517 on sc.staff_id = ast.staff_id
11518 and sc.schedule_on between ast.begin_date and coalesce(ast.end_date, '9999-12-31')
11519 inner join staff_types as st
11520 on ast.staff_type_id = st.id
11521 inner join buffer_point_targets_824879560 as pt
11522 on sc.block_id = pt.block_id
11523 and st.point_hour_schedule_id = pt.calendar_schedule_id
11524 and sc.staff_id = pt.staff_id
11525 and sc.is_weekend = pt.is_weekend
11526 where
11527 sc.schedule_on = '2017-10-04'
11528 and sc.call_type_id = 68
11529 and sc.staff_id = 47
11530 order by null
11531
11532 (153.0ms) select 1 from buffer_tmp_targets_scheduled_824879560
11533
11534 (157.5ms) delete
11535 from buffer_linkage_hour_targets_824879560
11536 where linkage_instance_id = 21201740
11537
11538 (167.4ms) truncate table buffer_tmp_targets_scheduled_824879560
11539
11540 (153.8ms) insert into buffer_tmp_targets_scheduled_824879560 (
11541 block_id,
11542 calendar_schedule_id,
11543 staff_id,
11544 assignment_id,
11545 assignment_type,
11546 day_of_week_mask,
11547 is_weekend,
11548 scheduled,
11549 other_scheduled
11550 )
11551 select
11552 ht.block_id,
11553 ht.calendar_schedule_id,
11554 ht.staff_id,
11555 0 as assignment_id,
11556 '' as assignment_type,
11557 0 as day_of_week_mask,
11558 ht.is_weekend,
11559 case
11560 when (sc.calendar_schedule_id = ht.calendar_schedule_id) then ci.hours
11561 else 0.0
11562 end as scheduled,
11563 case
11564 when (sc.calendar_schedule_id != ht.calendar_schedule_id) then ci.hours
11565 else 0.0
11566 end as other_scheduled
11567 from
11568 buffer_schedules_824879560 as sc
11569 inner join buffer_counter_increments_824879560 as ci
11570 on sc.id = ci.schedule_id
11571 and ci.hours > 0
11572 inner join assign_staff_types as ast
11573 on sc.staff_id = ast.staff_id
11574 and sc.schedule_on between ast.begin_date and coalesce(ast.end_date, '9999-12-31')
11575 inner join staff_types as st
11576 on ast.staff_type_id = st.id
11577 inner join buffer_hour_targets_824879560 as ht
11578 on sc.block_id = ht.block_id
11579 and st.point_hour_schedule_id = ht.calendar_schedule_id
11580 and sc.staff_id = ht.staff_id
11581 and sc.is_weekend = ht.is_weekend
11582 where
11583 sc.schedule_on = '2017-10-04'
11584 and sc.call_type_id = 68
11585 and sc.staff_id = 47
11586 order by null
11587
11588 (152.6ms) select 1 from buffer_tmp_targets_scheduled_824879560
11589
11590 (154.5ms) /* AssignmentLimitsPerPeriod */
11591 /* Unique Key: assignment_limit_id, staff_id, start_date */
11592 insert into buffer_staff_assignments_count_periods_824879560 (
11593 assignment_limit_id, staff_id, start_date, end_date, assignments_count
11594 )
11595 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
11596 1 as assignments_count
11597 from buffer_schedules_824879560 as sc
11598 inner join buffer_assignment_limit_call_types_824879560 as alct
11599 on sc.call_type_id = alct.call_type_id
11600 inner join assignment_limits as al
11601 on alct.assignment_limit_id = al.id
11602 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
11603 and al.max_per_period_limit is not null
11604 inner join assign_staff_types as ast
11605 on sc.staff_id = ast.staff_id
11606 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
11607 inner join buffer_assignment_limit_staff_types_824879560 as alst
11608 on alct.assignment_limit_id = alst.assignment_limit_id
11609 and ast.staff_type_id = alst.staff_type_id
11610 inner join (
11611 select assignment_limit_id, start_date, end_date
11612 from buffer_linkage_assignments_count_periods_824879560
11613 group by assignment_limit_id, start_date, end_date
11614 order by null
11615 ) as lac
11616 on alct.assignment_limit_id = lac.assignment_limit_id
11617 and sc.schedule_on between lac.start_date and lac.end_date
11618 where sc.schedule_on = '2017-10-04'
11619 and sc.call_type_id = 47
11620 and sc.staff_id = 68
11621 on duplicate key update
11622 assignments_count = assignments_count + 1
11623
11624 (159.2ms) /* AssignmentLimitsPerWeek */
11625 /* Unique Key: assignment_limit_id, staff_id, start_date */
11626 insert into buffer_staff_assignments_count_weeks_824879560 (
11627 assignment_limit_id, staff_id, start_date, end_date, assignments_count
11628 )
11629 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
11630 1 as assignments_count
11631 from buffer_schedules_824879560 as sc
11632 inner join buffer_assignment_limit_call_types_824879560 as alct
11633 on sc.call_type_id = alct.call_type_id
11634 inner join assignment_limits as al
11635 on alct.assignment_limit_id = al.id
11636 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
11637 and al.max_weekly_limit is not null
11638 inner join assign_staff_types as ast
11639 on sc.staff_id = ast.staff_id
11640 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
11641 inner join buffer_assignment_limit_staff_types_824879560 as alst
11642 on alct.assignment_limit_id = alst.assignment_limit_id
11643 and ast.staff_type_id = alst.staff_type_id
11644 inner join (
11645 select assignment_limit_id, start_date, end_date
11646 from buffer_linkage_assignments_count_weeks_824879560
11647 group by assignment_limit_id, start_date, end_date
11648 order by null
11649 ) as lac
11650 on alct.assignment_limit_id = lac.assignment_limit_id
11651 and sc.schedule_on between lac.start_date and lac.end_date
11652 where sc.schedule_on = '2017-10-04'
11653 and sc.call_type_id = 47
11654 and sc.staff_id = 68
11655 on duplicate key update
11656 assignments_count = assignments_count + 1
11657
11658 (159.5ms) /* AssignmentLimitsRolling */
11659 /* Unique Key: assignment_limit_id, staff_id, start_date */
11660 insert into buffer_staff_assignments_count_rolling_824879560 (
11661 assignment_limit_id, staff_id, start_date, end_date, assignments_count
11662 )
11663 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
11664 1 as assignments_count
11665 from buffer_schedules_824879560 as sc
11666 inner join buffer_assignment_limit_call_types_824879560 as alct
11667 on sc.call_type_id = alct.call_type_id
11668 inner join assignment_limits as al
11669 on alct.assignment_limit_id = al.id
11670 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
11671 and al.max_rolling_period is not null
11672 and al.max_rolling_limit is not null
11673 inner join assign_staff_types as ast
11674 on sc.staff_id = ast.staff_id
11675 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
11676 inner join buffer_assignment_limit_staff_types_824879560 as alst
11677 on alct.assignment_limit_id = alst.assignment_limit_id
11678 and ast.staff_type_id = alst.staff_type_id
11679 inner join (
11680 select assignment_limit_id, start_date, end_date
11681 from buffer_linkage_assignments_count_rolling_824879560
11682 group by assignment_limit_id, start_date, end_date
11683 order by null
11684 ) as lac
11685 on alct.assignment_limit_id = lac.assignment_limit_id
11686 and sc.schedule_on between lac.start_date and lac.end_date
11687 where sc.schedule_on = '2017-10-04'
11688 and sc.call_type_id = 47
11689 and sc.staff_id = 68
11690 on duplicate key update
11691 assignments_count = assignments_count + 1
11692
11693 (154.2ms) /* AssignmentLimitsConsecutive */
11694 /* Unique Key: assignment_limit_id, staff_id, schedule_on, start_date */
11695 insert ignore into buffer_staff_assignments_count_consecutive_824879560 (
11696 assignment_limit_id, staff_id, schedule_on, start_date, end_date
11697 )
11698 select lac.assignment_limit_id, sc.staff_id, sc.schedule_on, lac.start_date, lac.end_date
11699 from buffer_schedules_824879560 as sc
11700 inner join buffer_assignment_limit_call_types_824879560 as alct
11701 on sc.call_type_id = alct.call_type_id
11702 inner join assignment_limits as al
11703 on alct.assignment_limit_id = al.id
11704 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
11705 and al.max_consecutive_limit is not null
11706 inner join assign_staff_types as ast
11707 on sc.staff_id = ast.staff_id
11708 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
11709 inner join buffer_assignment_limit_staff_types_824879560 as alst
11710 on alct.assignment_limit_id = alst.assignment_limit_id
11711 and ast.staff_type_id = alst.staff_type_id
11712 inner join (
11713 select assignment_limit_id, start_date, end_date
11714 from buffer_linkage_assignments_count_consecutive_824879560
11715 group by assignment_limit_id, start_date, end_date
11716 order by null
11717 ) as lac
11718 on alct.assignment_limit_id = lac.assignment_limit_id
11719 and sc.schedule_on between lac.start_date and lac.end_date
11720 where sc.schedule_on = '2017-10-04'
11721 and sc.call_type_id = 47
11722 and sc.staff_id = 68
11723
11724INFO : (04-03 14:42:01) scheduled for: plan unit: [id:21201740] [2017-10-04 - BU], Andrew Church. DEPTH(1)
11725^C