· 8 years ago · Apr 25, 2018, 10:08 AM
1CalendarSchedule Load (148.4ms) SELECT `calendar_schedules`.* FROM `calendar_schedules` WHERE `calendar_schedules`.`client_id` = 319 AND `calendar_schedules`.`id` = 1381 ORDER BY `calendar_schedules`.`position` ASC LIMIT 1
2 Block Load (148.2ms) SELECT `blocks`.* FROM `blocks` INNER JOIN `block_schedules` ON `blocks`.`block_schedule_id` = `block_schedules`.`id` WHERE `block_schedules`.`id` = 447 AND `blocks`.`id` = 29253 ORDER BY start_date asc, end_date asc LIMIT 1
3 BlockSchedule Load (147.4ms) SELECT `block_schedules`.* FROM `block_schedules` WHERE `block_schedules`.`id` = 447 LIMIT 1
4 PopulationTimeframe Load (148.2ms) SELECT `population_timeframes`.* FROM `population_timeframes` WHERE `population_timeframes`.`client_id` = 319 AND `population_timeframes`.`timeframe_type` = 1 ORDER BY `population_timeframes`.`id` ASC LIMIT 1
5 RuleSet Load (148.6ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1506 LIMIT 1
6 Block Load (147.6ms) SELECT `blocks`.* FROM `blocks` INNER JOIN `block_schedules` ON `blocks`.`block_schedule_id` = `block_schedules`.`id` WHERE `block_schedules`.`id` = 447 AND (blocks.start_date >= '2018-05-01' AND blocks.end_date <= '2018-05-31') ORDER BY start_date asc, end_date asc
7INFO : (04-17 21:33:07) phase: Scheduler::Base
8INFO : (04-17 21:33:07) from: 2018-05-01 to: 2018-05-31
9 Rule Load (147.8ms) SELECT `rules`.* FROM `rules` WHERE `rules`.`rule_set_id` = 1506 ORDER BY applied desc, weight desc
10INFO : (04-17 21:33:08) rule configurations: 5. CUMULATIVE DAY OF WEEK TARGETS
11 - '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"=>"false"} weight:5
12 - 'Cumulative Assignment Targets' not applied
13 - 'Cumulative Combined Assignment Targets' not applied
14 - 'Cumulative Daily Assignment Targets' not applied
15 - 'Cumulative Hour Targets' not applied
16 - 'Cumulative Point Targets' not applied
17 - 'Cumulative Weekend / Weekday Assignment Targets' not applied
18 - 'Cumulative Weekend / Weekday Combined Assignment Targets' not applied
19 - 'Cumulative Weekend / Weekday Hour Targets' not applied
20 - 'Cumulative Weekend / Weekday Point Targets' not applied
21 - 'Current Assignment Targets' not applied
22 - 'Current Combined Assignment Targets' not applied
23 - 'Current Daily Assignment Targets' not applied
24 - 'Current Day of Week Targets' not applied
25 - 'Current Hour Targets' not applied
26 - 'Current Point Targets' not applied
27 - 'Current Weekend / Weekday Assignment Targets' not applied
28 - 'Current Weekend / Weekday Combined Assignment Targets' not applied
29 - 'Current Weekend / Weekday Hour Targets' not applied
30 - 'Current Weekend / Weekday Point Targets' not applied
31 - 'Pending Call Requests' not applied
32 - 'Pending No-call Requests' not applied
33 - 'Assignments Per Day' not applied
34 - 'Days Between Assignments' not applied
35 - 'Days Between Same Assignment' not applied
36 - 'Unassigned Days' not applied
37 - 'Weeks Between Same Assignment On Same Day Of Week' not applied
38 - 'Weeks Between Same Day Of Week' not applied
39INFO : (04-17 21:33:08) started: Scheduler::Cache::Collector.collect_all
40INFO : (04-17 21:33:08) collect_staffs
41 Staff Load (151.2ms) 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` = 319 AND `staffs`.`take_call` = 1 AND `staffs`.`active` = 1 ORDER BY `staffs`.`display_order` ASC, last_name, first_name
42 Client Load (151.2ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 319
43 StaffSpecialization Load (147.4ms) SELECT `staff_specializations`.* FROM `staff_specializations` WHERE `staff_specializations`.`staff_id` IN (20702, 20705, 20703, 20704, 20695, 20701, 20697, 20699, 20698, 20706, 20696)
44 Specialization Load (148.0ms) SELECT `specializations`.* FROM `specializations` WHERE `specializations`.`id` IN (711, 712) ORDER BY `specializations`.`priority` ASC
45 StaffCallType Load (150.1ms) SELECT `staff_call_types`.* FROM `staff_call_types` WHERE `staff_call_types`.`staff_id` IN (20702, 20705, 20703, 20704, 20695, 20701, 20697, 20699, 20698, 20706, 20696)
46INFO : (04-17 21:33:10) initial eligibles: [20702,20705,20703,20704,20695,20701,20697,20699,20698,20706,20696]
47INFO : (04-17 21:33:10) collect_call_types
48 CallType Load (148.4ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`client_id` = 319 AND `call_types`.`active` = 1 ORDER BY `call_types`.`display_order` ASC
49INFO : (04-17 21:33:11) initial call types: [12692,12693,12694,12706]
50INFO : (04-17 21:33:11) collect_chain_links
51 ChainLink Load (148.0ms) SELECT `chain_links`.* FROM `chain_links` WHERE `chain_links`.`client_id` = 319
52INFO : (04-17 21:33:11) collect_linkages
53 CallType Load (147.9ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 12693 LIMIT 1
54 CallType Load (147.6ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 12692 LIMIT 1
55 CallType Load (150.2ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 12692 LIMIT 1
56 CallType Load (147.9ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 12693 LIMIT 1
57 CallType Load (150.7ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 12693 LIMIT 1
58 CallType Load (149.1ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 12692 LIMIT 1
59 CallType Load (150.1ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 12692 LIMIT 1
60 CallType Load (149.3ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 12693 LIMIT 1
61INFO : (04-17 21:33:12) collect_schedules
62 Schedule Load (147.9ms) SELECT `schedules`.* FROM `schedules` WHERE `schedules`.`client_id` = 319 AND (`schedules`.`schedule_on` BETWEEN '2018-05-01' AND '2018-05-31')
63INFO : (04-17 21:33:13) collect_slots
64INFO : (04-17 21:33:13) collect_approved_call_requests
65 Request Load (148.6ms) SELECT `requests`.* FROM `requests` INNER JOIN `staffs` ON `staffs`.`id` = `requests`.`staff_id` WHERE `requests`.`client_id` = 319 AND `requests`.`request_type` = 1 AND `requests`.`status` = 1 AND (`requests`.`schedule_on` BETWEEN '2018-05-01' AND '2018-05-31') ORDER BY requests.schedule_on ASC, staffs.request_priority ASC, requests.created_at ASC
66INFO : (04-17 21:33:13) collect_approved_no_call_requests
67 Request Load (148.9ms) SELECT `requests`.* FROM `requests` WHERE `requests`.`client_id` = 319 AND `requests`.`request_type` = 0 AND `requests`.`status` = 1 AND (`requests`.`schedule_on` BETWEEN '2018-05-01' AND '2018-05-31') ORDER BY requests.schedule_on asc, requests.created_at asc
68INFO : (04-17 21:33:13) finished: Scheduler::Cache::Collector.collect_all
69INFO : (04-17 21:33:13) begin to process requests
70 CallType Load (149.0ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`calendar_schedule_id` = 1381 AND `call_types`.`active` = 1
71 (148.6ms) SELECT MAX(blocks.end_date) FROM `published_blocks` INNER JOIN `blocks` ON `blocks`.`id` = `published_blocks`.`block_id` WHERE `published_blocks`.`calendar_schedule_id` = 1381 AND ((published_blocks.assignment_ids IS NULL) AND (published_blocks.days_of_week_mask = 127))
72 Request Load (149.2ms) SELECT distinct requests.* FROM `requests` INNER JOIN `request_call_types` ON `request_call_types`.`request_id` = `requests`.`id` WHERE `requests`.`client_id` = 319 AND `requests`.`status` = 1 AND `requests`.`request_type` = 1 AND `request_call_types`.`call_type_id` IN (12692, 12693, 12694) AND (requests.schedule_on > '2018-04-30')
73 SQL (168.2ms) UPDATE `schedules` SET `schedules`.`populate_method` = 'auto_approved_request', `schedules`.`creator_id` = 166 WHERE `schedules`.`client_id` = 319 AND 1=0
74INFO : (04-17 21:33:14) end of requests processing
75 Block Load (148.4ms) SELECT `blocks`.* FROM `blocks` INNER JOIN `block_schedules` ON `blocks`.`block_schedule_id` = `block_schedules`.`id` WHERE `block_schedules`.`id` = 447 AND (blocks.start_date <= '2018-05-31' AND blocks.end_date >= '2018-05-31') ORDER BY start_date asc, end_date asc LIMIT 1
76 Client Load (150.1ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 319 LIMIT 1
77 NegativeLink Load (150.0ms) SELECT `negative_links`.* FROM `negative_links` WHERE `negative_links`.`client_id` = 319
78INFO : (04-17 21:33:15) <-- clear: 0 - Scheduler::AutoPopulate::Queries::CreateTables
79INFO : (04-17 21:33:15) <-- clear: 1 - Scheduler::AutoPopulate::Queries::AutoPopulateSlots
80INFO : (04-17 21:33:15) <-- clear: 2 - Scheduler::AutoPopulate::Queries::Query003
81INFO : (04-17 21:33:15) <-- clear: 3 - Scheduler::AutoPopulate::Queries::Query005
82INFO : (04-17 21:33:15) <-- clear: 4 - Scheduler::AutoPopulate::Queries::Query01
83INFO : (04-17 21:33:15) <-- clear: 5 - Scheduler::AutoPopulate::Queries::Query012
84INFO : (04-17 21:33:15) <-- clear: 6 - Scheduler::AutoPopulate::Queries::QueryTargets
85INFO : (04-17 21:33:15) <-- clear: 7 - Scheduler::AutoPopulate::Queries::Query013
86INFO : (04-17 21:33:15) <-- clear: 8 - Scheduler::AutoPopulate::Queries::Query014
87INFO : (04-17 21:33:15) <-- clear: 9 - Scheduler::AutoPopulate::Queries::Query015
88INFO : (04-17 21:33:15) <-- clear: 10 - Scheduler::AutoPopulate::Queries::Query02
89INFO : (04-17 21:33:15) <-- clear: 11 - Scheduler::AutoPopulate::Queries::Query03
90INFO : (04-17 21:33:15) <-- clear: 12 - Scheduler::AutoPopulate::Queries::Query04
91INFO : (04-17 21:33:15) <-- clear: 13 - Scheduler::AutoPopulate::Queries::Query045
92INFO : (04-17 21:33:15) <-- clear: 14 - Scheduler::AutoPopulate::Queries::QueryA
93INFO : (04-17 21:33:15) <-- clear: 15 - Scheduler::AutoPopulate::Queries::QueryB
94INFO : (04-17 21:33:15) <-- clear: 16 - Scheduler::AutoPopulate::Queries::Query05
95INFO : (04-17 21:33:15) <-- clear: 17 - Scheduler::AutoPopulate::Queries::Query06
96INFO : (04-17 21:33:15) <-- clear: 18 - Scheduler::AutoPopulate::Queries::Query07
97INFO : (04-17 21:33:15) <-- clear: 19 - Scheduler::AutoPopulate::Queries::Query0702
98INFO : (04-17 21:33:15) <-- clear: 20 - Scheduler::AutoPopulate::Queries::Query0705
99INFO : (04-17 21:33:15) <-- clear: 21 - Scheduler::AutoPopulate::Queries::Query0706
100INFO : (04-17 21:33:15) <-- clear: 22 - Scheduler::AutoPopulate::Queries::Query0707
101INFO : (04-17 21:33:15) <-- clear: 23 - Scheduler::AutoPopulate::Queries::Query0708
102INFO : (04-17 21:33:15) <-- clear: 24 - Scheduler::AutoPopulate::Queries::Query0709
103INFO : (04-17 21:33:15) <-- clear: 25 - Scheduler::AutoPopulate::Queries::Query07_10_AL
104INFO : (04-17 21:33:15) <-- clear: 26 - Scheduler::AutoPopulate::Queries::Query07_10_AL_01
105INFO : (04-17 21:33:15) <-- clear: 27 - Scheduler::AutoPopulate::Queries::Query07_10_AL_02
106INFO : (04-17 21:33:15) <-- clear: 28 - Scheduler::AutoPopulate::Queries::Query07_10_AL_03
107INFO : (04-17 21:33:15) <-- clear: 29 - Scheduler::AutoPopulate::Queries::Query07_10_AL_04
108INFO : (04-17 21:33:15) <-- clear: 30 - Scheduler::AutoPopulate::Queries::Query08
109INFO : (04-17 21:33:15) <-- clear: 31 - Scheduler::AutoPopulate::Queries::Query085
110INFO : (04-17 21:33:15) <-- clear: 32 - Scheduler::AutoPopulate::Queries::Query09
111INFO : (04-17 21:33:15) <-- clear: 33 - Scheduler::AutoPopulate::Queries::Query092
112INFO : (04-17 21:33:15) <-- clear: 34 - Scheduler::AutoPopulate::Queries::Query093
113INFO : (04-17 21:33:15) <-- clear: 35 - Scheduler::AutoPopulate::Queries::Query095
114INFO : (04-17 21:33:15) <-- clear: 36 - Scheduler::AutoPopulate::Queries::Query097
115INFO : (04-17 21:33:15) <-- clear: 37 - Scheduler::AutoPopulate::Queries::Query098
116INFO : (04-17 21:33:15) <-- clear: 38 - Scheduler::AutoPopulate::Queries::Query09_09_AL_01
117INFO : (04-17 21:33:15) <-- clear: 39 - Scheduler::AutoPopulate::Queries::Query09_09_AL_02
118INFO : (04-17 21:33:15) <-- clear: 40 - Scheduler::AutoPopulate::Queries::Query09_09_AL_03
119INFO : (04-17 21:33:15) <-- clear: 41 - Scheduler::AutoPopulate::Queries::Query09_09_AL_04
120INFO : (04-17 21:33:15) <-- clear: 42 - Scheduler::AutoPopulate::Queries::Query09_12_Points
121INFO : (04-17 21:33:15) <-- clear: 43 - Scheduler::AutoPopulate::Queries::Query09_12_Hours
122INFO : (04-17 21:33:15) <-- clear: 44 - Scheduler::AutoPopulate::Queries::Query10
123INFO : (04-17 21:33:15) <-- clear: 45 - Scheduler::AutoPopulate::Queries::QueryScore02
124INFO : (04-17 21:33:15) <-- clear: 46 - Scheduler::AutoPopulate::Queries::QueryScore03
125INFO : (04-17 21:33:15) <-- clear: 47 - Scheduler::AutoPopulate::Queries::QueryScore04
126INFO : (04-17 21:33:15) <-- clear: 48 - Scheduler::AutoPopulate::Queries::Query11
127INFO : (04-17 21:33:15) <-- clear: 49 - Scheduler::AutoPopulate::Queries::DropTables
128 (150.0ms) DROP TABLE IF EXISTS buffer_annual_hour_targets_1208161824
129 (148.8ms) DROP TABLE IF EXISTS buffer_annual_point_targets_1208161824
130 (148.9ms) DROP TABLE IF EXISTS buffer_annual_targets_staff_totals_1208161824
131 (148.9ms) DROP TABLE IF EXISTS buffer_auto_populate_slots_1208161824
132 (148.5ms) DROP TABLE IF EXISTS buffer_call_days_targets_1208161824
133 (152.0ms) DROP TABLE IF EXISTS buffer_call_type_targets_1208161824
134 (148.4ms) DROP TABLE IF EXISTS buffer_cumulative_cd_targets_1208161824
135 (148.5ms) DROP TABLE IF EXISTS buffer_cumulative_ct_targets_1208161824
136 (150.8ms) DROP TABLE IF EXISTS buffer_cumulative_dow_targets_1208161824
137 (149.7ms) DROP TABLE IF EXISTS buffer_cumulative_hour_targets_1208161824
138 (149.5ms) DROP TABLE IF EXISTS buffer_cumulative_oa_targets_1208161824
139 (148.5ms) DROP TABLE IF EXISTS buffer_cumulative_point_targets_1208161824
140 (149.4ms) DROP TABLE IF EXISTS buffer_current_cd_targets_1208161824
141 (148.4ms) DROP TABLE IF EXISTS buffer_current_ct_targets_1208161824
142 (148.6ms) DROP TABLE IF EXISTS buffer_current_dow_targets_1208161824
143 (148.6ms) DROP TABLE IF EXISTS buffer_current_hour_targets_1208161824
144 (149.2ms) DROP TABLE IF EXISTS buffer_current_oa_targets_1208161824
145 (148.7ms) DROP TABLE IF EXISTS buffer_current_point_targets_1208161824
146 (149.2ms) DROP TABLE IF EXISTS buffer_day_of_week_targets_1208161824
147 (150.0ms) DROP TABLE IF EXISTS buffer_hour_targets_1208161824
148 (149.7ms) DROP TABLE IF EXISTS buffer_linkage_call_days_targets_1208161824
149 (150.4ms) DROP TABLE IF EXISTS buffer_linkage_call_type_targets_1208161824
150 (148.7ms) DROP TABLE IF EXISTS buffer_linkage_targets_1208161824
151 (148.8ms) DROP TABLE IF EXISTS buffer_linkage_hour_targets_1208161824
152 (148.6ms) DROP TABLE IF EXISTS buffer_linkage_point_targets_1208161824
153 (148.5ms) DROP TABLE IF EXISTS buffer_location_privileges_1208161824
154 (148.9ms) DROP TABLE IF EXISTS buffer_periods_1208161824
155 (149.2ms) DROP TABLE IF EXISTS buffer_point_targets_1208161824
156 (148.7ms) DROP TABLE IF EXISTS buffer_schedules_1208161824
157 (149.5ms) DROP TABLE IF EXISTS buffer_target_call_types_1208161824
158 (149.0ms) DROP TABLE IF EXISTS buffer_target_daily_points_1208161824
159 (148.6ms) DROP TABLE IF EXISTS buffer_target_dates_list_1208161824
160 (148.9ms) DROP TABLE IF EXISTS buffer_target_primary_availabilities_1208161824
161 (148.9ms) DROP TABLE IF EXISTS buffer_targets_1208161824
162 (150.2ms) DROP TABLE IF EXISTS buffer_tmp_targets_availabilities_1208161824
163 (150.1ms) DROP TABLE IF EXISTS buffer_tmp_targets_availabilities_exclusions_1208161824
164 (148.5ms) DROP TABLE IF EXISTS buffer_tmp_targets_client_totals_1208161824
165 (148.8ms) DROP TABLE IF EXISTS buffer_tmp_targets_scheduled_1208161824
166 (148.6ms) DROP TABLE IF EXISTS buffer_tmp_targets_staff_totals_1208161824
167 (148.9ms) DROP TABLE IF EXISTS buffer_assignment_limit_call_types_1208161824
168 (148.9ms) DROP TABLE IF EXISTS buffer_assignment_limit_periods_1208161824
169 (148.2ms) DROP TABLE IF EXISTS buffer_assignment_limit_staff_types_1208161824
170 (148.9ms) DROP TABLE IF EXISTS buffer_auto_populate_slots_1208161824
171 (148.6ms) DROP TABLE IF EXISTS buffer_call_type_assignments_1208161824
172 (148.9ms) DROP TABLE IF EXISTS buffer_combined_availabilities_1208161824
173 (150.5ms) DROP TABLE IF EXISTS buffer_combined_availability_linkages_1208161824
174 (148.6ms) DROP TABLE IF EXISTS buffer_counter_increments_1208161824
175 (148.8ms) DROP TABLE IF EXISTS buffer_linkage_assigned_days_1208161824
176 (149.4ms) DROP TABLE IF EXISTS buffer_linkage_assignments_count_consecutive_1208161824
177 (148.5ms) DROP TABLE IF EXISTS buffer_linkage_assignments_count_periods_1208161824
178 (148.8ms) DROP TABLE IF EXISTS buffer_linkage_assignments_count_rolling_1208161824
179 (148.2ms) DROP TABLE IF EXISTS buffer_linkage_assignments_count_weeks_1208161824
180 (148.2ms) DROP TABLE IF EXISTS buffer_linkage_call_type_assignments_1208161824
181 (148.5ms) DROP TABLE IF EXISTS buffer_linkage_dow_targets_1208161824
182 (148.9ms) DROP TABLE IF EXISTS buffer_linkage_patterns_1208161824
183 (149.0ms) DROP TABLE IF EXISTS buffer_linkages_1208161824
184 (150.2ms) DROP TABLE IF EXISTS buffer_location_privileges_1208161824
185 (148.7ms) DROP TABLE IF EXISTS buffer_min_distances_1208161824
186 (150.5ms) DROP TABLE IF EXISTS buffer_negative_relations_1208161824
187 (148.9ms) DROP TABLE IF EXISTS buffer_rule_calc_filters_1208161824
188 (149.1ms) DROP TABLE IF EXISTS buffer_rule_calc_schedules_1208161824
189 (148.9ms) DROP TABLE IF EXISTS buffer_rule_scores_1208161824
190 (148.4ms) DROP TABLE IF EXISTS buffer_rule_scores_with_corrections_1208161824
191 (149.5ms) DROP TABLE IF EXISTS buffer_schedule_linkages_1208161824
192 (149.4ms) DROP TABLE IF EXISTS buffer_schedules_linkage_patterns_1208161824
193 (169.5ms) DROP TABLE IF EXISTS buffer_specialization_daily_counts_1208161824
194 (148.4ms) DROP TABLE IF EXISTS buffer_staff_assigned_days_1208161824
195 (148.7ms) DROP TABLE IF EXISTS buffer_staff_assignments_count_periods_1208161824
196 (149.3ms) DROP TABLE IF EXISTS buffer_staff_assignments_count_rolling_1208161824
197 (149.0ms) DROP TABLE IF EXISTS buffer_staff_assignments_count_weeks_1208161824
198 (148.9ms) DROP TABLE IF EXISTS buffer_staff_assignments_count_consecutive_1208161824
199 (149.2ms) DROP TABLE IF EXISTS buffer_staff_daily_counts_1208161824
200 (150.2ms) DROP TABLE IF EXISTS buffer_staff_specializations_1208161824
201 (150.6ms) DROP TABLE IF EXISTS buffer_static_availabilities_1208161824
202 (150.1ms) DROP TABLE IF EXISTS buffer_target_assignments_1208161824
203 (147.9ms) delete from buffer_target_dates
204 where session_id = 1208161824
205 and client_id = 319
206
207INFO : (04-17 21:33:26) --> fill: 0 - Scheduler::AutoPopulate::Queries::CreateTables
208 (152.5ms) CREATE TABLE IF NOT EXISTS buffer_assignment_limit_call_types_1208161824 LIKE buffer_assignment_limit_call_types
209 (152.6ms) CREATE TABLE IF NOT EXISTS buffer_assignment_limit_periods_1208161824 LIKE buffer_assignment_limit_periods
210 (150.8ms) CREATE TABLE IF NOT EXISTS buffer_assignment_limit_staff_types_1208161824 LIKE buffer_assignment_limit_staff_types
211 (151.1ms) CREATE TABLE IF NOT EXISTS buffer_auto_populate_slots_1208161824 LIKE buffer_auto_populate_slots
212 (151.9ms) CREATE TABLE IF NOT EXISTS buffer_call_type_assignments_1208161824 LIKE buffer_call_type_assignments
213 (151.3ms) CREATE TABLE IF NOT EXISTS buffer_combined_availabilities_1208161824 LIKE buffer_combined_availabilities
214 (157.5ms) CREATE TABLE IF NOT EXISTS buffer_combined_availability_linkages_1208161824 LIKE buffer_combined_availability_linkages
215 (153.6ms) CREATE TABLE IF NOT EXISTS buffer_counter_increments_1208161824 LIKE buffer_counter_increments
216 (151.1ms) CREATE TABLE IF NOT EXISTS buffer_linkage_assigned_days_1208161824 LIKE buffer_linkage_assigned_days
217 (151.6ms) CREATE TABLE IF NOT EXISTS buffer_linkage_assignments_count_consecutive_1208161824 LIKE buffer_linkage_assignments_count_consecutive
218 (151.9ms) CREATE TABLE IF NOT EXISTS buffer_linkage_assignments_count_periods_1208161824 LIKE buffer_linkage_assignments_count_periods
219 (151.7ms) CREATE TABLE IF NOT EXISTS buffer_linkage_assignments_count_rolling_1208161824 LIKE buffer_linkage_assignments_count_rolling
220 (151.4ms) CREATE TABLE IF NOT EXISTS buffer_linkage_assignments_count_weeks_1208161824 LIKE buffer_linkage_assignments_count_weeks
221 (151.5ms) CREATE TABLE IF NOT EXISTS buffer_linkage_call_type_assignments_1208161824 LIKE buffer_linkage_call_type_assignments
222 (151.6ms) CREATE TABLE IF NOT EXISTS buffer_linkage_dow_targets_1208161824 LIKE buffer_linkage_dow_targets
223 (152.0ms) CREATE TABLE IF NOT EXISTS buffer_linkage_patterns_1208161824 LIKE buffer_linkage_patterns
224 (152.6ms) CREATE TABLE IF NOT EXISTS buffer_linkages_1208161824 LIKE buffer_linkages
225 (151.4ms) CREATE TABLE IF NOT EXISTS buffer_location_privileges_1208161824 LIKE buffer_location_privileges
226 (151.5ms) CREATE TABLE IF NOT EXISTS buffer_min_distances_1208161824 LIKE buffer_min_distances
227 (151.8ms) CREATE TABLE IF NOT EXISTS buffer_negative_relations_1208161824 LIKE buffer_negative_relations
228 (152.3ms) CREATE TABLE IF NOT EXISTS buffer_rule_calc_filters_1208161824 LIKE buffer_rule_calc_filters
229 (151.3ms) CREATE TABLE IF NOT EXISTS buffer_rule_calc_schedules_1208161824 LIKE buffer_rule_calc_schedules
230 (151.6ms) CREATE TABLE IF NOT EXISTS buffer_rule_scores_1208161824 LIKE buffer_rule_scores
231 (151.5ms) CREATE TABLE IF NOT EXISTS buffer_rule_scores_with_corrections_1208161824 LIKE buffer_rule_scores_with_corrections
232 (151.8ms) CREATE TABLE IF NOT EXISTS buffer_schedule_linkages_1208161824 LIKE buffer_schedule_linkages
233 (151.1ms) CREATE TABLE IF NOT EXISTS buffer_schedules_linkage_patterns_1208161824 LIKE buffer_schedules_linkage_patterns
234 (151.9ms) CREATE TABLE IF NOT EXISTS buffer_specialization_daily_counts_1208161824 LIKE buffer_specialization_daily_counts
235 (161.8ms) CREATE TABLE IF NOT EXISTS buffer_staff_assigned_days_1208161824 LIKE buffer_staff_assigned_days
236 (151.7ms) CREATE TABLE IF NOT EXISTS buffer_staff_assignments_count_periods_1208161824 LIKE buffer_staff_assignments_count_periods
237 (152.2ms) CREATE TABLE IF NOT EXISTS buffer_staff_assignments_count_rolling_1208161824 LIKE buffer_staff_assignments_count_rolling
238 (151.9ms) CREATE TABLE IF NOT EXISTS buffer_staff_assignments_count_weeks_1208161824 LIKE buffer_staff_assignments_count_weeks
239 (152.5ms) CREATE TABLE IF NOT EXISTS buffer_staff_assignments_count_consecutive_1208161824 LIKE buffer_staff_assignments_count_consecutive
240 (151.2ms) CREATE TABLE IF NOT EXISTS buffer_staff_daily_counts_1208161824 LIKE buffer_staff_daily_counts
241 (151.8ms) CREATE TABLE IF NOT EXISTS buffer_staff_specializations_1208161824 LIKE buffer_staff_specializations
242 (151.4ms) CREATE TABLE IF NOT EXISTS buffer_static_availabilities_1208161824 LIKE buffer_static_availabilities
243 (163.3ms) CREATE TABLE IF NOT EXISTS buffer_target_assignments_1208161824 LIKE buffer_target_assignments
244 (152.7ms) CREATE TABLE IF NOT EXISTS buffer_annual_hour_targets_1208161824 LIKE buffer_annual_hour_targets
245 (151.1ms) CREATE TABLE IF NOT EXISTS buffer_annual_point_targets_1208161824 LIKE buffer_annual_point_targets
246 (151.3ms) CREATE TABLE IF NOT EXISTS buffer_annual_targets_staff_totals_1208161824 LIKE buffer_annual_targets_staff_totals
247 (148.5ms) CREATE TABLE IF NOT EXISTS buffer_auto_populate_slots_1208161824 LIKE buffer_auto_populate_slots
248 (151.2ms) CREATE TABLE IF NOT EXISTS buffer_call_days_targets_1208161824 LIKE buffer_call_days_targets
249 (151.5ms) CREATE TABLE IF NOT EXISTS buffer_call_type_targets_1208161824 LIKE buffer_call_type_targets
250 (154.0ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_cd_targets_1208161824 LIKE buffer_cumulative_cd_targets
251 (151.3ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_ct_targets_1208161824 LIKE buffer_cumulative_ct_targets
252 (151.2ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_dow_targets_1208161824 LIKE buffer_cumulative_dow_targets
253 (151.7ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_hour_targets_1208161824 LIKE buffer_cumulative_hour_targets
254 (155.9ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_oa_targets_1208161824 LIKE buffer_cumulative_oa_targets
255 (153.5ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_point_targets_1208161824 LIKE buffer_cumulative_point_targets
256 (170.5ms) CREATE TABLE IF NOT EXISTS buffer_current_cd_targets_1208161824 LIKE buffer_current_cd_targets
257 (152.5ms) CREATE TABLE IF NOT EXISTS buffer_current_ct_targets_1208161824 LIKE buffer_current_ct_targets
258 (151.2ms) CREATE TABLE IF NOT EXISTS buffer_current_dow_targets_1208161824 LIKE buffer_current_dow_targets
259 (151.0ms) CREATE TABLE IF NOT EXISTS buffer_current_hour_targets_1208161824 LIKE buffer_current_hour_targets
260 (161.5ms) CREATE TABLE IF NOT EXISTS buffer_current_oa_targets_1208161824 LIKE buffer_current_oa_targets
261 (151.0ms) CREATE TABLE IF NOT EXISTS buffer_current_point_targets_1208161824 LIKE buffer_current_point_targets
262 (152.2ms) CREATE TABLE IF NOT EXISTS buffer_day_of_week_targets_1208161824 LIKE buffer_day_of_week_targets
263 (151.6ms) CREATE TABLE IF NOT EXISTS buffer_hour_targets_1208161824 LIKE buffer_hour_targets
264 (153.6ms) CREATE TABLE IF NOT EXISTS buffer_linkage_call_days_targets_1208161824 LIKE buffer_linkage_call_days_targets
265 (151.5ms) CREATE TABLE IF NOT EXISTS buffer_linkage_call_type_targets_1208161824 LIKE buffer_linkage_call_type_targets
266 (151.2ms) CREATE TABLE IF NOT EXISTS buffer_linkage_targets_1208161824 LIKE buffer_linkage_targets
267 (151.7ms) CREATE TABLE IF NOT EXISTS buffer_linkage_hour_targets_1208161824 LIKE buffer_linkage_hour_targets
268 (151.1ms) CREATE TABLE IF NOT EXISTS buffer_linkage_point_targets_1208161824 LIKE buffer_linkage_point_targets
269 (149.0ms) CREATE TABLE IF NOT EXISTS buffer_location_privileges_1208161824 LIKE buffer_location_privileges
270 (152.0ms) CREATE TABLE IF NOT EXISTS buffer_periods_1208161824 LIKE buffer_periods
271 (151.0ms) CREATE TABLE IF NOT EXISTS buffer_point_targets_1208161824 LIKE buffer_point_targets
272 (151.6ms) CREATE TABLE IF NOT EXISTS buffer_schedules_1208161824 LIKE buffer_schedules
273 (153.4ms) CREATE TABLE IF NOT EXISTS buffer_target_call_types_1208161824 LIKE buffer_target_call_types
274 (152.6ms) CREATE TABLE IF NOT EXISTS buffer_target_daily_points_1208161824 LIKE buffer_target_daily_points
275 (151.5ms) CREATE TABLE IF NOT EXISTS buffer_target_dates_list_1208161824 LIKE buffer_target_dates_list
276 (152.8ms) CREATE TABLE IF NOT EXISTS buffer_target_primary_availabilities_1208161824 LIKE buffer_target_primary_availabilities
277 (159.6ms) CREATE TABLE IF NOT EXISTS buffer_targets_1208161824 LIKE buffer_targets
278 (151.7ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_availabilities_1208161824 LIKE buffer_tmp_targets_availabilities
279 (151.4ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_availabilities_exclusions_1208161824 LIKE buffer_tmp_targets_availabilities_exclusions
280 (151.4ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_client_totals_1208161824 LIKE buffer_tmp_targets_client_totals
281 (156.2ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_scheduled_1208161824 LIKE buffer_tmp_targets_scheduled
282 (151.5ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_staff_totals_1208161824 LIKE buffer_tmp_targets_staff_totals
283INFO : (04-17 21:33:38) --> fill: 1 - Scheduler::AutoPopulate::Queries::AutoPopulateSlots
284 (147.5ms) select
285 b.start_date,
286 b.end_date,
287 (pb.assignment_ids IS NULL) as fully_published,
288 concat(pbct.assignment_type, '#', pbct.assignment_id) as assignment_uid,
289 pbct.days_of_week_mask
290 from blocks as b
291 inner join published_blocks as pb
292 on pb.block_id = b.id
293 inner join published_block_call_types as pbct
294 on pbct.published_block_id = pb.id
295
296 where b.client_id = 319
297 and pb.calendar_schedule_id = 1381
298 and b.end_date BETWEEN '2018-05-01' AND '2018-05-31'
299
300 AutopopulateExclusion Load (151.4ms) SELECT `autopopulate_exclusions`.* FROM `autopopulate_exclusions` WHERE `autopopulate_exclusions`.`client_id` = 319 AND `autopopulate_exclusions`.`schedule_on` IN ('2018-05-01', '2018-05-02', '2018-05-03', '2018-05-04', '2018-05-05', '2018-05-06', '2018-05-07', '2018-05-08', '2018-05-09', '2018-05-10', '2018-05-11', '2018-05-12', '2018-05-13', '2018-05-14', '2018-05-15', '2018-05-16', '2018-05-17', '2018-05-18', '2018-05-19', '2018-05-20', '2018-05-21', '2018-05-22', '2018-05-23', '2018-05-24', '2018-05-25', '2018-05-26', '2018-05-27', '2018-05-28', '2018-05-29', '2018-05-30', '2018-05-31')
301 (152.2ms) INSERT INTO buffer_auto_populate_slots_1208161824
302 (schedule_on, day_of_week_mask, call_type_id, display_order, should_be_populated)
303 VALUES ('2018-05-01', '4', '12692', '0', 1), ('2018-05-01', '4', '12693', '1', 1), ('2018-05-01', '4', '12694', '3', 1), ('2018-05-02', '8', '12692', '0', 1), ('2018-05-02', '8', '12693', '1', 1), ('2018-05-02', '8', '12694', '3', 1), ('2018-05-03', '16', '12692', '0', 1), ('2018-05-03', '16', '12693', '1', 1), ('2018-05-03', '16', '12694', '3', 1), ('2018-05-04', '32', '12692', '0', 1), ('2018-05-04', '32', '12693', '1', 1), ('2018-05-04', '32', '12694', '3', 1), ('2018-05-05', '64', '12692', '0', 1), ('2018-05-05', '64', '12693', '1', 1), ('2018-05-05', '64', '12694', '3', 1), ('2018-05-06', '1', '12692', '0', 1), ('2018-05-06', '1', '12693', '1', 1), ('2018-05-06', '1', '12694', '3', 1), ('2018-05-07', '2', '12692', '0', 1), ('2018-05-07', '2', '12693', '1', 1), ('2018-05-07', '2', '12694', '3', 1), ('2018-05-08', '4', '12692', '0', 1), ('2018-05-08', '4', '12693', '1', 1), ('2018-05-08', '4', '12694', '3', 1), ('2018-05-09', '8', '12692', '0', 1), ('2018-05-09', '8', '12693', '1', 1), ('2018-05-09', '8', '12694', '3', 1), ('2018-05-10', '16', '12692', '0', 1), ('2018-05-10', '16', '12693', '1', 1), ('2018-05-10', '16', '12694', '3', 1), ('2018-05-11', '32', '12692', '0', 1), ('2018-05-11', '32', '12693', '1', 1), ('2018-05-11', '32', '12694', '3', 1), ('2018-05-12', '64', '12692', '0', 1), ('2018-05-12', '64', '12693', '1', 1), ('2018-05-12', '64', '12694', '3', 1), ('2018-05-13', '1', '12692', '0', 1), ('2018-05-13', '1', '12693', '1', 1), ('2018-05-13', '1', '12694', '3', 1), ('2018-05-14', '2', '12692', '0', 1), ('2018-05-14', '2', '12693', '1', 1), ('2018-05-14', '2', '12694', '3', 1), ('2018-05-15', '4', '12692', '0', 1), ('2018-05-15', '4', '12693', '1', 1), ('2018-05-15', '4', '12694', '3', 1), ('2018-05-16', '8', '12692', '0', 1), ('2018-05-16', '8', '12693', '1', 1), ('2018-05-16', '8', '12694', '3', 1), ('2018-05-17', '16', '12692', '0', 1), ('2018-05-17', '16', '12693', '1', 1), ('2018-05-17', '16', '12694', '3', 1), ('2018-05-18', '32', '12692', '0', 1), ('2018-05-18', '32', '12693', '1', 1), ('2018-05-18', '32', '12694', '3', 1), ('2018-05-19', '64', '12692', '0', 1), ('2018-05-19', '64', '12693', '1', 1), ('2018-05-19', '64', '12694', '3', 1), ('2018-05-20', '1', '12692', '0', 1), ('2018-05-20', '1', '12693', '1', 1), ('2018-05-20', '1', '12694', '3', 1), ('2018-05-21', '2', '12692', '0', 1), ('2018-05-21', '2', '12693', '1', 1), ('2018-05-21', '2', '12694', '3', 1), ('2018-05-22', '4', '12692', '0', 1), ('2018-05-22', '4', '12693', '1', 1), ('2018-05-22', '4', '12694', '3', 1), ('2018-05-23', '8', '12692', '0', 1), ('2018-05-23', '8', '12693', '1', 1), ('2018-05-23', '8', '12694', '3', 1), ('2018-05-24', '16', '12692', '0', 1), ('2018-05-24', '16', '12693', '1', 1), ('2018-05-24', '16', '12694', '3', 1), ('2018-05-25', '32', '12692', '0', 1), ('2018-05-25', '32', '12693', '1', 1), ('2018-05-25', '32', '12694', '3', 1), ('2018-05-26', '64', '12692', '0', 1), ('2018-05-26', '64', '12693', '1', 1), ('2018-05-26', '64', '12694', '3', 1), ('2018-05-27', '1', '12692', '0', 1), ('2018-05-27', '1', '12693', '1', 1), ('2018-05-27', '1', '12694', '3', 1), ('2018-05-28', '2', '12692', '0', 1), ('2018-05-28', '2', '12693', '1', 1), ('2018-05-28', '2', '12694', '3', 1), ('2018-05-29', '4', '12692', '0', 1), ('2018-05-29', '4', '12693', '1', 1), ('2018-05-29', '4', '12694', '3', 1), ('2018-05-30', '8', '12692', '0', 1), ('2018-05-30', '8', '12693', '1', 1), ('2018-05-30', '8', '12694', '3', 1), ('2018-05-31', '16', '12692', '0', 1), ('2018-05-31', '16', '12693', '1', 1), ('2018-05-31', '16', '12694', '3', 1)
304
305INFO : (04-17 21:33:39) --> fill: 2 - Scheduler::AutoPopulate::Queries::Query003
306 (149.5ms) insert into buffer_auto_populate_slots_1208161824/* client_id */ (
307 schedule_on,
308 day_of_week_mask,
309 call_type_id,
310 display_order,
311 should_be_populated
312 )
313 select distinct
314 date_add(
315 auto_populate_slots.schedule_on,
316 interval soft_linkages.offset day
317 ) as schedule_on,
318 (1 << (
319 dayofweek(
320 date_add(
321 auto_populate_slots.schedule_on,
322 interval soft_linkages.offset day
323 )
324 ) - 1
325 )
326 ) as day_of_week_mask,
327 soft_linkages.linked_call_type_id as call_type_id,
328 call_types.display_order,
329 0 as should_be_populated
330 from
331 buffer_auto_populate_slots_1208161824/* client_id */ as auto_populate_slots
332 inner join soft_linkages
333 on auto_populate_slots.call_type_id = soft_linkages.call_type_id
334 and auto_populate_slots.day_of_week_mask = soft_linkages.day_of_week_mask
335 left join buffer_auto_populate_slots_1208161824/* client_id */ as auto_populate_slots_2
336 on date_add(
337 auto_populate_slots.schedule_on,
338 interval soft_linkages.offset day
339 ) = auto_populate_slots_2.schedule_on
340 and soft_linkages.linked_call_type_id = auto_populate_slots_2.call_type_id
341 inner join call_types
342 on soft_linkages.linked_call_type_id = call_types.id
343 where auto_populate_slots_2.id is null
344 order by null
345
346INFO : (04-17 21:33:39) --> fill: 3 - Scheduler::AutoPopulate::Queries::Query005
347 (156.8ms) insert into buffer_auto_populate_slots_1208161824 (
348 schedule_on,
349 day_of_week_mask,
350 call_type_id,
351 display_order,
352 should_be_populated
353 )
354 select distinct
355 date_add(
356 auto_populate_slots.schedule_on,
357 interval linkage_relations.distance_in_days day
358 ) as schedule_on,
359 (1 << (
360 dayofweek(
361 date_add(
362 auto_populate_slots.schedule_on,
363 interval linkage_relations.distance_in_days day
364 )
365 ) - 1
366 )
367 ) as day_of_week_mask,
368 linkage_relations.linked_call_type_id as call_type_id,
369 call_types.display_order,
370 0 as should_be_populated
371 from
372 buffer_auto_populate_slots_1208161824 as auto_populate_slots
373 inner join linkage_relations
374 on auto_populate_slots.call_type_id = linkage_relations.call_type_id
375 and auto_populate_slots.day_of_week_mask = linkage_relations.day_of_week_mask
376 left join buffer_auto_populate_slots_1208161824 as auto_populate_slots_2
377 on date_add(
378 auto_populate_slots.schedule_on,
379 interval linkage_relations.distance_in_days day
380 ) = auto_populate_slots_2.schedule_on
381 and linkage_relations.linked_call_type_id = auto_populate_slots_2.call_type_id
382 inner join call_types
383 on linkage_relations.linked_call_type_id = call_types.id
384 where auto_populate_slots_2.id is null
385 order by null
386
387INFO : (04-17 21:33:39) --> fill: 4 - Scheduler::AutoPopulate::Queries::Query01
388 (152.0ms) insert into linkage_relations (
389 client_id,
390 call_type_id,
391 day_of_week_mask,
392 linked_call_type_id,
393 distance_in_days,
394 linkage_template_id
395 )
396 select distinct
397 319 /* client_id */ as client_id,
398 aps.call_type_id,
399 aps.day_of_week_mask,
400 aps.call_type_id as linked_call_type_id,
401 0 as distance_in_days,
402 coalesce(
403 lr.linkage_template_id,
404 @linkage_template_max := @linkage_template_max + 1
405 ) as linkage_template_id
406 from
407 buffer_auto_populate_slots_1208161824/* client_id */ as aps
408 inner join (
409 select @linkage_template_max := count(distinct linkage_template_id) - 1
410 from linkage_relations
411 where client_id = 319 /* client_id */
412 order by null
413 ) as lt
414 on 1 = 1
415 left join linkage_relations as lr use index (ix_linkage_relations_composite1)
416 on aps.call_type_id = lr.call_type_id
417 and aps.day_of_week_mask = lr.day_of_week_mask
418 left join linkage_relations as lr_2 use index (ix_linkage_relations_composite1)
419 on aps.call_type_id = lr_2.call_type_id
420 and aps.day_of_week_mask = lr_2.day_of_week_mask
421 and aps.call_type_id = lr_2.linked_call_type_id
422 and lr_2.distance_in_days = 0
423 where lr_2.id is null
424 order by null
425
426 (167.6ms) insert into buffer_schedules_1208161824 (
427 call_type_id,
428 staff_id,
429 schedule_on,
430 day_of_week_mask,
431 is_weekend,
432 display_order,
433 week_number,
434 should_be_evaluated,
435 should_be_populated,
436 linkage_instance_id
437 )
438 select
439 call_type_id,
440 staff_id,
441 schedule_on,
442 day_of_week_mask,
443 is_weekend,
444 display_order,
445 week_number,
446 max(should_be_evaluated) as should_be_evaluated,
447 max(should_be_populated) as should_be_populated,
448 min(linkage_instance_id) as linkage_instance_id
449 from (
450 select
451 auto_populate_slots_2.call_type_id,
452 schedules.staff_id,
453 auto_populate_slots_2.schedule_on,
454 auto_populate_slots_2.day_of_week_mask,
455 case
456 when (auto_populate_slots_2.day_of_week_mask & 62 > 0) then 0
457 else 1
458 end as is_weekend,
459 auto_populate_slots_2.display_order,
460 yearweek(
461 auto_populate_slots_2.schedule_on,
462 case
463 when (clients.start_of_week = 0) then 2
464 else 7
465 end
466 ) as week_number,
467 case
468 when (schedules.staff_id is null) then 1
469 else 0
470 end as should_be_evaluated,
471 (
472 case
473 when (
474 auto_populate_slots_2.should_be_populated = 1
475 and schedules.staff_id is null
476 ) then 1
477 else 0
478 end
479 ) as should_be_populated,
480 (
481 linkage_relations.linkage_template_id * 1000000 +
482 yearweek(
483 auto_populate_slots.schedule_on,
484 case
485 when (clients.start_of_week = 0) then 2
486 else 7
487 end
488 )
489 ) as linkage_instance_id
490 from
491 buffer_auto_populate_slots_1208161824 as auto_populate_slots
492 inner join clients
493 on clients.id = 319 /* client_id */
494 inner join linkage_relations
495 on auto_populate_slots.call_type_id = linkage_relations.call_type_id
496 and auto_populate_slots.day_of_week_mask = linkage_relations.day_of_week_mask
497 inner join buffer_auto_populate_slots_1208161824 as auto_populate_slots_2
498 on date_add(
499 auto_populate_slots.schedule_on,
500 interval linkage_relations.distance_in_days day
501 ) = auto_populate_slots_2.schedule_on
502 and linkage_relations.linked_call_type_id = auto_populate_slots_2.call_type_id
503 left join schedules
504 on auto_populate_slots_2.call_type_id = schedules.call_type_id
505 and auto_populate_slots_2.schedule_on = schedules.schedule_on
506 order by null
507 ) as t1
508 group by
509 call_type_id,
510 staff_id,
511 schedule_on,
512 day_of_week_mask,
513 display_order,
514 week_number
515 order by null
516
517INFO : (04-17 21:33:39) --> fill: 5 - Scheduler::AutoPopulate::Queries::Query012
518 (156.7ms) update
519 buffer_schedules_1208161824 as sc
520 inner join call_types as ct
521 on sc.call_type_id = ct.id
522 inner join calendar_schedules as cs
523 on ct.calendar_schedule_id = cs.id
524 inner join blocks as b
525 on cs.block_schedule_id = b.block_schedule_id
526 and sc.schedule_on between b.start_date and b.end_date
527 set
528 sc.calendar_schedule_id = cs.id,
529 sc.block_id = b.id
530
531 BlockSchedule Load (147.6ms) SELECT `block_schedules`.* FROM `block_schedules` WHERE `block_schedules`.`id` = 447 LIMIT 1
532 (162.2ms) insert into buffer_periods_1208161824 (
533 calendar_schedule_id,
534 block_schedule_id,
535 period_offset,
536 start_block_display_order,
537 end_block_display_order,
538 start_date,
539 end_date,
540 should_be_populated,
541 should_be_evaluated
542 )
543 select
544 t1.calendar_schedule_id,
545 t1.block_schedule_id,
546 t1.period_offset,
547 t2.start_block_display_order,
548 t2.end_block_display_order,
549 t2.start_date,
550 t2.end_date,
551 t1.should_be_populated,
552 t1.should_be_evaluated
553 from (
554 select
555 sc.calendar_schedule_id,
556 b.block_schedule_id,
557 case
558 when ((month(b.start_date) - pt.begin_period) >= 0)
559 then (year(b.start_date) * 100 + (month(b.start_date) - pt.begin_period) div pt.timeframe_type)
560 else
561 ((year(b.start_date) - 1) * 100 + (month(b.start_date) + 12 - pt.begin_period) div pt.timeframe_type)
562 end as period_offset,
563 max(sc.should_be_populated) as should_be_populated,
564 max(sc.should_be_evaluated) as should_be_evaluated
565 from (
566 select
567 sc.block_id,
568 sc.calendar_schedule_id,
569 max(ps.should_be_populated) as should_be_populated,
570 1 as should_be_evaluated
571 from
572 buffer_schedules_1208161824 as sc
573 inner join buffer_auto_populate_slots_1208161824 as ps
574 on sc.schedule_on = ps.schedule_on
575 and sc.call_type_id = ps.call_type_id
576 group by
577 sc.block_id,
578 sc.calendar_schedule_id
579 order by null
580 ) as sc
581 inner join blocks as b
582 on sc.block_id = b.id
583 inner join population_timeframes as pt
584 on pt.client_id = 319
585 and pt.timeframe_type = 1
586 group by
587 sc.calendar_schedule_id,
588 b.block_schedule_id,
589 period_offset
590 order by null
591 ) as t1
592 inner join (
593 select
594 b.block_schedule_id,
595 case
596 when ((month(b.start_date) - pt.begin_period) >= 0)
597 then (year(b.start_date) * 100 + (month(b.start_date) - pt.begin_period) div pt.timeframe_type)
598 else
599 ((year(b.start_date) - 1) * 100 + (month(b.start_date) + 12 - pt.begin_period) div pt.timeframe_type)
600 end as period_offset,
601 min(b.display_order) as start_block_display_order,
602 max(b.display_order) as end_block_display_order,
603 min(b.start_date) as start_date,
604 max(b.end_date) as end_date
605 from
606 blocks as b
607 inner join population_timeframes as pt
608 on pt.client_id = 319
609 and pt.timeframe_type = 1
610 where
611 b.client_id = 319
612 group by
613 b.block_schedule_id,
614 period_offset
615 order by null
616 ) as t2
617 on t1.block_schedule_id = t2.block_schedule_id
618 and t1.period_offset = t2.period_offset
619 order by null
620
621 (150.2ms) update
622 buffer_schedules_1208161824 as sc
623 inner join buffer_periods_1208161824 as p
624 on sc.calendar_schedule_id = p.calendar_schedule_id
625 and sc.schedule_on between p.start_date and p.end_date
626 set sc.period_offset = p.period_offset
627
628INFO : (04-17 21:33:40) --> fill: 6 - Scheduler::AutoPopulate::Queries::QueryTargets
629 (147.9ms) delete from buffer_target_dates
630 where session_id = 1208161824
631
632 (146.4ms) select distinct calendar_schedule_id
633 from buffer_periods_1208161824
634
635 (162.1ms) insert into buffer_target_dates (
636 session_id,
637 client_id,
638 calendar_schedule_id,
639 block_id,
640 start_date,
641 end_date,
642 block_display_order,
643 period_offset,
644 build_cd_targets,
645 cd_targets_source,
646 copy_cd_targets,
647 build_ct_targets,
648 ct_targets_source,
649 copy_ct_targets,
650 build_oa_targets,
651 oa_targets_source,
652 copy_oa_targets,
653 build_dow_targets,
654 dow_targets_source,
655 copy_dow_targets,
656 build_point_targets,
657 point_targets_source,
658 copy_point_targets,
659 build_hour_targets,
660 hour_targets_source,
661 copy_hour_targets,
662 is_published,
663 affected_by_populate,
664 within_cumulative_period
665 )
666 select
667 1208161824 as session_id,
668 319 as client_id,
669 t1.calendar_schedule_id,
670 t1.block_id,
671 t1.start_date,
672 t1.end_date,
673 t1.block_display_order,
674 t1.period_offset,
675 case
676 when (
677 (
678 FALSE
679 )
680 and t1.is_published = 0
681 and coalesce(pb.has_unpublished, 1) = 1
682 and cd_u.block_id is null
683 ) then 1
684 else 0
685 end as build_cd_targets,
686 case
687 when (
688 t1.is_published = 1
689 or (
690 pb.has_published = 1
691 and pb.has_unpublished = 0
692 )
693 ) then 'published'
694 when (
695 coalesce(pb.has_published, 0) = 0
696 and coalesce(pb.has_unpublished, 1) = 1
697 and cd_u.block_id is not null
698 ) then 'unpublished'
699 when (
700 pb.has_published = 1
701 and pb.has_unpublished = 1
702 and cd_u.block_id is not null
703 ) then 'both'
704 else ''
705 end as cd_targets_source,
706 0 as copy_cd_targets,
707 case
708 when (
709 (
710 FALSE
711 )
712 and t1.is_published = 0
713 and coalesce(pb.has_unpublished, 1) = 1
714 and ct_u.block_id is null
715 ) then 1
716 else 0
717 end as build_ct_targets,
718 case
719 when (
720 t1.is_published = 1
721 or (
722 pb.has_published = 1
723 and pb.has_unpublished = 0
724 )
725 ) then 'published'
726 when (
727 coalesce(pb.has_published, 0) = 0
728 and coalesce(pb.has_unpublished, 1) = 1
729 and ct_u.block_id is not null
730 ) then 'unpublished'
731 when (
732 pb.has_published = 1
733 and pb.has_unpublished = 1
734 and ct_u.block_id is not null
735 ) then 'both'
736 else ''
737 end as ct_targets_source,
738 0 as copy_ct_targets,
739 case
740 when (
741 (
742 FALSE
743 )
744 and t1.is_published = 0
745 and oa_u.block_id is null
746 ) then 1
747 else 0
748 end as build_oa_targets,
749 case
750 when (t1.is_published = 1) then 'published'
751 when (oa_u.block_id is not null) then 'unpublished'
752 else ''
753 end as oa_targets_source,
754 0 as copy_oa_targets,
755 case
756 when (
757 (
758 t1.within_cumulative_period = 1 /* AnnualDayOfWeekMixRule */
759 )
760 and t1.is_published = 0
761 and dow_u.block_id is null
762 ) then 1
763 else 0
764 end as build_dow_targets,
765 case
766 when (t1.is_published = 1) then 'published'
767 when (dow_u.block_id is not null) then 'unpublished'
768 else ''
769 end as dow_targets_source,
770 0 as copy_dow_targets,
771 case
772 when (
773 (
774 FALSE
775 )
776 and t1.is_published = 0
777 and p_u.block_id is null
778 ) then 1
779 else 0
780 end as build_point_targets,
781 case
782 when (t1.is_published = 1) then 'published'
783 when (p_u.block_id is not null) then 'unpublished'
784 else ''
785 end as point_targets_source,
786 0 as copy_point_targets,
787 case
788 when (
789 (
790 FALSE
791 )
792 and t1.is_published = 0
793 and h_u.block_id is null
794 ) then 1
795 else 0
796 end as build_hour_targets,
797 case
798 when (t1.is_published = 1) then 'published'
799 when (h_u.block_id is not null) then 'unpublished'
800 else ''
801 end as hour_targets_source,
802 0 as copy_hour_targets,
803 t1.is_published,
804 t1.affected_by_populate,
805 t1.within_cumulative_period
806 from (
807 select
808 t1.calendar_schedule_id,
809 b.id as block_id,
810 b.start_date,
811 b.end_date,
812 t1.block_display_order,
813 p.period_offset,
814 case
815 when (t1.block_display_order between t1.start_block_display_order and t1.end_block_display_order) then 1
816 else 0
817 end as affected_by_populate,
818 case
819 when (t1.block_display_order between (t1.timeframe_ending - (2 - 1)) and t1.timeframe_ending) then 1
820 else 0
821 end as within_cumulative_period,
822 case
823 when (pb.id is not null) then 1
824 else 0
825 end as is_published
826 from (
827 select
828 t1.calendar_schedule_id,
829 t1.block_schedule_id,
830 (t1.end_block_display_order - ns.item_number) as block_display_order,
831 t1.start_block_display_order,
832 t1.end_block_display_order,
833 t1.timeframe_ending
834 from (
835 select
836 calendar_schedule_id,
837 block_schedule_id,
838 min(start_block_display_order) as start_block_display_order,
839 max(end_block_display_order) as end_block_display_order,
840 max(
841 case
842 when (should_be_populated = 1) then end_block_display_order
843 else null
844 end
845 ) as timeframe_ending
846 from
847 buffer_periods_1208161824
848 group by
849 calendar_schedule_id,
850 block_schedule_id
851 order by null
852 ) as t1
853 inner join numeric_sequence as ns
854 on ns.item_number < greatest(1 /* current targets period */, 2 /* cumulative targets period */)
855 and t1.end_block_display_order >= ns.item_number
856 where
857 (t1.end_block_display_order - ns.item_number) /* block display order */
858 between t1.start_block_display_order and t1.end_block_display_order
859 or (t1.end_block_display_order - ns.item_number)
860 between (t1.timeframe_ending - (2 /* cumulative targets period */ - 1)) and t1.timeframe_ending
861 order by null
862 ) as t1
863 inner join blocks as b
864 on t1.block_schedule_id = b.block_schedule_id
865 and t1.block_display_order = b.display_order
866 left join buffer_periods_1208161824 as p
867 on t1.calendar_schedule_id = p.calendar_schedule_id
868 and t1.block_display_order between p.start_block_display_order and p.end_block_display_order
869 left join published_blocks as pb
870 on b.id = pb.block_id
871 and t1.calendar_schedule_id = pb.calendar_schedule_id
872 and pb.assignment_ids is null
873 and pb.days_of_week_mask = 127
874 order by null
875 ) as t1
876 left join (
877 select
878 calendar_schedule_id,
879 block_id
880 from
881 unpublished_call_days_targets
882 where
883 calendar_schedule_id in (1381) /* list of calendar schedules */
884 group by
885 calendar_schedule_id,
886 block_id
887 order by null
888 ) as cd_u
889 on t1.calendar_schedule_id = cd_u.calendar_schedule_id
890 and t1.block_id = cd_u.block_id
891 left join (
892 select
893 calendar_schedule_id,
894 block_id
895 from
896 unpublished_call_type_targets
897 where
898 calendar_schedule_id in (1381) /* list of calendar schedules */
899 group by
900 calendar_schedule_id,
901 block_id
902 order by null
903 ) as ct_u
904 on t1.calendar_schedule_id = ct_u.calendar_schedule_id
905 and t1.block_id = ct_u.block_id
906 left join (
907 select
908 calendar_schedule_id,
909 block_id
910 from
911 unpublished_targets
912 where
913 calendar_schedule_id in (1381) /* list of calendar schedules */
914 group by
915 calendar_schedule_id,
916 block_id
917 order by null
918 ) as oa_u
919 on t1.calendar_schedule_id = oa_u.calendar_schedule_id
920 and t1.block_id = oa_u.block_id
921 left join (
922 select
923 calendar_schedule_id,
924 block_id
925 from
926 unpublished_day_of_week_targets
927 where
928 calendar_schedule_id in (1381) /* list of calendar schedules */
929 group by
930 calendar_schedule_id,
931 block_id
932 order by null
933 ) as dow_u
934 on t1.calendar_schedule_id = dow_u.calendar_schedule_id
935 and t1.block_id = dow_u.block_id
936 left join (
937 select
938 calendar_schedule_id,
939 block_id
940 from
941 unpublished_point_targets
942 where
943 calendar_schedule_id in (1381) /* list of calendar schedules */
944 group by
945 calendar_schedule_id,
946 block_id
947 order by null
948 ) as p_u
949 on t1.calendar_schedule_id = p_u.calendar_schedule_id
950 and t1.block_id = p_u.block_id
951 left join (
952 select
953 calendar_schedule_id,
954 block_id
955 from
956 unpublished_hour_targets
957 where
958 calendar_schedule_id in (1381) /* list of calendar schedules */
959 group by
960 calendar_schedule_id,
961 block_id
962 order by null
963 ) as h_u
964 on t1.calendar_schedule_id = h_u.calendar_schedule_id
965 and t1.block_id = h_u.block_id
966 left join (
967 select
968 pb.calendar_schedule_id,
969 pb.block_id,
970 max(
971 case
972 when (coalesce(pbct.days_of_week_mask, 0) > 0) then 1
973 else 0
974 end
975 ) as has_published,
976 max(
977 case
978 when (coalesce(pbct.days_of_week_mask, 0) < 127) then 1
979 else 0
980 end
981 ) as has_unpublished
982 from (
983 select
984 case
985 when (tg.id is null) then ct.id
986 else tg.id
987 end as assignment_id,
988 case
989 when (tg.id is null) then 'CallType'
990 else 'TargetGroup'
991 end as assignment_type,
992 ct.calendar_schedule_id
993 from
994 call_types as ct
995 left join target_group_calls as tgc
996 on ct.id = tgc.call_type_id
997 left join target_groups as tg
998 on tgc.target_group_id = tg.id
999 and tg.active = 1
1000 where
1001 ct.calendar_schedule_id in (1381) /* list of calendar schedules */
1002 and ct.active = 1
1003 and ct.included_in_targets > 0
1004 and ct.days_of_week_mask > 0
1005 group by
1006 assignment_id,
1007 assignment_type,
1008 ct.calendar_schedule_id
1009 order by null
1010 ) as ct
1011 inner join published_blocks as pb
1012 on ct.calendar_schedule_id = pb.calendar_schedule_id
1013 and (
1014 pb.assignment_ids is not null
1015 or pb.days_of_week_mask < 127
1016 )
1017 left join published_block_call_types as pbct
1018 on pb.id = pbct.published_block_id
1019 and ct.assignment_id = pbct.assignment_id
1020 and ct.assignment_type = pbct.assignment_type
1021 group by
1022 pb.calendar_schedule_id,
1023 pb.block_id
1024 order by null
1025 ) as pb
1026 on t1.calendar_schedule_id = pb.calendar_schedule_id
1027 and t1.block_id = pb.block_id
1028 order by null
1029
1030Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0101 - 458.57599999999996ms
1031 (150.0ms) /*
1032 MonthlyCallMixRule, CurrentWeeklyCallTypeTargetsRule, AnnualCallMixRule, CumulativeWeeklyCallTypeTargetsRule,
1033 StaffCapacityRule, CurrentWeeklyOverallTargetsRule, AnnualTargetsRule, CumulativeWeeklyOverallTargetsRule,
1034 MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule
1035 */
1036 update buffer_target_dates
1037 set build_cd_targets = 1
1038 where
1039 session_id = 1208161824
1040 and build_cd_targets = 0
1041 and cd_targets_source = ''
1042 and (
1043 build_dow_targets = 1 /* MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule */
1044 )
1045
1046 (148.1ms) /*
1047 MonthlyCallMixRule, CurrentWeeklyCallTypeTargetsRule, AnnualCallMixRule, CumulativeWeeklyCallTypeTargetsRule,
1048 StaffCapacityRule, CurrentWeeklyOverallTargetsRule, AnnualTargetsRule, CumulativeWeeklyOverallTargetsRule,
1049 MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule
1050 */
1051 update buffer_target_dates
1052 set
1053 build_dow_targets = 1, dow_targets_source = '' /* MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule */
1054 where
1055 session_id = 1208161824
1056 and build_cd_targets = 1
1057
1058Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0102 - 299.06100000000004ms
1059 (148.4ms) /*
1060 MonthlyCallMixRule, CurrentWeeklyCallTypeTargetsRule, AnnualCallMixRule, CumulativeWeeklyCallTypeTargetsRule,
1061 StaffCapacityRule, CurrentWeeklyOverallTargetsRule, AnnualTargetsRule, CumulativeWeeklyOverallTargetsRule,
1062 MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule
1063 */
1064
1065 insert into buffer_call_days_targets_1208161824 (
1066 calendar_schedule_id,
1067 block_id,
1068 staff_id,
1069 assignment_id,
1070 assignment_type,
1071 day_of_week_mask,
1072 is_weekend,
1073 raw_target,
1074 target,
1075 initial_target,
1076 scheduled,
1077 available_days
1078 )
1079 select
1080 cdt.calendar_schedule_id,
1081 cdt.block_id,
1082 cdt.staff_id,
1083 cdt.assignment_id,
1084 cdt.assignment_type,
1085 cdt.day_of_week_mask,
1086 cdt.is_weekend,
1087 cdt.raw_target,
1088 cdt.target,
1089 cdt.initial_target,
1090 cdt.scheduled,
1091 cdt.available_days
1092 from
1093 buffer_target_dates as td
1094 inner join call_days_targets as cdt
1095 on td.calendar_schedule_id = cdt.calendar_schedule_id
1096 and td.block_id = cdt.block_id
1097 where
1098 td.session_id = 1208161824
1099 and td.build_cd_targets = 0
1100 and td.cd_targets_source in ('published', 'both')
1101 and (
1102 td.build_dow_targets = 1 /* MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule */
1103 )
1104 order by null
1105
1106 (147.8ms) /*
1107 MonthlyCallMixRule, CurrentWeeklyCallTypeTargetsRule, AnnualCallMixRule, CumulativeWeeklyCallTypeTargetsRule,
1108 StaffCapacityRule, CurrentWeeklyOverallTargetsRule, AnnualTargetsRule, CumulativeWeeklyOverallTargetsRule,
1109 MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule
1110 */
1111 insert into buffer_call_days_targets_1208161824 (
1112 calendar_schedule_id,
1113 block_id,
1114 staff_id,
1115 assignment_id,
1116 assignment_type,
1117 day_of_week_mask,
1118 is_weekend,
1119 raw_target,
1120 target,
1121 initial_target,
1122 scheduled,
1123 available_days
1124 )
1125 select
1126 ucdt.calendar_schedule_id,
1127 ucdt.block_id,
1128 ucdt.staff_id,
1129 ucdt.assignment_id,
1130 ucdt.assignment_type,
1131 ucdt.day_of_week_mask,
1132 ucdt.is_weekend,
1133 ucdt.raw_target,
1134 ucdt.target,
1135 ucdt.initial_target,
1136 ucdt.scheduled,
1137 ucdt.available_days
1138 from
1139 buffer_target_dates as td
1140 inner join unpublished_call_days_targets as ucdt
1141 on td.calendar_schedule_id = ucdt.calendar_schedule_id
1142 and td.block_id = ucdt.block_id
1143 where
1144 td.session_id = 1208161824
1145 and td.build_cd_targets = 0
1146 and td.cd_targets_source in ('unpublished', 'both')
1147 and (
1148 td.build_dow_targets = 1 /* MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule */
1149 )
1150 order by null
1151
1152Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0103 - 297.368ms
1153 (147.3ms) select
1154 max(build_cd_targets) as build_cd_targets,
1155 max(build_ct_targets) as build_ct_targets,
1156 max(build_oa_targets) as build_oa_targets,
1157 max(build_dow_targets) as build_dow_targets,
1158 max(build_point_targets) as build_point_targets,
1159 max(build_hour_targets) as build_hour_targets
1160 from buffer_target_dates
1161 where session_id = 1208161824
1162 order by null
1163
1164Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets02 - 147.773ms
1165 (148.2ms) select distinct calendar_schedule_id
1166 from buffer_target_dates
1167 where
1168 session_id = 1208161824
1169 and (
1170 build_cd_targets = 1
1171 or build_ct_targets = 1
1172 or build_oa_targets = 1
1173 or build_dow_targets = 1
1174 )
1175
1176 (149.0ms) truncate table buffer_target_call_types_1208161824
1177
1178 (151.1ms) insert into buffer_target_call_types_1208161824 (
1179 id,
1180 target_group_id,
1181 assignment_id,
1182 assignment_type,
1183 calendar_schedule_id,
1184 days_of_week_mask,
1185 hours,
1186 points_days_of_week_mask,
1187 included_in_targets,
1188 all_staff_types,
1189 location_id
1190 )
1191 select
1192 ct.id,
1193 coalesce(tg.id, 0) as target_group_id,
1194 case
1195 when (tg.id is null) then ct.id
1196 else tg.id
1197 end as assignment_id,
1198 case
1199 when (tg.id is null) then 'CallType'
1200 else 'TargetGroup'
1201 end as assignment_type,
1202 ct.calendar_schedule_id,
1203 ct.days_of_week_mask,
1204 null as hours,
1205 null as points_days_of_week_mask,
1206 ct.included_in_targets,
1207 ct.all_staff_types,
1208 ct.location_id
1209 from
1210 call_types as ct
1211 left join target_group_calls as tgc
1212 on ct.id = tgc.call_type_id
1213 left join target_groups as tg
1214 on tgc.target_group_id = tg.id
1215 and tg.active = 1
1216 where
1217 ct.calendar_schedule_id in (1381)
1218 and ct.active = 1
1219 and ct.days_of_week_mask > 0
1220 and ct.included_in_targets > 0
1221 order by null
1222
1223Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets02Calls - 449.586ms
1224 (168.0ms) select id from buffer_target_call_types_1208161824 limit 1
1225 Block Exists (146.9ms) 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` = 447 LIMIT 1
1226 Block Load (148.0ms) 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` = 447 ORDER BY start_date DESC, end_date DESC, blocks.start_date DESC LIMIT 1
1227 Block Load (147.5ms) SELECT `blocks`.* FROM `blocks` WHERE `blocks`.`client_id` = 319 AND `blocks`.`block_schedule_id` = 447 AND (blocks.end_date > '2018-04-30') AND (blocks.id != 29252) ORDER BY start_date asc LIMIT 1
1228 (148.5ms) truncate table buffer_location_privileges_1208161824
1229
1230 (152.6ms) insert into buffer_location_privileges_1208161824 (
1231 staff_id,
1232 location_id,
1233 begin_date,
1234 end_date
1235 )
1236 select
1237 s.id as staff_id,
1238 l.location_id,
1239 '0000-00-00' as begin_date,
1240 '9999-12-31' as end_date
1241 from (
1242 select
1243 l.id as location_id
1244 from
1245 buffer_target_call_types_1208161824 as ct
1246 inner join locations as l
1247 on ct.location_id = l.id
1248 and l.active = 1
1249 group by
1250 l.id
1251 order by null
1252 ) as l
1253 inner join staffs as s
1254 on s.client_id = 319
1255 and s.active = 1
1256 and s.take_call = 1
1257 left join location_privileges as lp
1258 on s.id = lp.staff_id
1259 where
1260 lp.id is null
1261 union
1262 select
1263 lp.staff_id,
1264 lp.location_id,
1265 lp.begin_date,
1266 coalesce(lp.end_date, '9999-12-31') as end_date
1267 from (
1268 select
1269 l.id as location_id
1270 from
1271 buffer_target_call_types_1208161824 as ct
1272 inner join locations as l
1273 on ct.location_id = l.id
1274 and l.active = 1
1275 group by
1276 l.id
1277 order by null
1278 ) as l
1279 inner join location_privileges as lp
1280 on l.location_id = lp.location_id
1281 order by null
1282
1283 (151.2ms) truncate table buffer_target_primary_availabilities_1208161824
1284
1285 (160.5ms) insert into buffer_target_primary_availabilities_1208161824 (
1286 staff_id,
1287 call_type_id,
1288 target_group_id,
1289 assignment_id,
1290 assignment_type,
1291 calendar_schedule_id,
1292 day_of_week_mask,
1293 is_weekend,
1294 staff_type_id,
1295 st_begin_date,
1296 st_end_date,
1297 location_id,
1298 lp_begin_date,
1299 lp_end_date,
1300 included_in_targets
1301 )
1302 select straight_join
1303 s.id as staff_id,
1304 ct.id as call_type_id,
1305 ct.target_group_id,
1306 ct.assignment_id,
1307 ct.assignment_type,
1308 ct.calendar_schedule_id,
1309 t1.day_of_week_mask,
1310 t1.is_weekend,
1311 ast.staff_type_id,
1312 ast.begin_date as st_begin_date,
1313 coalesce(ast.end_date, '9999-12-31') as st_end_date,
1314 lp.location_id,
1315 lp.begin_date as lp_begin_date,
1316 lp.end_date as lp_end_date,
1317 ct.included_in_targets
1318 from (
1319 select 1 as day_of_week_mask, 1 as is_weekend
1320 union select 2, 0
1321 union select 4, 0
1322 union select 8, 0
1323 union select 16, 0
1324 union select 32, 0
1325 union select 64, 1
1326 ) as t1
1327 inner join buffer_target_call_types_1208161824 as ct
1328 on (t1.day_of_week_mask & ct.days_of_week_mask) > 0
1329 and ct.all_staff_types = 1
1330 inner join staff_call_types as sct
1331 on ct.id = sct.call_type_id
1332 -- 1st pass (assignments)
1333 and ((
1334 ct.included_in_targets & 1 > 0
1335 and t1.day_of_week_mask & sct.days_of_week_mask > 0
1336 )
1337 or (
1338 ct.included_in_targets & 2 > 0
1339 and t1.day_of_week_mask & sct.secondary_availability_days_of_week_mask > 0
1340 )
1341 )
1342
1343 inner join staffs as s
1344 on sct.staff_id = s.id
1345 and s.active = 1
1346 and s.take_call = 1
1347 inner join buffer_location_privileges_1208161824 as lp
1348 on s.id = lp.staff_id
1349 and ct.location_id = lp.location_id
1350 and coalesce(lp.end_date, '9999-12-31') >= '2018-05-01' /* current targets begin date */
1351 inner join assign_staff_types as ast
1352 on s.id = ast.staff_id
1353 and coalesce(ast.end_date, '9999-12-31') >= '2018-05-01' /* current targets begin date */
1354
1355 where
1356 ast.begin_date <= coalesce(lp.end_date, '9999-12-31')
1357 and lp.begin_date <= coalesce(ast.end_date, '9999-12-31')
1358
1359 order by null
1360
1361 (151.6ms) insert into buffer_target_primary_availabilities_1208161824 (
1362 staff_id,
1363 call_type_id,
1364 target_group_id,
1365 assignment_id,
1366 assignment_type,
1367 calendar_schedule_id,
1368 day_of_week_mask,
1369 is_weekend,
1370 staff_type_id,
1371 st_begin_date,
1372 st_end_date,
1373 location_id,
1374 lp_begin_date,
1375 lp_end_date,
1376 included_in_targets
1377 )
1378 select straight_join
1379 s.id as staff_id,
1380 ct.id as call_type_id,
1381 ct.target_group_id,
1382 ct.assignment_id,
1383 ct.assignment_type,
1384 ct.calendar_schedule_id,
1385 t1.day_of_week_mask,
1386 t1.is_weekend,
1387 ast.staff_type_id,
1388 ast.begin_date as st_begin_date,
1389 coalesce(ast.end_date, '9999-12-31') as st_end_date,
1390 lp.location_id,
1391 lp.begin_date as lp_begin_date,
1392 lp.end_date as lp_end_date,
1393 ct.included_in_targets
1394 from (
1395 select 1 as day_of_week_mask, 1 as is_weekend
1396 union select 2, 0
1397 union select 4, 0
1398 union select 8, 0
1399 union select 16, 0
1400 union select 32, 0
1401 union select 64, 1
1402 ) as t1
1403 inner join buffer_target_call_types_1208161824 as ct
1404 on (t1.day_of_week_mask & ct.days_of_week_mask) > 0
1405 and ct.all_staff_types = 0
1406 inner join staff_call_types as sct
1407 on ct.id = sct.call_type_id
1408 -- 1st pass (assignments)
1409 and ((
1410 ct.included_in_targets & 1 > 0
1411 and t1.day_of_week_mask & sct.days_of_week_mask > 0
1412 )
1413 or (
1414 ct.included_in_targets & 2 > 0
1415 and t1.day_of_week_mask & sct.secondary_availability_days_of_week_mask > 0
1416 )
1417 )
1418
1419 inner join staffs as s
1420 on sct.staff_id = s.id
1421 and s.active = 1
1422 and s.take_call = 1
1423 inner join buffer_location_privileges_1208161824 as lp
1424 on s.id = lp.staff_id
1425 and ct.location_id = lp.location_id
1426 and coalesce(lp.end_date, '9999-12-31') >= '2018-05-01' /* current targets begin date */
1427 inner join assign_staff_types as ast
1428 on s.id = ast.staff_id
1429 and coalesce(ast.end_date, '9999-12-31') >= '2018-05-01' /* current targets begin date */
1430 inner join eligible_staff_types as est
1431 on ct.id = est.call_type_id
1432 and ast.staff_type_id = est.staff_type_id
1433
1434 where
1435 ast.begin_date <= coalesce(lp.end_date, '9999-12-31')
1436 and lp.begin_date <= coalesce(ast.end_date, '9999-12-31')
1437
1438 order by null
1439
1440Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0201 - 1221.382ms
1441 (148.2ms) select id from buffer_target_primary_availabilities_1208161824 limit 1
1442 (170.2ms) insert into buffer_annual_targets_staff_totals_1208161824 (
1443 staff_id,
1444 assignment_id,
1445 assignment_type,
1446 calendar_schedule_id,
1447 day_of_week_mask,
1448 is_weekend,
1449 allocated,
1450 estimated_vacation,
1451 available_days,
1452 relative_capacity
1453 )
1454 select distinct
1455 pa.staff_id,
1456 pa.assignment_id,
1457 pa.assignment_type,
1458 pa.calendar_schedule_id,
1459 pa.day_of_week_mask,
1460 pa.is_weekend,
1461 case
1462 when (at_a.id is not null) then at_a.allocated
1463 when (ts.annual_target_view = 'fte') then 1.0
1464 else (t1.assignments_count * 52 / t1.staffs_count)
1465 end as allocated,
1466 coalesce(at_vc.allocated, 0) as estimated_vacation,
1467 (52 - coalesce(at_vc.allocated, 0)) as available_days,
1468 0 as relative_capacity /* will be calculated on the next step */
1469 from
1470 buffer_target_primary_availabilities_1208161824 as pa
1471 inner join (
1472 select
1473 assignment_id,
1474 assignment_type,
1475 day_of_week_mask,
1476 count(distinct call_type_id) as assignments_count,
1477 count(distinct staff_id) as staffs_count
1478 from buffer_target_primary_availabilities_1208161824
1479 group by
1480 assignment_id,
1481 assignment_type,
1482 day_of_week_mask
1483 order by null
1484 ) as t1
1485 on pa.assignment_id = t1.assignment_id
1486 and pa.assignment_type = t1.assignment_type
1487 and pa.day_of_week_mask = t1.day_of_week_mask
1488 inner join target_autopopulate_timeframes as ts
1489 on pa.calendar_schedule_id = ts.calendar_schedule_id
1490 left join annual_targets as at_a
1491 on pa.staff_id = at_a.staff_id
1492 and pa.assignment_id = at_a.assignment_id
1493 and pa.assignment_type = at_a.assignment_type
1494 and pa.day_of_week_mask = at_a.day_of_week_mask
1495 left join annual_targets as at_vc
1496 on pa.staff_id = at_vc.staff_id
1497 and pa.assignment_id = -1
1498 and pa.assignment_type = 'Vacation'
1499 and pa.day_of_week_mask = at_vc.day_of_week_mask
1500 order by null
1501
1502Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0203 - 170.71800000000002ms
1503 (151.5ms) update
1504 buffer_annual_targets_staff_totals_1208161824 as atst
1505 inner join (
1506 select
1507 assignment_id,
1508 assignment_type,
1509 day_of_week_mask,
1510 sum(allocated) as allocated_total,
1511 sum(available_days) as available_days_total
1512 from buffer_annual_targets_staff_totals_1208161824
1513 group by
1514 assignment_id,
1515 assignment_type,
1516 day_of_week_mask
1517 order by null
1518 ) as t1
1519 on atst.assignment_id = t1.assignment_id
1520 and atst.assignment_type = t1.assignment_type
1521 and atst.day_of_week_mask = t1.day_of_week_mask
1522 set
1523 atst.relative_capacity =
1524 case
1525 when (t1.allocated_total > 0 and t1.available_days_total > 0)
1526 then (atst.allocated / t1.allocated_total) / (atst.available_days / t1.available_days_total) * 100
1527 else 0
1528 end
1529
1530Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0204 - 151.971ms
1531 (148.6ms) truncate table buffer_target_dates_list_1208161824
1532
1533 (151.0ms) insert into buffer_target_dates_list_1208161824 (
1534 block_id,
1535 calendar_schedule_id,
1536 date,
1537 day_of_week_mask,
1538 is_weekend
1539
1540 )
1541 select
1542 dl.block_id,
1543 dl.calendar_schedule_id,
1544 dl.date,
1545 (1 << (dayofweek(dl.date) - 1)) as day_of_week_mask,
1546 case
1547 when (dayofweek(dl.date) between 2 /* Monday */ and 6 /* Friday */) then 0
1548 else 1
1549 end as is_weekend
1550
1551 from(
1552 select
1553 td.block_id,
1554 td.calendar_schedule_id,
1555 date_add(td.start_date, interval ns.item_number day) as date
1556 from
1557 buffer_target_dates as td
1558 inner join numeric_sequence as ns
1559 on ns.item_number <= datediff(td.end_date, td.start_date)
1560 where
1561 td.session_id = 1208161824
1562 and (td.build_cd_targets = 1 OR td.build_dow_targets = 1)
1563 order by null
1564 ) as dl
1565
1566 order by null
1567
1568 (148.8ms) truncate table buffer_tmp_targets_availabilities_1208161824
1569
1570 (157.5ms) insert into buffer_tmp_targets_availabilities_1208161824 (
1571 block_id,
1572 calendar_schedule_id,
1573 date,
1574 day_of_week_mask,
1575 is_weekend,
1576 call_type_id,
1577 assignment_id,
1578 assignment_type,
1579 staff_id,
1580 included_in_targets
1581 )
1582 select
1583 dl.block_id,
1584 dl.calendar_schedule_id,
1585 dl.date,
1586 dl.day_of_week_mask,
1587 dl.is_weekend,
1588 pa.call_type_id,
1589 pa.assignment_id,
1590 pa.assignment_type,
1591 pa.staff_id,
1592 pa.included_in_targets
1593 from
1594 buffer_target_dates_list_1208161824 as dl
1595 inner join buffer_target_primary_availabilities_1208161824 as pa
1596 on dl.calendar_schedule_id = pa.calendar_schedule_id
1597 and dl.day_of_week_mask = pa.day_of_week_mask
1598 and dl.date between pa.st_begin_date and pa.st_end_date
1599 and dl.date between pa.lp_begin_date and pa.lp_end_date
1600 inner join staff_types as st
1601 on pa.staff_type_id = st.id
1602 and st.active = 1
1603 order by null
1604
1605 (148.5ms) truncate table buffer_tmp_targets_availabilities_exclusions_1208161824
1606
1607 (152.0ms) insert into buffer_tmp_targets_availabilities_exclusions_1208161824 (id)
1608 select ta.id
1609 from
1610 buffer_tmp_targets_availabilities_1208161824 as ta
1611 inner join staff_rotations as sr use index (ix_staff_rotations_composite_1)
1612 on ta.staff_id = sr.staff_id
1613 and ta.date between sr.start_date and sr.end_date
1614 inner join rotations as r
1615 on sr.rotation_id = r.id
1616 and r.active = 1
1617 left join rotation_call_types as rct
1618 on sr.rotation_id = rct.rotation_id
1619 and ta.call_type_id = rct.call_type_id
1620 -- 1st pass
1621 and ((
1622 ta.included_in_targets & 1 > 0
1623 and ta.day_of_week_mask & rct.days_of_week_mask > 0
1624 )
1625 or (
1626 ta.included_in_targets & 2 > 0
1627 and ta.day_of_week_mask & rct.secondary_availability_days_of_week_mask > 0
1628 )
1629 )
1630
1631 left join daily_rotations as dr
1632 on ta.date = dr.schedule_on
1633 and ta.staff_id = dr.staff_id
1634 where
1635 rct.id is null
1636 and dr.id is null
1637 order by null
1638
1639 (149.8ms) insert into buffer_tmp_targets_availabilities_exclusions_1208161824 (id)
1640 select ta.id
1641 from
1642 buffer_tmp_targets_availabilities_1208161824 as ta
1643 inner join daily_rotations as dr
1644 on ta.date = dr.schedule_on
1645 and ta.staff_id = dr.staff_id
1646 inner join rotations as r
1647 on dr.rotation_id = r.id
1648 and r.active = 1
1649 left join rotation_call_types as rct
1650 on dr.rotation_id = rct.rotation_id
1651 and ta.call_type_id = rct.call_type_id
1652 -- 1st pass
1653 and ((
1654 ta.included_in_targets & 1 > 0
1655 and ta.day_of_week_mask & rct.days_of_week_mask > 0
1656 )
1657 or (
1658 ta.included_in_targets & 2 > 0
1659 and ta.day_of_week_mask & rct.secondary_availability_days_of_week_mask > 0
1660 )
1661 )
1662
1663 where rct.id is null
1664 order by null
1665
1666 (156.7ms) insert into buffer_tmp_targets_availabilities_exclusions_1208161824 (id)
1667 select ta.id
1668 from
1669 buffer_tmp_targets_availabilities_1208161824 as ta
1670 inner join target_autopopulate_timeframes as ts
1671 on ta.calendar_schedule_id = ts.calendar_schedule_id
1672 -- 1st pass
1673 and ts.available_days_in_calls = 1
1674
1675 inner join vacations as v
1676 on ta.date = v.schedule_on
1677 and ta.staff_id = v.staff_id
1678 and v.status = 3 /* status = fulfilled */
1679 order by null
1680
1681Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets03 - 1216.766ms
1682 (149.1ms) truncate table buffer_tmp_targets_scheduled_1208161824
1683
1684 (157.3ms) /* Assignment points */
1685 insert into buffer_tmp_targets_scheduled_1208161824 (
1686 block_id,
1687 calendar_schedule_id,
1688 staff_id,
1689 assignment_id,
1690 assignment_type,
1691 day_of_week_mask,
1692 is_weekend,
1693 scheduled,
1694 other_scheduled
1695 )
1696 select
1697 dl.block_id,
1698 dl.calendar_schedule_id,
1699 sc.staff_id,
1700 ct.assignment_id,
1701 ct.assignment_type,
1702 dl.day_of_week_mask,
1703 dl.is_weekend,
1704 count(sc.id) as _scheduled,
1705 0 as other_scheduled
1706 from
1707 buffer_target_dates_list_1208161824 as dl
1708 inner join buffer_target_call_types_1208161824 as ct
1709 on dl.calendar_schedule_id = ct.calendar_schedule_id
1710 and (dl.day_of_week_mask & ct.days_of_week_mask) > 0
1711 inner join schedules as sc
1712 on dl.date = sc.schedule_on
1713 and ct.id = sc.call_type_id
1714 group by
1715 dl.block_id,
1716 dl.calendar_schedule_id,
1717 sc.staff_id,
1718 ct.assignment_id,
1719 ct.assignment_type,
1720 dl.day_of_week_mask,
1721 dl.is_weekend
1722 having
1723 _scheduled != 0
1724 order by null
1725
1726 (148.6ms) truncate table buffer_tmp_targets_staff_totals_1208161824
1727
1728 (156.5ms) insert into buffer_tmp_targets_staff_totals_1208161824 (
1729 block_id,
1730 calendar_schedule_id,
1731 staff_id,
1732 assignment_id,
1733 assignment_type,
1734 day_of_week_mask,
1735 is_weekend,
1736 relative_capacity,
1737 available_days,
1738 weighted_days,
1739 scheduled,
1740 other_scheduled
1741 )
1742 select
1743 t1.block_id,
1744 t1.calendar_schedule_id,
1745 t1.staff_id,
1746 t1.assignment_id,
1747 t1.assignment_type,
1748 t1.day_of_week_mask,
1749 t1.is_weekend,
1750 atst.relative_capacity,
1751 t1.available_days,
1752 (t1.available_days * atst.relative_capacity / 100) as weighted_days,
1753 coalesce(sch_t.scheduled, 0) as scheduled,
1754 0 as other_scheduled
1755 from (
1756 select
1757 ta.block_id,
1758 ta.calendar_schedule_id,
1759 ta.staff_id,
1760 ta.assignment_id,
1761 ta.assignment_type,
1762 ta.day_of_week_mask,
1763 ta.is_weekend,
1764 count(distinct ta.date) as available_days
1765 from
1766 buffer_tmp_targets_availabilities_1208161824 as ta
1767 left join buffer_tmp_targets_availabilities_exclusions_1208161824 as tae
1768 on ta.id = tae.id
1769 where tae.id is null
1770 group by
1771 ta.block_id,
1772 ta.calendar_schedule_id,
1773 ta.staff_id,
1774 ta.assignment_id,
1775 ta.assignment_type,
1776 ta.day_of_week_mask,
1777 ta.is_weekend
1778 order by null
1779 ) as t1
1780 inner join buffer_annual_targets_staff_totals_1208161824 as atst
1781 on t1.staff_id = atst.staff_id
1782 and t1.assignment_id = atst.assignment_id
1783 and t1.assignment_type = atst.assignment_type
1784 and t1.day_of_week_mask = atst.day_of_week_mask
1785 left join (
1786 select
1787 block_id,
1788 calendar_schedule_id,
1789 staff_id,
1790 assignment_id,
1791 assignment_type,
1792 day_of_week_mask,
1793 sum(scheduled) as scheduled
1794 from buffer_tmp_targets_scheduled_1208161824
1795 group by
1796 block_id,
1797 calendar_schedule_id,
1798 staff_id,
1799 assignment_id,
1800 assignment_type,
1801 day_of_week_mask
1802 order by null
1803 ) as sch_t
1804 on t1.block_id = sch_t.block_id
1805 and t1.calendar_schedule_id = sch_t.calendar_schedule_id
1806 and t1.staff_id = sch_t.staff_id
1807 and t1.assignment_id = sch_t.assignment_id
1808 and t1.assignment_type = sch_t.assignment_type
1809 and t1.day_of_week_mask = sch_t.day_of_week_mask
1810 order by null
1811
1812 (149.4ms) truncate table buffer_tmp_targets_client_totals_1208161824
1813
1814 (302.8ms) insert into buffer_tmp_targets_client_totals_1208161824 (
1815 block_id,
1816 calendar_schedule_id,
1817 assignment_id,
1818 assignment_type,
1819 day_of_week_mask,
1820 is_weekend,
1821 targets_total,
1822 weighted_days_total
1823 )
1824 select
1825 st.block_id,
1826 st.calendar_schedule_id,
1827 st.assignment_id,
1828 st.assignment_type,
1829 st.day_of_week_mask,
1830 st.is_weekend,
1831 ca.assignments_total as targets_total,
1832 sum(st.weighted_days) as weighted_days_total
1833 from
1834 buffer_tmp_targets_staff_totals_1208161824 as st
1835 inner join (
1836 select
1837 dl.block_id,
1838 dl.calendar_schedule_id,
1839 ct.assignment_id,
1840 ct.assignment_type,
1841 dl.day_of_week_mask,
1842 sum(
1843 case
1844 when ((
1845 ts.use_non_targeted_staff = 0
1846 or sc.id is null
1847 or pa.staff_id is not null
1848 )
1849 and (
1850 ts.remove_slots_from_denominator_targets = 0
1851 or ae.id is null
1852 )
1853 ) then 1
1854 else 0
1855 end
1856 ) as assignments_total
1857 from
1858 buffer_target_dates_list_1208161824 as dl
1859 inner join buffer_target_call_types_1208161824 as ct
1860 on dl.calendar_schedule_id = ct.calendar_schedule_id
1861 and (dl.day_of_week_mask & ct.days_of_week_mask) > 0
1862 inner join target_autopopulate_timeframes as ts
1863 on dl.calendar_schedule_id = ts.calendar_schedule_id
1864 left join schedules as sc
1865 on dl.date = sc.schedule_on
1866 and ct.id = sc.call_type_id
1867 left join autopopulate_exclusions as ae
1868 on dl.date = ae.schedule_on
1869 and ct.id = ae.call_type_id
1870 left join buffer_target_primary_availabilities_1208161824 as pa
1871 on sc.staff_id = pa.staff_id
1872 and ct.id = pa.call_type_id
1873 and dl.day_of_week_mask = pa.day_of_week_mask
1874 and dl.date between pa.st_begin_date and pa.st_end_date
1875 and dl.date between pa.lp_begin_date and pa.lp_end_date
1876 group by
1877 dl.block_id,
1878 dl.calendar_schedule_id,
1879 ct.assignment_id,
1880 ct.assignment_type,
1881 dl.day_of_week_mask
1882 order by null
1883 ) as ca
1884 on st.block_id = ca.block_id
1885 and st.calendar_schedule_id = ca.calendar_schedule_id
1886 and st.assignment_id = ca.assignment_id
1887 and st.assignment_type = ca.assignment_type
1888 and st.day_of_week_mask = ca.day_of_week_mask
1889 group by
1890 st.block_id,
1891 st.calendar_schedule_id,
1892 st.assignment_id,
1893 st.assignment_type,
1894 st.day_of_week_mask,
1895 st.is_weekend,
1896 ca.assignments_total
1897 order by null
1898
1899 (152.7ms) insert into buffer_call_days_targets_1208161824 (
1900 block_id,
1901 calendar_schedule_id,
1902 staff_id,
1903 assignment_id,
1904 assignment_type,
1905 day_of_week_mask,
1906 is_weekend,
1907 raw_target,
1908 target,
1909 initial_target,
1910 scheduled,
1911 available_days
1912 )
1913 select
1914 st.block_id,
1915 st.calendar_schedule_id,
1916 st.staff_id,
1917 st.assignment_id,
1918 st.assignment_type,
1919 st.day_of_week_mask,
1920 st.is_weekend,
1921 case
1922 when (ct.weighted_days_total > 0)
1923 then (ct.targets_total * st.weighted_days / ct.weighted_days_total)
1924 else 0
1925 end as raw_target,
1926 case
1927 when (ct.weighted_days_total > 0)
1928 then (ct.targets_total * st.weighted_days / ct.weighted_days_total)
1929 else 0
1930 end as target,
1931 case
1932 when (ct.weighted_days_total > 0)
1933 then (ct.targets_total * st.weighted_days / ct.weighted_days_total)
1934 else 0
1935 end as initial_target,
1936 st.scheduled,
1937 st.available_days
1938 from
1939 buffer_tmp_targets_staff_totals_1208161824 as st
1940 inner join buffer_tmp_targets_client_totals_1208161824 as ct
1941 on st.block_id = ct.block_id
1942 and st.calendar_schedule_id = ct.calendar_schedule_id
1943 and st.assignment_id = ct.assignment_id
1944 and st.assignment_type = ct.assignment_type
1945 and st.day_of_week_mask = ct.day_of_week_mask
1946 order by null
1947
1948 (153.0ms) update
1949 buffer_call_days_targets_1208161824 as cdt
1950 left join call_days_targets as pcdt
1951 on cdt.block_id = pcdt.block_id
1952 and cdt.calendar_schedule_id = pcdt.calendar_schedule_id
1953 and cdt.staff_id = pcdt.staff_id
1954 and cdt.assignment_id = pcdt.assignment_id
1955 and cdt.assignment_type = pcdt.assignment_type
1956 and cdt.day_of_week_mask = pcdt.day_of_week_mask
1957 left join call_type_adjusted_targets as ctat
1958 on cdt.block_id = ctat.block_id
1959 and cdt.calendar_schedule_id = ctat.calendar_schedule_id
1960 and cdt.staff_id = ctat.staff_id
1961 and cdt.assignment_id = ctat.assignment_id
1962 and cdt.assignment_type = ctat.assignment_type
1963 and cdt.day_of_week_mask = ctat.day_of_week_mask
1964 set
1965 cdt.raw_target =
1966 case
1967 when (pcdt.id is not null) then pcdt.raw_target
1968 else cdt.raw_target
1969 end,
1970 cdt.target =
1971 case
1972 when (pcdt.id is not null) then pcdt.target
1973 when (ctat.id is not null) then ctat.target
1974 else cdt.target
1975 end,
1976 cdt.initial_target =
1977 case
1978 when (pcdt.id is not null) then pcdt.initial_target
1979 else cdt.initial_target
1980 end
1981
1982 (146.7ms) insert into buffer_call_days_targets_1208161824 (
1983 block_id,
1984 calendar_schedule_id,
1985 staff_id,
1986 assignment_id,
1987 assignment_type,
1988 day_of_week_mask,
1989 is_weekend,
1990 raw_target,
1991 target,
1992 initial_target,
1993 scheduled,
1994 available_days
1995 )
1996 select
1997 sch_t.block_id,
1998 sch_t.calendar_schedule_id,
1999 sch_t.staff_id,
2000 sch_t.assignment_id,
2001 sch_t.assignment_type,
2002 sch_t.day_of_week_mask,
2003 sch_t.is_weekend,
2004 0.0 as raw_target,
2005 0.0 as target,
2006 0.0 as initial_target,
2007 sum(sch_t.scheduled) as scheduled,
2008 0 as available_days
2009 from
2010 buffer_tmp_targets_scheduled_1208161824 as sch_t
2011 left join buffer_call_days_targets_1208161824 as cdt
2012 on sch_t.block_id = cdt.block_id
2013 and sch_t.calendar_schedule_id = cdt.calendar_schedule_id
2014 and sch_t.staff_id = cdt.staff_id
2015 and sch_t.assignment_id = cdt.assignment_id
2016 and sch_t.assignment_type = cdt.assignment_type
2017 and sch_t.day_of_week_mask = cdt.day_of_week_mask
2018 where
2019 sch_t.scheduled != 0
2020 and cdt.id is null
2021 group by
2022 sch_t.block_id,
2023 sch_t.calendar_schedule_id,
2024 sch_t.staff_id,
2025 sch_t.assignment_id,
2026 sch_t.assignment_type,
2027 sch_t.day_of_week_mask,
2028 sch_t.is_weekend
2029 order by null
2030
2031Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets05 - 1519.62ms
2032 (290.4ms) insert into buffer_day_of_week_targets_1208161824 (
2033 block_id,
2034 calendar_schedule_id,
2035 staff_id,
2036 wday,
2037 raw_target,
2038 target,
2039 scheduled,
2040 available_days
2041 )
2042 select
2043 cdt.block_id,
2044 cdt.calendar_schedule_id,
2045 cdt.staff_id,
2046 log2(cdt.day_of_week_mask) as _wday,
2047 sum(cdt.raw_target) as raw_target,
2048 sum(cdt.target) as target,
2049 sum(cdt.scheduled) as scheduled,
2050 coalesce(t1.available_days, 0) as available_days
2051 from
2052 buffer_target_dates as td
2053 inner join buffer_call_days_targets_1208161824 as cdt
2054 on td.block_id = cdt.block_id
2055 and td.calendar_schedule_id = cdt.calendar_schedule_id
2056 left join (
2057 select
2058 ta.block_id,
2059 ta.calendar_schedule_id,
2060 ta.staff_id,
2061 ta.day_of_week_mask,
2062 count(distinct ta.date) as available_days
2063 from
2064 buffer_target_dates as td
2065 inner join buffer_tmp_targets_availabilities_1208161824 as ta
2066 on td.block_id = ta.block_id
2067 and td.calendar_schedule_id = ta.calendar_schedule_id
2068 left join buffer_tmp_targets_availabilities_exclusions_1208161824 as tae
2069 on ta.id = tae.id
2070 where
2071 td.session_id = 1208161824 /* session_id */
2072 and td.build_dow_targets = 1
2073 and tae.id is null
2074 group by
2075 ta.block_id,
2076 ta.calendar_schedule_id,
2077 ta.staff_id,
2078 ta.day_of_week_mask
2079 order by null
2080 ) as t1
2081 on cdt.block_id = t1.block_id
2082 and cdt.calendar_schedule_id = t1.calendar_schedule_id
2083 and cdt.staff_id = t1.staff_id
2084 and cdt.day_of_week_mask = t1.day_of_week_mask
2085 where
2086 td.session_id = 1208161824 /* session_id */
2087 and td.build_dow_targets = 1
2088 group by
2089 cdt.block_id,
2090 cdt.calendar_schedule_id,
2091 cdt.staff_id,
2092 _wday,
2093 t1.available_days
2094 order by null;
2095
2096Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets06 - 290.88399999999996ms
2097 (146.5ms) delete ucdt
2098 from buffer_target_dates as td
2099 inner join unpublished_call_days_targets as ucdt
2100 on td.calendar_schedule_id = ucdt.calendar_schedule_id
2101 and td.block_id = ucdt.block_id
2102 where
2103 td.session_id = 1208161824
2104 and td.build_cd_targets = 1
2105
2106 (156.7ms) insert into unpublished_call_days_targets (
2107 client_id,
2108 calendar_schedule_id,
2109 block_id,
2110 staff_id,
2111 assignment_id,
2112 assignment_type,
2113 day_of_week_mask,
2114 is_weekend,
2115 raw_target,
2116 target,
2117 initial_target,
2118 scheduled,
2119 available_days
2120 )
2121 select
2122 td.client_id,
2123 cdt.calendar_schedule_id,
2124 cdt.block_id,
2125 cdt.staff_id,
2126 cdt.assignment_id,
2127 cdt.assignment_type,
2128 cdt.day_of_week_mask,
2129 cdt.is_weekend,
2130 cdt.raw_target,
2131 cdt.target,
2132 cdt.initial_target,
2133 cdt.scheduled,
2134 cdt.available_days
2135 from
2136 buffer_target_dates as td
2137 inner join buffer_call_days_targets_1208161824 as cdt
2138 on td.calendar_schedule_id = cdt.calendar_schedule_id
2139 and td.block_id = cdt.block_id
2140 left join published_blocks as pb
2141 on td.calendar_schedule_id = pb.calendar_schedule_id
2142 and td.block_id = pb.block_id
2143 left join published_block_call_types as pbct
2144 on pb.id = pbct.published_block_id
2145 and cdt.assignment_id = pbct.assignment_id
2146 and cdt.assignment_type = pbct.assignment_type
2147 and cdt.day_of_week_mask & pbct.days_of_week_mask > 0
2148 where
2149 td.session_id = 1208161824 /* session_id */
2150 and td.build_cd_targets = 1
2151 and pbct.id is null
2152 union all
2153 select
2154 td.client_id,
2155 td.calendar_schedule_id,
2156 td.block_id,
2157 0 as staff_id,
2158 0 as assignment_id,
2159 '' as assignment_type,
2160 0 as day_of_week_mask,
2161 0 as is_weekend,
2162 0 as raw_target,
2163 0 as target,
2164 0 as initial_target,
2165 0 as scheduled,
2166 0 as available_days
2167 from
2168 buffer_target_dates as td
2169 where
2170 td.session_id = 1208161824 /* session_id */
2171 and td.build_cd_targets = 1
2172 order by null
2173
2174 (146.7ms) delete udowt
2175 from
2176 buffer_target_dates as td
2177 inner join unpublished_day_of_week_targets as udowt
2178 on td.calendar_schedule_id = udowt.calendar_schedule_id
2179 and td.block_id = udowt.block_id
2180 where
2181 td.session_id = 1208161824
2182 and td.build_dow_targets = 1
2183
2184 (151.3ms) insert into unpublished_day_of_week_targets (
2185 client_id,
2186 calendar_schedule_id,
2187 block_id,
2188 staff_id,
2189 wday,
2190 raw_target,
2191 target,
2192 scheduled,
2193 available_days
2194 )
2195 select
2196 td.client_id,
2197 dowt.calendar_schedule_id,
2198 dowt.block_id,
2199 dowt.staff_id,
2200 dowt.wday,
2201 dowt.raw_target,
2202 dowt.target,
2203 dowt.scheduled,
2204 dowt.available_days
2205 from buffer_target_dates as td
2206 inner join buffer_day_of_week_targets_1208161824 as dowt
2207 on td.calendar_schedule_id = dowt.calendar_schedule_id
2208 and td.block_id = dowt.block_id
2209 where
2210 td.session_id = 1208161824 /* session_id */
2211 and td.build_dow_targets = 1
2212 union all
2213 select
2214 td.client_id,
2215 td.calendar_schedule_id,
2216 td.block_id,
2217 0 as staff_id,
2218 0 as wday,
2219 0 as raw_target,
2220 0 as target,
2221 0 as scheduled,
2222 0 as available_days
2223 from
2224 buffer_target_dates as td
2225 where
2226 td.session_id = 1208161824 /* session_id */
2227 and td.build_dow_targets = 1
2228 order by null
2229
2230Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0701 - 603.279ms
2231 (153.2ms) /* AnnualDayOfWeekMixRule */
2232 insert into buffer_cumulative_dow_targets_1208161824 (
2233 staff_id,
2234 wday,
2235 calendar_schedule_id,
2236 raw_target,
2237 adjusted_target,
2238 scheduled,
2239 available_days
2240 )
2241 select
2242 t.staff_id,
2243 t.wday,
2244 t.calendar_schedule_id,
2245 sum(t.raw_target) as raw_target,
2246 sum(t.adjusted_target) as adjusted_target,
2247 sum(t.scheduled) as scheduled,
2248 sum(t.available_days) as available_days
2249 from (
2250 select
2251 t.calendar_schedule_id,
2252 t.block_id,
2253 t.staff_id,
2254 t.wday,
2255 t.raw_target,
2256 t.target as adjusted_target,
2257 t.scheduled,
2258 t.available_days
2259 from buffer_target_dates as td
2260 inner join buffer_day_of_week_targets_1208161824 as t
2261 on td.calendar_schedule_id = t.calendar_schedule_id
2262 and td.block_id = t.block_id
2263 where td.session_id = 1208161824
2264 and td.build_dow_targets = 1
2265 and td.within_cumulative_period = 1
2266 union
2267 select
2268 dowt.calendar_schedule_id,
2269 dowt.block_id,
2270 dowt.staff_id,
2271 dowt.wday,
2272 dowt.raw_target,
2273 dowt.target,
2274 dowt.scheduled,
2275 dowt.available_days
2276 from buffer_target_dates as td
2277 inner join day_of_week_targets as dowt
2278 on td.calendar_schedule_id = dowt.calendar_schedule_id
2279 and td.block_id = dowt.block_id
2280 where td.session_id = 1208161824
2281 and td.build_dow_targets = 0
2282 and td.dow_targets_source = 'published'
2283 and td.within_cumulative_period = 1
2284 union
2285 select
2286 udowt.calendar_schedule_id,
2287 udowt.block_id,
2288 udowt.staff_id,
2289 udowt.wday,
2290 udowt.raw_target,
2291 udowt.target,
2292 udowt.scheduled,
2293 udowt.available_days
2294 from buffer_target_dates as td
2295 inner join unpublished_day_of_week_targets as udowt
2296 on td.calendar_schedule_id = udowt.calendar_schedule_id
2297 and td.block_id = udowt.block_id
2298 where td.session_id = 1208161824
2299 and td.build_dow_targets = 0
2300 and td.dow_targets_source = 'unpublished'
2301 and td.within_cumulative_period = 1
2302 union all
2303 select
2304 tad.calendar_schedule_id,
2305 tad.block_id,
2306 tad.staff_id,
2307 log2(tad.day_of_week_mask) as wday,
2308 0 as raw_target,
2309 0 as target,
2310 tad.adjustment_value as scheduled,
2311 0 as available_days
2312 from buffer_target_dates as td
2313 inner join target_adjustment_details as tad
2314 on td.calendar_schedule_id = tad.calendar_schedule_id
2315 and td.block_id = tad.block_id
2316 and tad.staff_id > 0
2317 where td.session_id = 1208161824
2318 and td.within_cumulative_period = 1
2319 order by null
2320 ) as t
2321 group by
2322 t.staff_id,
2323 t.wday,
2324 t.calendar_schedule_id
2325 order by null
2326
2327Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0702 - 153.965ms
2328Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0703 - 0.058ms
2329 (147.7ms) /* MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule */
2330 insert into buffer_day_of_week_targets_1208161824 (
2331 calendar_schedule_id,
2332 block_id,
2333 staff_id,
2334 wday,
2335 raw_target,
2336 target,
2337 scheduled,
2338 available_days
2339 )
2340 select
2341 dowt.calendar_schedule_id,
2342 dowt.block_id,
2343 dowt.staff_id,
2344 dowt.wday,
2345 dowt.raw_target,
2346 dowt.target,
2347 dowt.scheduled,
2348 dowt.available_days
2349 from buffer_target_dates as td
2350 inner join day_of_week_targets as dowt
2351 on td.calendar_schedule_id = dowt.calendar_schedule_id
2352 and td.block_id = dowt.block_id
2353 where td.session_id = 1208161824
2354 and td.build_dow_targets = 0
2355 and td.dow_targets_source = 'published'
2356 and td.affected_by_populate = 1
2357 union
2358 select
2359 udowt.calendar_schedule_id,
2360 udowt.block_id,
2361 udowt.staff_id,
2362 udowt.wday,
2363 udowt.raw_target,
2364 udowt.target,
2365 udowt.scheduled,
2366 udowt.available_days
2367 from buffer_target_dates as td
2368 inner join unpublished_day_of_week_targets as udowt
2369 on td.calendar_schedule_id = udowt.calendar_schedule_id
2370 and td.block_id = udowt.block_id
2371 where td.session_id = 1208161824
2372 and td.build_dow_targets = 0
2373 and td.dow_targets_source = 'unpublished'
2374 and td.affected_by_populate = 1
2375 order by null
2376
2377 (149.0ms) /* MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule */
2378 update buffer_day_of_week_targets_1208161824 as dowt
2379 inner join (
2380 select
2381 dowt.block_id,
2382 dowt.calendar_schedule_id,
2383 dowt.staff_id,
2384 dowt.wday,
2385 sum(tad.adjustment_value) as adjustment_value
2386 from
2387 buffer_day_of_week_targets_1208161824 as dowt
2388 inner join target_adjustment_details as tad
2389 on dowt.block_id = tad.block_id
2390 and dowt.calendar_schedule_id = tad.calendar_schedule_id
2391 and dowt.staff_id = tad.staff_id
2392 and dowt.wday = log2(tad.day_of_week_mask)
2393 group by
2394 dowt.block_id,
2395 dowt.calendar_schedule_id,
2396 dowt.staff_id,
2397 dowt.wday
2398 order by null
2399 ) as dowta
2400 on dowt.block_id = dowta.block_id
2401 and dowt.calendar_schedule_id = dowta.calendar_schedule_id
2402 and dowt.staff_id = dowta.staff_id
2403 and dowt.wday = dowta.wday
2404 set dowt.scheduled = dowt.scheduled + dowta.adjustment_value
2405
2406Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets07Reports - 297.80899999999997ms
2407INFO : (04-17 21:33:47) --> fill: 7 - Scheduler::AutoPopulate::Queries::Query013
2408 (180.8ms) insert into buffer_counter_increments_1208161824 (
2409 schedule_id,
2410 calls,
2411 points,
2412 hours,
2413 affects_cumulative_targets
2414 )
2415 select
2416 sc.id as schedule_id,
2417 case
2418 when (ct.included_in_targets > 0) then 1
2419 else 0
2420 end as calls,
2421 coalesce(
2422 case
2423 when (hl.observed_date is null or dp.point is not null) then dp.point
2424 else dp_2.point
2425 end,
2426 0.0
2427 ) as points,
2428 ct.hours,
2429 case
2430 when (b.display_order between (t1.timeframe_ending - (2 /* cumulative targets period */ - 1)) and t1.timeframe_ending) then 1
2431 else 0
2432 end as affects_cumulative_targets
2433 from
2434 buffer_schedules_1208161824 as sc
2435 inner join (
2436 select
2437 id,
2438 included_in_targets,
2439 coalesce(
2440 timestampdiff(
2441 minute,
2442 concat('1900-01-01 ', maketime(start_time_hour, start_time_minute, 0)),
2443 concat(
2444 '1900-01-0',
2445 case
2446 when ((
2447 start_time_hour | start_time_minute | end_time_hour | end_time_minute > 0
2448 )
2449 and (
2450 timediff(
2451 maketime(end_time_hour, end_time_minute, 0),
2452 maketime(start_time_hour, start_time_minute, 0)
2453 ) <= 0
2454 )
2455 ) then '2'
2456 else '1'
2457 end,
2458 ' ',
2459 maketime(end_time_hour, end_time_minute, 0)
2460 )
2461 ) / 60,
2462 0.0
2463 ) as hours
2464 from call_types
2465 where
2466 client_id = 319
2467 and active = 1
2468 order by null
2469 ) as ct
2470 on sc.call_type_id = ct.id
2471 inner join blocks as b
2472 on sc.block_id = b.id
2473 inner join (
2474 select
2475 calendar_schedule_id,
2476 max(
2477 case
2478 when (should_be_populated = 1) then end_block_display_order
2479 else null
2480 end
2481 ) as timeframe_ending
2482 from buffer_periods_1208161824
2483 group by calendar_schedule_id
2484 order by null
2485 ) as t1
2486 on sc.calendar_schedule_id = t1.calendar_schedule_id
2487 left join (
2488 select
2489 hd.observed_date,
2490 case
2491 when (hd.observed_date > hd.extended_date) then hd.extended_date
2492 else hd.observed_date
2493 end as date_from,
2494 case
2495 when (hd.observed_date < hd.extended_date) then hd.extended_date
2496 else hd.observed_date
2497 end as date_to
2498 from
2499 holidays as h
2500 inner join holiday_dates as hd
2501 on h.id = hd.holiday_id
2502 inner join (
2503 select
2504 year(min(schedule_on)) as year_from,
2505 year(max(schedule_on)) as year_to
2506 from buffer_schedules_1208161824
2507 where should_be_evaluated = 1
2508 ) as y
2509 on hd.year between y.year_from and y.year_to
2510 where
2511 h.client_id = 319
2512 and (
2513 h.observed = 1
2514 or h.extended = 1
2515 )
2516 order by null
2517 ) as hl
2518 on sc.schedule_on between hl.date_from and hl.date_to
2519 left join assignment_annotations as aa
2520 on ct.id = aa.assignmentable_id
2521 and aa.assignmentable_type = 'CallType'
2522 and aa.annotation_id = 0 /* annotation = "None" */
2523 and aa.applicable = 1
2524 left join assignment_annotation_daily_points as dp
2525 on aa.id = dp.assignment_annotation_id
2526 and case
2527 when (hl.observed_date is null) then (dayofweek(sc.schedule_on) - 1)
2528 when (sc.schedule_on = hl.observed_date) then 7
2529 else 8
2530 end = dp.day
2531 left join assignment_annotation_daily_points as dp_2
2532 on aa.id = dp_2.assignment_annotation_id
2533 and (dayofweek(sc.schedule_on) - 1) = dp_2.day
2534 where sc.should_be_evaluated = 1
2535 order by null
2536
2537INFO : (04-17 21:33:48) --> fill: 8 - Scheduler::AutoPopulate::Queries::Query014
2538 (151.3ms) -- Prepare the information about the blocks we're populating and the linkage patterns which will be used on those blocks
2539 insert into buffer_linkage_patterns_1208161824 (
2540 period_offset,
2541 calendar_schedule_id,
2542 block_id,
2543 block_start_date,
2544 block_start_dow,
2545 block_length,
2546 linkage_pattern_id,
2547 pattern_start_dow,
2548 days_before_start,
2549 pattern_length,
2550 start_offset,
2551 iterations_count
2552 )
2553 select
2554 b1.period_offset,
2555 b1.calendar_schedule_id,
2556 b1.block_id,
2557 b2.start_date as block_start_date,
2558 dayofweek(b2.start_date) as block_start_dow,
2559 (datediff(b2.end_date, b2.start_date) + 1) as block_length,
2560 lp.id as linkage_pattern_id,
2561 (lp.start_on + 1) as pattern_start_dow,
2562 lp.days_before_start,
2563 (lp.length * 7) as pattern_length,
2564 null as start_offset,
2565 null as iterations_count
2566 from (
2567 select
2568 calendar_schedule_id,
2569 block_id,
2570 period_offset
2571 from buffer_schedules_1208161824
2572 group by
2573 calendar_schedule_id,
2574 block_id,
2575 period_offset
2576 order by null
2577 ) as b1
2578 inner join blocks as b2
2579 on b1.block_id = b2.id
2580 inner join linkage_patterns as lp
2581 on lp.client_id = 319
2582 and b1.calendar_schedule_id = lp.calendar_schedule_id
2583 order by null
2584
2585 (149.6ms) -- 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
2586 update buffer_linkage_patterns_1208161824
2587 set start_offset = if(
2588 (pattern_start_dow + (case when (pattern_start_dow < block_start_dow) then 7 else 0 end) - block_start_dow) <= days_before_start,
2589 (pattern_start_dow + (case when (pattern_start_dow < block_start_dow) then 7 else 0 end) - block_start_dow),
2590 (block_start_dow + (case when (block_start_dow < pattern_start_dow) then 7 else 0 end) - pattern_start_dow) * (-1)
2591 )
2592
2593 (152.3ms) -- 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)
2594 -- a pattern should be repeated couple of times (in order to cover the entire block)
2595 update buffer_linkage_patterns_1208161824
2596 set iterations_count =
2597 ceiling(
2598 (
2599 block_length +
2600 case
2601 when (start_offset < 0) then abs(start_offset)
2602 else 0
2603 end
2604 ) * 1.0 / pattern_length
2605 )
2606
2607 (148.4ms) -- Generate an assignments sequence for every linkage pattern
2608 insert into buffer_schedules_linkage_patterns_1208161824 (
2609 call_type_id,
2610 staff_id,
2611 schedule_on,
2612 period_offset,
2613 day_of_week_mask,
2614 display_order,
2615 week_number,
2616 should_be_evaluated,
2617 should_be_populated,
2618 linkage_instance_id,
2619 block_id,
2620 calendar_schedule_id
2621 )
2622 select
2623 lps.assignment_id as call_type_id,
2624 null as staff_id,
2625 case
2626 when (lp.start_offset < 0)
2627 then date_add(lp.block_start_date, interval (lp.start_offset + ns.item_number * lp.pattern_length + lps.offset) day)
2628 else
2629 date_add(lp.block_start_date, interval ((lp.start_offset + ns.item_number * lp.pattern_length + lps.offset) mod lp.block_length) day)
2630 end as schedule_on,
2631 lp.period_offset,
2632 null as day_of_week_mask,
2633 null as display_order,
2634 null as week_number,
2635 0 as should_be_evaluated,
2636 0 as should_be_populated,
2637 lp.linkage_pattern_id as linkage_instance_id,
2638 lp.block_id,
2639 lp.calendar_schedule_id
2640 from
2641 numeric_sequence as ns
2642 inner join buffer_linkage_patterns_1208161824 as lp
2643 on ns.item_number <= (lp.iterations_count - 1)
2644 inner join linkage_pattern_slots as lps
2645 on lp.linkage_pattern_id = lps.linkage_pattern_id
2646 and lps.assignment_type = 'CallType'
2647 where
2648 case
2649 when (lp.start_offset < 0)
2650 then (lp.start_offset + ns.item_number * lp.pattern_length + lps.offset)
2651 else
2652 (ns.item_number * lp.pattern_length + lps.offset)
2653 end between 0 and (lp.block_length - 1)
2654 order by null
2655
2656 (149.9ms) -- Fill the columns that we left blank in the previous "INSERT"
2657 update
2658 buffer_schedules_linkage_patterns_1208161824 as slp
2659 inner join clients as cl
2660 on cl.id = 319
2661 inner join call_types as ct
2662 on slp.call_type_id = ct.id
2663 left join buffer_schedules_1208161824 as bs
2664 on slp.schedule_on = bs.schedule_on
2665 and slp.call_type_id = bs.call_type_id
2666 set
2667 slp.day_of_week_mask = (1 << (dayofweek(slp.schedule_on) - 1)),
2668 slp.display_order = ct.display_order,
2669 slp.week_number =
2670 yearweek(
2671 slp.schedule_on,
2672 case
2673 when (cl.start_of_week = 0) then 2
2674 else 7
2675 end
2676 ),
2677 slp.should_be_evaluated = coalesce(bs.should_be_evaluated, 0),
2678 slp.should_be_populated = coalesce(bs.should_be_populated, 0);
2679
2680 (147.0ms) -- Delete linkage patterns that don't have intersection with assignments we should auto-populate
2681 delete slp_1
2682 from
2683 buffer_schedules_linkage_patterns_1208161824 as slp_1
2684 inner join (
2685 select linkage_instance_id
2686 from buffer_schedules_linkage_patterns_1208161824
2687 group by linkage_instance_id
2688 having
2689 max(should_be_evaluated) = 0
2690 and max(should_be_populated) = 0
2691 order by null
2692 ) as slp_2
2693 on slp_1.linkage_instance_id = slp_2.linkage_instance_id
2694
2695 (149.3ms) -- Use a linkage pattern ID instead of linkage instance ID for those assignments that intersect with linkage patterns
2696 update
2697 buffer_schedules_linkage_patterns_1208161824 as slp
2698 inner join buffer_schedules_1208161824 as bs_1
2699 on slp.schedule_on = bs_1.schedule_on
2700 and slp.call_type_id = bs_1.call_type_id
2701 inner join buffer_schedules_1208161824 as bs_2
2702 on bs_1.linkage_instance_id = bs_2.linkage_instance_id
2703 set bs_2.linkage_instance_id = slp.linkage_instance_id
2704
2705 (147.4ms) -- Linkage pattern slots that don't have intersection with auto-populate assignments but are a part of a pattern that has such intersection
2706 -- should be copied over to the buffer schedules table (used during the auto-populate process)
2707 insert into buffer_schedules_1208161824 (
2708 call_type_id,
2709 staff_id,
2710 schedule_on,
2711 period_offset,
2712 day_of_week_mask,
2713 is_weekend,
2714 display_order,
2715 week_number,
2716 should_be_evaluated,
2717 should_be_populated,
2718 linkage_instance_id,
2719 block_id,
2720 calendar_schedule_id
2721 )
2722 select
2723 call_type_id,
2724 staff_id,
2725 schedule_on,
2726 period_offset,
2727 day_of_week_mask,
2728 case
2729 when (day_of_week_mask & 62 > 0) then 0
2730 else 1
2731 end as is_weekend,
2732 display_order,
2733 week_number,
2734 should_be_evaluated,
2735 should_be_populated,
2736 linkage_instance_id,
2737 block_id,
2738 calendar_schedule_id
2739 from buffer_schedules_linkage_patterns_1208161824
2740 where
2741 should_be_evaluated = 0
2742 and should_be_populated = 0
2743
2744INFO : (04-17 21:33:49) --> fill: 9 - Scheduler::AutoPopulate::Queries::Query015
2745 (148.3ms) insert into buffer_schedules_1208161824 (
2746 call_type_id,
2747 staff_id,
2748 schedule_on,
2749 day_of_week_mask,
2750 is_weekend,
2751 display_order,
2752 should_be_evaluated,
2753 should_be_populated,
2754 linkage_instance_id
2755 )
2756 select distinct
2757 schedules_call_overlap.call_type_id,
2758 schedules_call_overlap.staff_id,
2759 schedules_call_overlap.schedule_on,
2760 (1 << (dayofweek(schedules_call_overlap.schedule_on) - 1)) as day_of_week_mask,
2761 case
2762 when (dayofweek(schedules_call_overlap.schedule_on) between 2 and 6) then 0
2763 else 1
2764 end as is_weekend,
2765 call_types.display_order,
2766 0 as should_be_evaluated,
2767 0 as should_be_populated,
2768 -1 as linkage_instance_id
2769 from (
2770 select schedule_on
2771 from buffer_schedules_1208161824
2772 where should_be_evaluated = 1
2773 group by schedule_on
2774 order by null
2775 ) as buffer_schedules_1
2776 inner join schedules as schedules_call_overlap
2777 on schedules_call_overlap.client_id = 319
2778 and buffer_schedules_1.schedule_on = schedules_call_overlap.schedule_on
2779 left join buffer_schedules_1208161824 as buffer_schedules_2
2780 on schedules_call_overlap.schedule_on = buffer_schedules_2.schedule_on
2781 and schedules_call_overlap.call_type_id = buffer_schedules_2.call_type_id
2782 inner join call_types
2783 on schedules_call_overlap.call_type_id = call_types.id
2784 where buffer_schedules_2.id is null
2785 order by null
2786
2787INFO : (04-17 21:33:49) --> fill: 10 - Scheduler::AutoPopulate::Queries::Query02
2788INFO : (04-17 21:33:49) --> fill: 11 - Scheduler::AutoPopulate::Queries::Query03
2789INFO : (04-17 21:33:49) --> fill: 12 - Scheduler::AutoPopulate::Queries::Query04
2790INFO : (04-17 21:33:49) --> fill: 13 - Scheduler::AutoPopulate::Queries::Query045
2791INFO : (04-17 21:33:49) --> fill: 14 - Scheduler::AutoPopulate::Queries::QueryA
2792 (151.8ms) insert into buffer_schedules_1208161824 (
2793 call_type_id,
2794 staff_id,
2795 schedule_on,
2796 day_of_week_mask,
2797 is_weekend,
2798 display_order,
2799 should_be_evaluated,
2800 should_be_populated,
2801 linkage_instance_id
2802 )
2803 select distinct straight_join
2804 schedules.call_type_id,
2805 schedules.staff_id,
2806 schedules.schedule_on,
2807 (1 << (dayofweek(schedules.schedule_on) - 1)) as day_of_week_mask,
2808 case
2809 when (dayofweek(schedules.schedule_on) between 2 and 6) then 0
2810 else 1
2811 end as is_weekend,
2812 call_types.display_order,
2813 0 as should_be_evaluated,
2814 0 as should_be_populated,
2815 -1 as linkage_instance_id
2816 from
2817 buffer_schedules_1208161824 as buffer_schedules_1
2818 inner join negative_links_influences use index (ix_unique_links)
2819 on buffer_schedules_1.day_of_week_mask = negative_links_influences.day_of_week_mask
2820 and buffer_schedules_1.call_type_id = negative_links_influences.source_id
2821 and negative_links_influences.source_type = 'CallType'
2822 and negative_links_influences.target_type = 'CallType'
2823 inner join schedules use index (ix_schedules_call_date)
2824 on date_add(
2825 buffer_schedules_1.schedule_on,
2826 interval negative_links_influences.offset day
2827 ) = schedules.schedule_on
2828 and negative_links_influences.target_id = schedules.call_type_id
2829 left join buffer_schedules_1208161824 as buffer_schedules_2 use index (ix_buffer_schedules_composite_1)
2830 on schedules.schedule_on = buffer_schedules_2.schedule_on
2831 and schedules.call_type_id = buffer_schedules_2.call_type_id
2832 inner join call_types
2833 on schedules.call_type_id = call_types.id
2834 where
2835 buffer_schedules_1.linkage_instance_id >= 0
2836 and buffer_schedules_1.should_be_evaluated = 1
2837 and buffer_schedules_2.id is null
2838 order by null
2839
2840INFO : (04-17 21:33:49) --> fill: 15 - Scheduler::AutoPopulate::Queries::QueryB
2841 (151.0ms) insert into buffer_schedules_1208161824 (
2842 call_type_id,
2843 staff_id,
2844 schedule_on,
2845 day_of_week_mask,
2846 is_weekend,
2847 display_order,
2848 should_be_evaluated,
2849 should_be_populated,
2850 linkage_instance_id
2851 )
2852 select distinct straight_join
2853 (-1 * negative_links_influences.target_id) as call_type_id,
2854 vacations.staff_id,
2855 vacations.schedule_on,
2856 (1 << (dayofweek(vacations.schedule_on) - 1)) as day_of_week_mask,
2857 vacations.weekend_on as is_weekend,
2858 -1 as display_order,
2859 0 as should_be_evaluated,
2860 0 as should_be_populated,
2861 -1 as linkage_instance_id
2862 from
2863 buffer_schedules_1208161824 as buffer_schedules_1
2864 inner join negative_links_influences use index (ix_unique_links)
2865 on buffer_schedules_1.day_of_week_mask = negative_links_influences.day_of_week_mask
2866 and buffer_schedules_1.call_type_id = negative_links_influences.source_id
2867 and negative_links_influences.source_type = 'CallType'
2868 and negative_links_influences.target_id > 0
2869 and negative_links_influences.target_type in ('Vacation', 'NonClinicalType')
2870 inner join vacations use index (ix_vacations_on_schedule_and_client)
2871 on vacations.client_id = 319 /* client_id */
2872 and date_add(
2873 buffer_schedules_1.schedule_on,
2874 interval negative_links_influences.offset day
2875 ) = vacations.schedule_on
2876 and negative_links_influences.target_id = vacations.non_clinical_type_id
2877 and vacations.status in (3) /* based on the "non-working requests" settings */
2878 left join buffer_schedules_1208161824 as buffer_schedules_2 use index (ix_buffer_schedules_composite_1)
2879 on vacations.staff_id = buffer_schedules_2.staff_id
2880 and vacations.schedule_on = buffer_schedules_2.schedule_on
2881 and (-1 * negative_links_influences.target_id) = buffer_schedules_2.call_type_id
2882 where
2883 buffer_schedules_1.linkage_instance_id >= 0
2884 and buffer_schedules_1.should_be_evaluated = 1
2885 and buffer_schedules_2.id is null
2886 order by null
2887
2888INFO : (04-17 21:33:49) --> fill: 16 - Scheduler::AutoPopulate::Queries::Query05
2889 (152.7ms) insert into buffer_linkages_1208161824 (
2890 linkage_instance_id,
2891 slots_count_total,
2892 has_conflicts
2893 )
2894 select straight_join
2895 schedules.linkage_instance_id,
2896 count(1) as slots_count_total,
2897 if(linkage_conflicts.linkage_template_id is not null, 1, 0) as has_conflicts
2898 from
2899 buffer_schedules_1208161824 as schedules
2900 left join (
2901 select straight_join
2902 linkage_relations.linkage_template_id
2903 from linkage_relations
2904 inner join negative_links_influences use index (ix_unique_links)
2905 on linkage_relations.day_of_week_mask = negative_links_influences.day_of_week_mask
2906 and linkage_relations.call_type_id = negative_links_influences.source_id
2907 and negative_links_influences.source_type = 'CallType'
2908 and linkage_relations.linked_call_type_id = negative_links_influences.target_id
2909 and negative_links_influences.target_type = 'CallType'
2910 and linkage_relations.distance_in_days = negative_links_influences.offset
2911 where linkage_relations.client_id = 319 /* client_id */
2912 and (
2913 linkage_relations.call_type_id != linkage_relations.linked_call_type_id
2914 or linkage_relations.distance_in_days != 0
2915 )
2916 group by linkage_relations.linkage_template_id
2917 order by null
2918 ) as linkage_conflicts
2919 on (schedules.linkage_instance_id div 1000000) = linkage_conflicts.linkage_template_id
2920 where schedules.linkage_instance_id >= 0
2921 group by
2922 schedules.linkage_instance_id,
2923 has_conflicts
2924 order by null
2925
2926INFO : (04-17 21:33:49) --> fill: 17 - Scheduler::AutoPopulate::Queries::Query06
2927 (152.2ms) insert into buffer_target_assignments_1208161824 (
2928 call_type_id,
2929 target_group_id,
2930 assignment_id,
2931 assignment_type
2932 )
2933 select
2934 t1.call_type_id,
2935 ifnull(tg.id, 0) as target_group_id,
2936 if(tg.id is null, t1.call_type_id, tg.id) as assignment_id,
2937 if(tg.id is null, 'CallType', 'TargetGroup') as assignment_type
2938 from (
2939 select ct.id as call_type_id
2940 from
2941 buffer_schedules_1208161824 as sc
2942 inner join call_types as ct
2943 on sc.call_type_id = ct.id
2944 and ct.active = 1
2945 and ct.included_in_targets > 0
2946 where linkage_instance_id >= 0
2947 group by ct.id
2948 order by null
2949 ) as t1
2950 left join target_group_calls as tgc
2951 on t1.call_type_id = tgc.call_type_id
2952 left join target_groups as tg
2953 on tgc.target_group_id = tg.id
2954 and tg.active = 1
2955 order by null
2956
2957INFO : (04-17 21:33:50) --> fill: 18 - Scheduler::AutoPopulate::Queries::Query07
2958INFO : (04-17 21:33:50) --> fill: 19 - Scheduler::AutoPopulate::Queries::Query0702
2959INFO : (04-17 21:33:50) --> fill: 20 - Scheduler::AutoPopulate::Queries::Query0705
2960 (148.5ms) insert into buffer_linkage_call_type_assignments_1208161824 (
2961 linkage_instance_id,
2962 call_type_id,
2963 is_weekend,
2964 period_offset,
2965 calendar_schedule_id,
2966 max_assignments,
2967 assignments_count
2968 )
2969 select
2970 s.linkage_instance_id,
2971 s.call_type_id,
2972 s.is_weekend,
2973 s.period_offset,
2974 s.calendar_schedule_id,
2975 case
2976 when (s.is_weekend = 0) then ct.max_weekday_assignments
2977 else ct.max_weekend_assignments
2978 end as _max_assignments,
2979 sum(1) as assignments_count
2980 from buffer_schedules_1208161824 as s
2981 inner join call_types as ct
2982 on s.call_type_id = ct.id
2983 and ct.active = 1
2984 and (
2985 ct.max_weekday_assignments is not null
2986 or ct.max_weekend_assignments is not null
2987 )
2988 where s.linkage_instance_id >= 0
2989 and s.staff_id is null
2990 group by
2991 s.linkage_instance_id,
2992 s.call_type_id,
2993 s.is_weekend,
2994 s.period_offset,
2995 s.calendar_schedule_id,
2996 _max_assignments
2997 having _max_assignments >= 0
2998 order by null
2999
3000INFO : (04-17 21:33:50) --> fill: 21 - Scheduler::AutoPopulate::Queries::Query0706
3001 (147.8ms) insert into buffer_call_type_assignments_1208161824 (
3002 staff_id,
3003 call_type_id,
3004 is_weekend,
3005 period_offset,
3006 calendar_schedule_id,
3007 assignments_count
3008 )
3009 select
3010 sc.staff_id,
3011 sc.call_type_id,
3012 sc.weekend_on as is_weekend,
3013 p.period_offset,
3014 p.calendar_schedule_id,
3015 sum(1) as assignments_count
3016 from buffer_periods_1208161824 as p
3017 inner join call_types as ct
3018 on p.calendar_schedule_id = ct.calendar_schedule_id
3019 and ct.active = 1
3020 and (
3021 ct.max_weekday_assignments is not null
3022 or ct.max_weekend_assignments is not null
3023 )
3024 inner join schedules as sc
3025 on ct.id = sc.call_type_id
3026 and sc.schedule_on between p.start_date and p.end_date
3027 and sc.staff_id is not null
3028 where p.should_be_evaluated = 1
3029 group by
3030 sc.staff_id,
3031 sc.call_type_id,
3032 sc.weekend_on,
3033 p.period_offset,
3034 p.calendar_schedule_id
3035 order by null
3036
3037INFO : (04-17 21:33:50) --> fill: 22 - Scheduler::AutoPopulate::Queries::Query0707
3038INFO : (04-17 21:33:50) --> fill: 23 - Scheduler::AutoPopulate::Queries::Query0708
3039 (149.9ms) insert into buffer_linkage_assigned_days_1208161824 (
3040 linkage_instance_id,
3041 period_offset,
3042 week_number,
3043 schedule_on,
3044 is_weekend
3045 )
3046 select distinct
3047 sc.linkage_instance_id,
3048 sc.period_offset,
3049 sc.week_number,
3050 sc.schedule_on,
3051 sc.is_weekend
3052 from
3053 buffer_schedules_1208161824 as sc
3054 inner join call_types as ct
3055 on sc.call_type_id = ct.id
3056 and ct.unassigned_day = 0
3057 where
3058 sc.linkage_instance_id >= 0
3059 and sc.staff_id is null
3060 order by null
3061
3062INFO : (04-17 21:33:50) --> fill: 24 - Scheduler::AutoPopulate::Queries::Query0709
3063 (149.8ms) /* AnnualDayOfWeekMixRule */
3064 insert into buffer_linkage_dow_targets_1208161824 (
3065 linkage_instance_id,
3066 wday,
3067 period_offset,
3068 calendar_schedule_id,
3069 scheduled
3070 )
3071 select
3072 s.linkage_instance_id,
3073 (dayofweek(s.schedule_on) - 1) as _wday,
3074 -1 as period_offset,
3075 s.calendar_schedule_id,
3076 sum(ci.calls) as _scheduled
3077 from
3078 buffer_schedules_1208161824 as s
3079 inner join buffer_counter_increments_1208161824 as ci
3080 on s.id = ci.schedule_id
3081 and ci.affects_cumulative_targets = 1
3082 where
3083 s.linkage_instance_id >= 0
3084 and s.staff_id is null
3085 group by
3086 s.linkage_instance_id,
3087 _wday,
3088 s.calendar_schedule_id
3089 having _scheduled > 0
3090 order by null
3091
3092INFO : (04-17 21:33:50) --> fill: 25 - Scheduler::AutoPopulate::Queries::Query07_10_AL
3093 (148.9ms) /* AssignmentLimitsPerPeriod, AssignmentLimitsPerWeek, AssignmentLimitsRolling, AssignmentLimitsConsecutive */
3094 insert into buffer_assignment_limit_call_types_1208161824 (
3095 assignment_limit_id, call_type_id
3096 )
3097 select al.id as assignment_limit_id, ct.id as call_type_id
3098 from assignment_limits as al
3099 inner join assignment_limit_call_types as alct
3100 on al.id = alct.assignment_limit_id
3101 inner join call_types as ct
3102 on alct.call_type_id = ct.id
3103 and ct.active = 1
3104 where al.client_id = 319
3105 and al.active = 1
3106 union
3107 select al.id as assignment_limit_id, ct.id as call_type_id
3108 from assignment_limits as al
3109 inner join call_types as ct
3110 on al.client_id = ct.client_id
3111 and al.calendar_schedule_id = ct.calendar_schedule_id
3112 and ct.active = 1
3113 where al.client_id = 319
3114 and al.active = 1
3115 and al.all_current_schedule_assignments = 1
3116 union
3117 select al.id as assignment_limit_id, ct.id as call_type_id
3118 from assignment_limits as al
3119 inner join call_types as ct
3120 on al.client_id = ct.client_id
3121 and al.calendar_schedule_id != ct.calendar_schedule_id
3122 and ct.active = 1
3123 where al.client_id = 319
3124 and al.active = 1
3125 and al.all_other_schedule_assignments = 1
3126 order by null
3127
3128 (149.0ms) /* AssignmentLimitsPerPeriod, AssignmentLimitsPerWeek, AssignmentLimitsRolling, AssignmentLimitsConsecutive */
3129 insert into buffer_assignment_limit_staff_types_1208161824 (
3130 assignment_limit_id, staff_type_id
3131 )
3132 select al.id as assignment_limit_id, st.id as staff_type_id
3133 from assignment_limits as al
3134 inner join assignment_limit_staff_types as alst
3135 on al.id = alst.assignment_limit_id
3136 inner join staff_types as st
3137 on alst.staff_type_id = st.id
3138 and st.active = 1
3139 where al.client_id = 319
3140 and al.active = 1
3141 union
3142 select al.id as assignment_limit_id, st.id as staff_type_id
3143 from assignment_limits as al
3144 inner join staff_types as st
3145 on al.client_id = st.client_id
3146 and st.active = 1
3147 where al.client_id = 319
3148 and al.active = 1
3149 and al.all_staff_types = 1
3150 order by null
3151
3152INFO : (04-17 21:33:50) --> fill: 26 - Scheduler::AutoPopulate::Queries::Query07_10_AL_01
3153 (153.4ms) /* AssignmentLimitsPerPeriod */
3154 insert into buffer_assignment_limit_periods_1208161824 (
3155 assignment_limit_id, period_id, start_date, end_date
3156 )
3157 select
3158 al.id as assignment_limit_id,
3159 if(
3160 bs.blocks_type = 0,
3161 if(
3162 (month(b.start_date) - pt.begin_period) >= 0,
3163 year(b.start_date) * 100 + (month(b.start_date) - pt.begin_period) div pt.timeframe_type + 1,
3164 (year(b.start_date) - 1) * 100 + (month(b.start_date) + 12 - pt.begin_period) div pt.timeframe_type + 1
3165 ),
3166 b.display_order
3167 ) as period_id,
3168 min(b.start_date) as start_date,
3169 max(b.end_date) as end_date
3170 from assignment_limits as al
3171 inner join calendar_schedules as cs
3172 on al.calendar_schedule_id = cs.id
3173 inner join block_schedules as bs
3174 on cs.block_schedule_id = bs.id
3175 inner join blocks as b
3176 on bs.id = b.block_schedule_id
3177 and b.end_date >= date_add(now(), interval -24 month)
3178 inner join population_timeframes as pt
3179 on pt.client_id = 319
3180 and al.timeframe_type = pt.timeframe_type
3181 where al.client_id = 319
3182 and al.active = 1
3183 and al.max_per_period_limit is not null
3184 group by al.id, period_id
3185 order by null
3186
3187 (149.1ms) /* AssignmentLimitsPerPeriod */
3188 insert into buffer_linkage_assignments_count_periods_1208161824 (
3189 linkage_instance_id, assignment_limit_id, schedule_on, start_date, end_date, assignments_count
3190 )
3191 select sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on, alp.start_date, alp.end_date,
3192 count(distinct sc.id) as assignments_count
3193 from buffer_schedules_1208161824 as sc
3194 inner join buffer_assignment_limit_call_types_1208161824 as alct
3195 on sc.call_type_id = alct.call_type_id
3196 inner join assignment_limits as al
3197 on alct.assignment_limit_id = al.id
3198 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
3199 and al.max_per_period_limit is not null
3200 inner join buffer_assignment_limit_periods_1208161824 as alp
3201 on alct.assignment_limit_id = alp.assignment_limit_id
3202 and sc.schedule_on between alp.start_date and alp.end_date
3203 where sc.linkage_instance_id >= 0
3204 and sc.staff_id is null
3205 group by sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on, alp.start_date, alp.end_date
3206 order by null
3207
3208INFO : (04-17 21:33:51) --> fill: 27 - Scheduler::AutoPopulate::Queries::Query07_10_AL_02
3209 (149.1ms) /* AssignmentLimitsPerWeek */
3210 insert into buffer_linkage_assignments_count_weeks_1208161824 (
3211 linkage_instance_id, assignment_limit_id, schedule_on, start_date, end_date, assignments_count
3212 )
3213 select sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on,
3214 if(
3215 cl.start_of_week = 0,
3216 date_add(sc.schedule_on, interval (1 - dayofweek(sc.schedule_on)) day),
3217 date_add(sc.schedule_on, interval (0 - weekday(sc.schedule_on)) day)
3218 ) as start_date,
3219 if(
3220 cl.start_of_week = 0,
3221 date_add(sc.schedule_on, interval (7 - dayofweek(sc.schedule_on)) day),
3222 date_add(sc.schedule_on, interval (6 - weekday(sc.schedule_on)) day)
3223 ) as end_date,
3224 count(distinct sc.id) as assignments_count
3225 from buffer_schedules_1208161824 as sc
3226 inner join buffer_assignment_limit_call_types_1208161824 as alct
3227 on sc.call_type_id = alct.call_type_id
3228 inner join assignment_limits as al
3229 on alct.assignment_limit_id = al.id
3230 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
3231 and al.max_weekly_limit is not null
3232 inner join clients as cl
3233 on cl.id = 319
3234 where sc.linkage_instance_id >= 0
3235 and sc.staff_id is null
3236 group by sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on, start_date, end_date
3237 order by null
3238
3239INFO : (04-17 21:33:51) --> fill: 28 - Scheduler::AutoPopulate::Queries::Query07_10_AL_03
3240 (148.2ms) /* AssignmentLimitsRolling */
3241 insert into buffer_linkage_assignments_count_rolling_1208161824 (
3242 linkage_instance_id, assignment_limit_id, schedule_on, start_date, end_date, assignments_count
3243 )
3244 select sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on,
3245 date_add(sc.schedule_on, interval (1 - ns.item_number) day) as start_date,
3246 date_add(sc.schedule_on, interval (al.max_rolling_period - ns.item_number) day) as end_date,
3247 count(distinct sc.id) as assignments_count
3248 from buffer_schedules_1208161824 as sc
3249 inner join buffer_assignment_limit_call_types_1208161824 as alct
3250 on sc.call_type_id = alct.call_type_id
3251 inner join assignment_limits as al
3252 on alct.assignment_limit_id = al.id
3253 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
3254 and al.max_rolling_period is not null
3255 and al.max_rolling_limit is not null
3256 inner join numeric_sequence as ns
3257 on ns.item_number between 1 and al.max_rolling_period
3258 where sc.linkage_instance_id >= 0
3259 and sc.staff_id is null
3260 group by sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on, start_date, end_date
3261 order by null
3262
3263INFO : (04-17 21:33:51) --> fill: 29 - Scheduler::AutoPopulate::Queries::Query07_10_AL_04
3264 (147.6ms) /* AssignmentLimitsConsecutive */
3265 insert into buffer_linkage_assignments_count_consecutive_1208161824 (
3266 linkage_instance_id, assignment_limit_id, schedule_on, start_date, end_date
3267 )
3268 select sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on,
3269 date_add(sc.schedule_on, interval (1 - ns.item_number) day) as start_date,
3270 date_add(sc.schedule_on, interval ((al.max_consecutive_limit + 1) - ns.item_number) day) as end_date
3271 from buffer_schedules_1208161824 as sc
3272 inner join buffer_assignment_limit_call_types_1208161824 as alct
3273 on sc.call_type_id = alct.call_type_id
3274 inner join assignment_limits as al
3275 on alct.assignment_limit_id = al.id
3276 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
3277 and al.max_consecutive_limit is not null
3278 inner join numeric_sequence as ns
3279 on ns.item_number between 1 and (al.max_consecutive_limit + 1)
3280 where sc.linkage_instance_id >= 0
3281 and sc.staff_id is null
3282 group by sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on, start_date, end_date
3283 order by null
3284
3285INFO : (04-17 21:33:51) --> fill: 30 - Scheduler::AutoPopulate::Queries::Query08
3286 (149.8ms) insert into buffer_staff_daily_counts_1208161824 (
3287 staff_id, schedule_on, linkage_instance_id, slots_count
3288 )
3289 select staff_id, schedule_on, null as linkage_instance_id,
3290 count(1) as slots_count
3291 from buffer_schedules_1208161824
3292 where staff_id is not null
3293 and call_type_id > 0 /* VC */
3294 group by staff_id, schedule_on
3295 order by null
3296
3297 (150.4ms) insert into buffer_staff_daily_counts_1208161824 (
3298 staff_id, schedule_on, linkage_instance_id, slots_count
3299 )
3300 select staff_id, schedule_on, linkage_instance_id,
3301 count(1) as slots_count
3302 from buffer_schedules_1208161824
3303 where staff_id is not null
3304 and call_type_id > 0 /* VC */
3305 group by staff_id, schedule_on, linkage_instance_id
3306 order by null
3307
3308INFO : (04-17 21:33:52) --> fill: 31 - Scheduler::AutoPopulate::Queries::Query085
3309 (315.7ms) insert into buffer_staff_specializations_1208161824 (
3310 staff_id, specialization_id
3311 )
3312 select staff_id, specialization_id
3313 from view_staff_specializations
3314 where client_id = 319
3315 order by null
3316
3317 (150.0ms) insert into buffer_specialization_daily_counts_1208161824 (
3318 specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
3319 )
3320 select sp.id as specialization_id,
3321 null as staff_id,
3322 bs_1.schedule_on,
3323 count(distinct st_sp.staff_id) as staffs_scheduled,
3324 sp.max_scheduled,
3325 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
3326 from (
3327 select schedule_on, day_of_week_mask
3328 from buffer_schedules_1208161824
3329 where should_be_evaluated = 1
3330 group by schedule_on, day_of_week_mask
3331 order by null
3332 ) as bs_1
3333 inner join specializations as sp
3334 on sp.client_id = 319
3335 and sp.active = 1
3336 inner join buffer_schedules_1208161824 as bs_2
3337 on bs_1.schedule_on = bs_2.schedule_on
3338 and bs_2.call_type_id > 0 /* is not VC */
3339 inner join max_applicable_call_types as mact
3340 on sp.id = mact.specialization_id
3341 and bs_2.call_type_id = mact.call_type_id
3342 left join buffer_staff_specializations_1208161824 as st_sp
3343 on bs_2.staff_id = st_sp.staff_id
3344 and sp.id = st_sp.specialization_id
3345 group by sp.id, bs_1.schedule_on, sp.max_scheduled
3346 order by null
3347
3348 (149.3ms) insert into buffer_specialization_daily_counts_1208161824 (
3349 specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
3350 )
3351 select sp.id as specialization_id,
3352 st_sp.staff_id,
3353 bs_1.schedule_on,
3354 1 as staffs_scheduled,
3355 sp.max_scheduled,
3356 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
3357 from (
3358 select schedule_on, day_of_week_mask
3359 from buffer_schedules_1208161824
3360 where should_be_evaluated = 1
3361 group by schedule_on, day_of_week_mask
3362 order by null
3363 ) as bs_1
3364 inner join specializations as sp
3365 on sp.client_id = 319
3366 and sp.active = 1
3367 inner join buffer_schedules_1208161824 as bs_2
3368 on bs_1.schedule_on = bs_2.schedule_on
3369 and bs_2.call_type_id > 0 /* is not VC */
3370 inner join max_applicable_call_types as mact
3371 on sp.id = mact.specialization_id
3372 and bs_2.call_type_id = mact.call_type_id
3373 inner join buffer_staff_specializations_1208161824 as st_sp
3374 on bs_2.staff_id = st_sp.staff_id
3375 and sp.id = st_sp.specialization_id
3376 group by sp.id, st_sp.staff_id, bs_1.schedule_on, sp.max_scheduled
3377 order by null
3378
3379INFO : (04-17 21:33:52) --> fill: 32 - Scheduler::AutoPopulate::Queries::Query09
3380 (149.0ms) truncate table buffer_location_privileges_1208161824
3381
3382 (153.9ms) insert into buffer_location_privileges_1208161824 (
3383 staff_id,
3384 location_id,
3385 begin_date,
3386 end_date
3387 )
3388 select
3389 s.id as staff_id,
3390 l.location_id,
3391 '0000-00-00' as begin_date,
3392 '9999-12-31' as end_date
3393 from (
3394 select l.id as location_id
3395 from
3396 buffer_schedules_1208161824 as sc
3397 inner join call_types as ct
3398 on sc.call_type_id = ct.id
3399 and ct.active = 1
3400 inner join locations as l
3401 on ct.location_id = l.id
3402 and l.active = 1
3403 where sc.linkage_instance_id >= 0
3404 and sc.should_be_evaluated = 1
3405 group by l.id
3406 order by null
3407 ) as l
3408 inner join staffs as s
3409 on s.client_id = 319
3410 and s.active = 1
3411 and s.take_call = 1
3412 and s.auto_populatable = 1
3413 left join location_privileges as lp
3414 on s.id = lp.staff_id
3415 where lp.id is null
3416 union
3417 select
3418 lp.staff_id,
3419 lp.location_id,
3420 lp.begin_date,
3421 lp.end_date
3422 from (
3423 select l.id as location_id
3424 from
3425 buffer_schedules_1208161824 as sc
3426 inner join call_types as ct
3427 on sc.call_type_id = ct.id
3428 and ct.active = 1
3429 inner join locations as l
3430 on ct.location_id = l.id
3431 and l.active = 1
3432 where sc.linkage_instance_id >= 0
3433 and sc.should_be_evaluated = 1
3434 group by l.id
3435 order by null
3436 ) as l
3437 inner join location_privileges as lp
3438 on l.location_id = lp.location_id
3439 order by null;
3440
3441 (410.5ms) insert into buffer_static_availabilities_1208161824 (
3442 schedule_id,
3443 staff_id,
3444 staff_type_id,
3445 is_primary
3446 )
3447 select
3448 schedules.id as schedule_id,
3449 staffs.id as staff_id,
3450 assign_staff_types.staff_type_id,
3451 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
3452 from
3453 buffer_schedules_1208161824 as schedules
3454 /* AvailabilityRule */
3455 inner join call_types
3456 on schedules.call_type_id = call_types.id
3457 and call_types.active = 1
3458 and schedules.day_of_week_mask & call_types.days_of_week_mask > 0
3459 inner join staff_call_types
3460 on call_types.id = staff_call_types.call_type_id
3461 and schedules.day_of_week_mask & (staff_call_types.days_of_week_mask | staff_call_types.secondary_availability_days_of_week_mask) > 0
3462 inner join staffs
3463 on staff_call_types.staff_id = staffs.id
3464 and staffs.active = 1
3465 and staffs.take_call = 1
3466 and staffs.auto_populatable = 1
3467 inner join buffer_location_privileges_1208161824 as location_privileges
3468 on staffs.id = location_privileges.staff_id
3469 and call_types.location_id = location_privileges.location_id
3470 and schedules.schedule_on between location_privileges.begin_date and ifnull(location_privileges.end_date, '9999-12-31')
3471 inner join assign_staff_types
3472 on staffs.id = assign_staff_types.staff_id
3473 and schedules.schedule_on between assign_staff_types.begin_date and ifnull(assign_staff_types.end_date, '9999-12-31')
3474 left join eligible_staff_types
3475 on staff_call_types.call_type_id = eligible_staff_types.call_type_id
3476 and assign_staff_types.staff_type_id = eligible_staff_types.staff_type_id
3477 left join staff_rotations
3478 on staffs.id = staff_rotations.staff_id
3479 and schedules.schedule_on between staff_rotations.start_date and staff_rotations.end_date
3480 left join daily_rotations
3481 on staffs.id = daily_rotations.staff_id
3482 and schedules.schedule_on = daily_rotations.schedule_on
3483 left join rotations
3484 on rotations.id = ifnull(daily_rotations.rotation_id, staff_rotations.rotation_id)
3485 and rotations.active = 1
3486 left join rotation_call_types
3487 on rotations.id = rotation_call_types.rotation_id
3488 and staff_call_types.call_type_id = rotation_call_types.call_type_id
3489 and schedules.day_of_week_mask & (rotation_call_types.days_of_week_mask | rotation_call_types.secondary_availability_days_of_week_mask) > 0
3490 /* RequiredRotationsRule */
3491 left join required_rotations
3492 on staff_call_types.call_type_id = required_rotations.call_type_id
3493 left join staff_rotations as staff_rotations2
3494 on staffs.id = staff_rotations2.staff_id
3495 and required_rotations.rotation_id = staff_rotations2.rotation_id
3496 and schedules.schedule_on >= staff_rotations2.start_date
3497 /* NoCallRequestsHiddenHardRule */
3498 left join request_settings
3499 on assign_staff_types.staff_type_id = request_settings.staff_type_id
3500 left join requests
3501 on schedules.schedule_on = requests.schedule_on
3502 and staffs.id = requests.staff_id
3503 and requests.request_type = 0 /* type = no_call */
3504 and requests.status in (1, 3) /* status = approved or fulfilled */
3505 and call_types.is_no_call_requestable = 1
3506 left join request_call_types
3507 on requests.id = request_call_types.request_id
3508 and schedules.call_type_id = request_call_types.call_type_id
3509 where
3510 schedules.linkage_instance_id >= 0
3511 and schedules.should_be_evaluated = 1
3512 and (
3513 call_types.all_staff_types = 1
3514 or eligible_staff_types.id is not null
3515 )
3516 and (
3517 rotations.id is null
3518 or rotation_call_types.id is not null
3519 )
3520 and (
3521 requests.id is null
3522 or (
3523 requests.all_call_types = 1
3524 and request_settings.call_only_all_call_switch = 1 /* calls only */
3525 and call_types.assignment_type = 1 /* clinical */
3526 )
3527 or (
3528 requests.all_call_types = 0
3529 and request_call_types.id is null
3530 )
3531 )
3532 group by
3533 schedules.id,
3534 staffs.id,
3535 assign_staff_types.staff_type_id,
3536 is_primary
3537 having
3538 sum(if(required_rotations.id is not null and staff_rotations2.id is null, 1, 0)) = 0 /* RequiredRotationsRule */
3539 and is_primary IN (0,1) /* PrimaryAvailabilityRule */
3540 order by null
3541
3542INFO : (04-17 21:33:53) --> fill: 33 - Scheduler::AutoPopulate::Queries::Query092
3543 (149.3ms) /* RotationPostCallRule */
3544 /* Exclude people and slots when a post-call is not allowed on the first day of a rotation */
3545 delete sa
3546 from buffer_static_availabilities_1208161824 as sa
3547 inner join buffer_schedules_1208161824 as sc
3548 on sa.schedule_id = sc.id
3549 inner join call_types as ct
3550 on sc.call_type_id = ct.id
3551 and ct.assignment_type = 0 /* call */
3552 inner join staff_rotations as sr
3553 on sa.staff_id = sr.staff_id
3554 and date_add(sc.schedule_on, interval 1 day) = sr.start_date
3555 inner join rotations as r
3556 on sr.rotation_id = r.id
3557 and r.post_call_allowed = 0
3558
3559INFO : (04-17 21:33:53) --> fill: 34 - Scheduler::AutoPopulate::Queries::Query093
3560INFO : (04-17 21:33:53) --> fill: 35 - Scheduler::AutoPopulate::Queries::Query095
3561 (149.5ms) insert into buffer_negative_relations_1208161824 (
3562 schedule_id,
3563 affected_by_schedule_id,
3564 staff_id
3565 )
3566 select
3567 b_schedules.id as schedule_id,
3568 b_schedules_negative_link.id as affected_by_schedule_id,
3569 b_schedules_negative_link.staff_id
3570 from
3571 buffer_schedules_1208161824 as b_schedules
3572 /* NegativeLinkRule */
3573 inner join negative_links_influences
3574 on b_schedules.day_of_week_mask = negative_links_influences.day_of_week_mask
3575 and b_schedules.call_type_id = negative_links_influences.source_id
3576 and negative_links_influences.source_type = 'CallType'
3577 and negative_links_influences.target_type = 'CallType'
3578 inner join buffer_schedules_1208161824 as b_schedules_negative_link
3579 on date_add(
3580 b_schedules.schedule_on,
3581 interval negative_links_influences.offset day
3582 ) = b_schedules_negative_link.schedule_on
3583 and negative_links_influences.target_id = b_schedules_negative_link.call_type_id
3584 and b_schedules.id != b_schedules_negative_link.id
3585 where
3586 b_schedules.linkage_instance_id >= 0
3587 and b_schedules.should_be_evaluated = 1
3588 order by null
3589
3590 (151.1ms) insert into buffer_negative_relations_1208161824 (
3591 schedule_id,
3592 affected_by_schedule_id,
3593 staff_id
3594 )
3595 select
3596 b_schedules.id as schedule_id,
3597 b_schedules_negative_link.id as affected_by_schedule_id,
3598 b_schedules_negative_link.staff_id
3599 from
3600 buffer_schedules_1208161824 as b_schedules
3601 /* NegativeLinkRule */
3602 inner join negative_links_influences
3603 on b_schedules.day_of_week_mask = negative_links_influences.day_of_week_mask
3604 and b_schedules.call_type_id = negative_links_influences.source_id
3605 and negative_links_influences.source_type = 'CallType'
3606 and negative_links_influences.target_type in ('Vacation', 'NonClinicalType')
3607 inner join buffer_schedules_1208161824 as b_schedules_negative_link
3608 on date_add(
3609 b_schedules.schedule_on,
3610 interval negative_links_influences.offset day
3611 ) = b_schedules_negative_link.schedule_on
3612 and (-1 * negative_links_influences.target_id) = b_schedules_negative_link.call_type_id
3613 and b_schedules.id != b_schedules_negative_link.id
3614 where
3615 b_schedules.linkage_instance_id >= 0
3616 and b_schedules.should_be_evaluated = 1
3617 order by null
3618
3619 (149.3ms) delete from buffer_schedules_1208161824
3620 where call_type_id < 0 /* vacations and non-clinicals */
3621
3622INFO : (04-17 21:33:53) --> fill: 36 - Scheduler::AutoPopulate::Queries::Query097
3623 (190.2ms) insert into buffer_staff_assigned_days_1208161824 (
3624 staff_id, period_offset, week_number, schedule_on, is_weekend, is_assigned
3625 )
3626 select staffs.staff_id,
3627 if(days.within_period = 1, days.period_offset, null) as period_offset,
3628 yearweek(days.schedule_on, if(clients.start_of_week = 0, 2, 7)) as week_number,
3629 days.schedule_on,
3630 if(dayofweek(days.schedule_on) in (7, 1), 1, 0) as is_weekend,
3631 if(schedules.staff_id is not null or vacations.staff_id is not null, 1, 0) as is_assigned
3632 from (
3633 select distinct staff_id
3634 from buffer_static_availabilities_1208161824
3635 order by null
3636 ) as staffs
3637 inner join (
3638 select p.period_offset,
3639 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,
3640 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
3641 from buffer_periods_1208161824 as p
3642 inner join (
3643 select 0 as digit union select 1 union select 2 union select 3 union select 4
3644 union select 5 union select 6 union select 7 union select 8 union select 9
3645 ) as digits_1
3646 inner join (
3647 select 0 as digit union select 1 union select 2 union select 3 union select 4
3648 union select 5 union select 6 union select 7 union select 8 union select 9
3649 ) as digits_2
3650 inner join (
3651 select 0 as digit union select 1 union select 2 union select 3 union select 4
3652 union select 5 union select 6 union select 7 union select 8 union select 9
3653 ) as digits_3
3654 where p.calendar_schedule_id = 1381
3655 and p.should_be_evaluated = 1
3656 and (digits_1.digit * 100 + digits_2.digit * 10 + digits_3.digit) <= datediff(p.end_date, p.start_date) + 12
3657 order by null
3658 ) as days
3659 inner join (
3660 select min(start_date) as start_date, max(end_date) as end_date
3661 from buffer_periods_1208161824
3662 where calendar_schedule_id = 1381
3663 and should_be_evaluated = 1
3664 order by null
3665 ) as limits
3666 inner join clients
3667 on clients.id = 319
3668 left join (
3669 select sc.staff_id, sc.schedule_on
3670 from buffer_periods_1208161824 as p
3671 inner join schedules as sc
3672 on sc.client_id = 319
3673 and sc.schedule_on between date_add(p.start_date, interval -6 day) and date_add(p.end_date, interval 6 day)
3674 inner join call_types as ct
3675 on sc.call_type_id = ct.id
3676 and ct.unassigned_day = 0
3677 where p.calendar_schedule_id = 1381
3678 and p.should_be_evaluated = 1
3679 group by sc.staff_id, sc.schedule_on
3680 order by null
3681 ) as schedules
3682 on staffs.staff_id = schedules.staff_id
3683 and days.schedule_on = schedules.schedule_on
3684 left join (
3685 select v.staff_id, v.schedule_on
3686 from buffer_periods_1208161824 as p
3687 inner join vacations as v
3688 on v.client_id = 319
3689 and v.schedule_on between date_add(p.start_date, interval -6 day) and date_add(p.end_date, interval 6 day)
3690 and v.status IN (3)
3691 inner join non_clinical_types as nct
3692 on v.non_clinical_type_id = nct.id
3693 and nct.active = 1
3694 and nct.unassigned_day = 0
3695 where p.calendar_schedule_id = 1381
3696 and p.should_be_evaluated = 1
3697 group by v.staff_id, v.schedule_on
3698 order by null
3699 ) as vacations
3700 on staffs.staff_id = vacations.staff_id
3701 and days.schedule_on = vacations.schedule_on
3702 where days.within_period = 1
3703 or yearweek(days.schedule_on, if(clients.start_of_week = 0, 2, 7)) in (
3704 yearweek(limits.start_date, if(clients.start_of_week = 0, 2, 7)),
3705 yearweek(limits.end_date, if(clients.start_of_week = 0, 2, 7))
3706 )
3707 order by null
3708
3709INFO : (04-17 21:33:54) --> fill: 37 - Scheduler::AutoPopulate::Queries::Query098
3710 (153.1ms) insert into buffer_combined_availabilities_1208161824 (
3711 schedule_id, staff_id, staff_type_id, is_primary, linkage_instance_id, has_violations
3712 )
3713 select sc.id as schedule_id, sa.staff_id, sa.staff_type_id, sa.is_primary,
3714 sc.linkage_instance_id, 0 as has_violations
3715 from buffer_schedules_1208161824 as sc
3716 /* Static availability */
3717 inner join buffer_static_availabilities_1208161824 as sa
3718 on sc.id = sa.schedule_id
3719 inner join buffer_linkages_1208161824 as l
3720 on sc.linkage_instance_id = l.linkage_instance_id
3721 where sc.should_be_evaluated = 1
3722 and l.has_conflicts = 0
3723
3724 (149.2ms) insert into buffer_schedule_linkages_1208161824 (
3725 staff_id, linkage_instance_id, slots_count
3726 )
3727 select staff_id, linkage_instance_id, count(1) as slots_count
3728 from buffer_schedules_1208161824 use index (ix_buffer_schedules_composite_2)
3729 where staff_id is not null
3730 and linkage_instance_id >= 0
3731 group by staff_id, linkage_instance_id
3732 order by null
3733
3734INFO : (04-17 21:33:54) --> fill: 38 - Scheduler::AutoPopulate::Queries::Query09_09_AL_01
3735 (147.8ms) /* AssignmentLimitsPerPeriod */
3736 insert into buffer_staff_assignments_count_periods_1208161824 (
3737 assignment_limit_id, staff_id, start_date, end_date, assignments_count
3738 )
3739 select straight_join lac.assignment_limit_id, ca.staff_id, lac.start_date, lac.end_date,
3740 count(distinct sc.id) as assignments_count
3741 from (
3742 select linkage_instance_id, assignment_limit_id, start_date, end_date
3743 from buffer_linkage_assignments_count_periods_1208161824
3744 group by linkage_instance_id, assignment_limit_id, start_date, end_date
3745 order by null
3746 ) as lac
3747 inner join (
3748 select linkage_instance_id, staff_id
3749 from buffer_combined_availabilities_1208161824
3750 group by linkage_instance_id, staff_id
3751 order by null
3752 ) as ca
3753 on lac.linkage_instance_id = ca.linkage_instance_id
3754 inner join assignment_limits as al
3755 on lac.assignment_limit_id = al.id
3756 inner join schedules as sc
3757 on ca.staff_id = sc.staff_id
3758 and sc.schedule_on between lac.start_date and lac.end_date
3759 and ((1 << (dayofweek(sc.schedule_on) - 1)) & al.considered_days_of_week_mask) > 0
3760 inner join buffer_assignment_limit_call_types_1208161824 as alct
3761 on lac.assignment_limit_id = alct.assignment_limit_id
3762 and sc.call_type_id = alct.call_type_id
3763 inner join assign_staff_types as ast
3764 on sc.staff_id = ast.staff_id
3765 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
3766 inner join buffer_assignment_limit_staff_types_1208161824 as alst
3767 on lac.assignment_limit_id = alst.assignment_limit_id
3768 and ast.staff_type_id = alst.staff_type_id
3769 group by lac.assignment_limit_id, ca.staff_id, lac.start_date, lac.end_date
3770 order by null
3771
3772INFO : (04-17 21:33:54) --> fill: 39 - Scheduler::AutoPopulate::Queries::Query09_09_AL_02
3773 (147.6ms) /* AssignmentLimitsPerWeek */
3774 insert into buffer_staff_assignments_count_weeks_1208161824 (
3775 assignment_limit_id, staff_id, start_date, end_date, assignments_count
3776 )
3777 select straight_join lac.assignment_limit_id, ca.staff_id, lac.start_date, lac.end_date,
3778 count(distinct sc.id) as assignments_count
3779 from (
3780 select linkage_instance_id, assignment_limit_id, start_date, end_date
3781 from buffer_linkage_assignments_count_weeks_1208161824
3782 group by linkage_instance_id, assignment_limit_id, start_date, end_date
3783 order by null
3784 ) as lac
3785 inner join (
3786 select linkage_instance_id, staff_id
3787 from buffer_combined_availabilities_1208161824
3788 group by linkage_instance_id, staff_id
3789 order by null
3790 ) as ca
3791 on lac.linkage_instance_id = ca.linkage_instance_id
3792 inner join assignment_limits as al
3793 on lac.assignment_limit_id = al.id
3794 inner join schedules as sc
3795 on ca.staff_id = sc.staff_id
3796 and sc.schedule_on between lac.start_date and lac.end_date
3797 and ((1 << (dayofweek(sc.schedule_on) - 1)) & al.considered_days_of_week_mask) > 0
3798 inner join buffer_assignment_limit_call_types_1208161824 as alct
3799 on lac.assignment_limit_id = alct.assignment_limit_id
3800 and sc.call_type_id = alct.call_type_id
3801 inner join assign_staff_types as ast
3802 on sc.staff_id = ast.staff_id
3803 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
3804 inner join buffer_assignment_limit_staff_types_1208161824 as alst
3805 on lac.assignment_limit_id = alst.assignment_limit_id
3806 and ast.staff_type_id = alst.staff_type_id
3807 group by lac.assignment_limit_id, ca.staff_id, lac.start_date, lac.end_date
3808 order by null
3809
3810INFO : (04-17 21:33:54) --> fill: 40 - Scheduler::AutoPopulate::Queries::Query09_09_AL_03
3811 (148.0ms) /* AssignmentLimitsRolling */
3812 insert into buffer_staff_assignments_count_rolling_1208161824 (
3813 assignment_limit_id, staff_id, start_date, end_date, assignments_count
3814 )
3815 select straight_join lac.assignment_limit_id, ca.staff_id, lac.start_date, lac.end_date,
3816 count(distinct sc.id) as assignments_count
3817 from (
3818 select linkage_instance_id, assignment_limit_id, start_date, end_date
3819 from buffer_linkage_assignments_count_rolling_1208161824
3820 group by linkage_instance_id, assignment_limit_id, start_date, end_date
3821 order by null
3822 ) as lac
3823 inner join (
3824 select linkage_instance_id, staff_id
3825 from buffer_combined_availabilities_1208161824
3826 group by linkage_instance_id, staff_id
3827 order by null
3828 ) as ca
3829 on lac.linkage_instance_id = ca.linkage_instance_id
3830 inner join assignment_limits as al
3831 on lac.assignment_limit_id = al.id
3832 inner join schedules as sc
3833 on ca.staff_id = sc.staff_id
3834 and sc.schedule_on between lac.start_date and lac.end_date
3835 and ((1 << (dayofweek(sc.schedule_on) - 1)) & al.considered_days_of_week_mask) > 0
3836 inner join buffer_assignment_limit_call_types_1208161824 as alct
3837 on lac.assignment_limit_id = alct.assignment_limit_id
3838 and sc.call_type_id = alct.call_type_id
3839 inner join assign_staff_types as ast
3840 on sc.staff_id = ast.staff_id
3841 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
3842 inner join buffer_assignment_limit_staff_types_1208161824 as alst
3843 on lac.assignment_limit_id = alst.assignment_limit_id
3844 and ast.staff_type_id = alst.staff_type_id
3845 group by lac.assignment_limit_id, ca.staff_id, lac.start_date, lac.end_date
3846 order by null
3847
3848INFO : (04-17 21:33:54) --> fill: 41 - Scheduler::AutoPopulate::Queries::Query09_09_AL_04
3849 (148.2ms) /* AssignmentLimitsConsecutive */
3850 insert into buffer_staff_assignments_count_consecutive_1208161824 (
3851 assignment_limit_id, staff_id, schedule_on, start_date, end_date
3852 )
3853 select straight_join lac.assignment_limit_id, ca.staff_id, sc.schedule_on, lac.start_date, lac.end_date
3854 from (
3855 select linkage_instance_id, assignment_limit_id, start_date, end_date
3856 from buffer_linkage_assignments_count_consecutive_1208161824
3857 group by linkage_instance_id, assignment_limit_id, start_date, end_date
3858 order by null
3859 ) as lac
3860 inner join (
3861 select linkage_instance_id, staff_id
3862 from buffer_combined_availabilities_1208161824
3863 group by linkage_instance_id, staff_id
3864 order by null
3865 ) as ca
3866 on lac.linkage_instance_id = ca.linkage_instance_id
3867 inner join assignment_limits as al
3868 on lac.assignment_limit_id = al.id
3869 inner join schedules as sc
3870 on ca.staff_id = sc.staff_id
3871 and sc.schedule_on between lac.start_date and lac.end_date
3872 and ((1 << (dayofweek(sc.schedule_on) - 1)) & al.considered_days_of_week_mask) > 0
3873 inner join buffer_assignment_limit_call_types_1208161824 as alct
3874 on lac.assignment_limit_id = alct.assignment_limit_id
3875 and sc.call_type_id = alct.call_type_id
3876 inner join assign_staff_types as ast
3877 on sc.staff_id = ast.staff_id
3878 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
3879 inner join buffer_assignment_limit_staff_types_1208161824 as alst
3880 on lac.assignment_limit_id = alst.assignment_limit_id
3881 and ast.staff_type_id = alst.staff_type_id
3882 group by lac.assignment_limit_id, ca.staff_id, sc.schedule_on, lac.start_date, lac.end_date
3883 order by null
3884
3885INFO : (04-17 21:33:55) --> fill: 42 - Scheduler::AutoPopulate::Queries::Query09_12_Points
3886INFO : (04-17 21:33:55) --> fill: 43 - Scheduler::AutoPopulate::Queries::Query09_12_Hours
3887INFO : (04-17 21:33:55) --> fill: 44 - Scheduler::AutoPopulate::Queries::Query10
3888 RuleSet Load (147.8ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1506 LIMIT 1
3889 Client Load (150.7ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 319 LIMIT 1
3890 (147.4ms) /* SpecializationOverlapRule */
3891 delete ca
3892 from buffer_combined_availabilities_1208161824 as ca use index (ix_buffer_combined_availabilities_composite_1)
3893 inner join buffer_schedules_1208161824 as sc
3894 on ca.schedule_id = sc.id
3895 inner join buffer_staff_specializations_1208161824 as ssp
3896 on ca.staff_id = ssp.staff_id
3897 inner join max_applicable_call_types as mact
3898 on ssp.specialization_id = mact.specialization_id
3899 and sc.call_type_id = mact.call_type_id
3900 inner join buffer_specialization_daily_counts_1208161824 as sdc use index (ix_buffer_specialization_daily_counts_composite_1)
3901 on ssp.specialization_id = sdc.specialization_id
3902 and sc.schedule_on = sdc.schedule_on
3903 and sdc.staff_id is null
3904 left join buffer_specialization_daily_counts_1208161824 as sdc_2 use index (ix_buffer_specialization_daily_counts_composite_1)
3905 on ssp.specialization_id = sdc_2.specialization_id
3906 and sc.schedule_on = sdc_2.schedule_on
3907 and ca.staff_id = sdc_2.staff_id
3908 where sdc.should_be_evaluated = 1
3909 and (sdc.staffs_scheduled + if(sdc_2.id is null, 1, 0)) > sdc.max_scheduled
3910
3911 (147.1ms) delete ca
3912 from buffer_combined_availabilities_1208161824 as ca
3913 inner join (
3914 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
3915 sum(lac.assignments_count) as assignments_count
3916 from (
3917 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
3918 from buffer_combined_availabilities_1208161824 as ca
3919 inner join buffer_schedules_1208161824 as sc
3920 on ca.schedule_id = sc.id
3921 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
3922 order by null
3923 ) as ca_sc
3924 inner join buffer_linkage_assignments_count_weeks_1208161824 as lac
3925 on ca_sc.linkage_instance_id = lac.linkage_instance_id
3926 and ca_sc.schedule_on = lac.schedule_on
3927 inner join buffer_assignment_limit_staff_types_1208161824 as alst
3928 on lac.assignment_limit_id = alst.assignment_limit_id
3929 and ca_sc.staff_type_id = alst.staff_type_id
3930 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
3931 order by null
3932 ) as lac
3933 on ca.linkage_instance_id = lac.linkage_instance_id
3934 and ca.staff_id = lac.staff_id
3935 inner join assignment_limits as al
3936 on lac.assignment_limit_id = al.id
3937 left join buffer_staff_assignments_count_weeks_1208161824 as sac
3938 on lac.assignment_limit_id = sac.assignment_limit_id
3939 and lac.staff_id = sac.staff_id
3940 and lac.start_date = sac.start_date
3941 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_weekly_limit
3942
3943 (148.7ms) delete ca
3944 from buffer_combined_availabilities_1208161824 as ca
3945 inner join (
3946 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
3947 sum(lac.assignments_count) as assignments_count
3948 from (
3949 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
3950 from buffer_combined_availabilities_1208161824 as ca
3951 inner join buffer_schedules_1208161824 as sc
3952 on ca.schedule_id = sc.id
3953 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
3954 order by null
3955 ) as ca_sc
3956 inner join buffer_linkage_assignments_count_periods_1208161824 as lac
3957 on ca_sc.linkage_instance_id = lac.linkage_instance_id
3958 and ca_sc.schedule_on = lac.schedule_on
3959 inner join buffer_assignment_limit_staff_types_1208161824 as alst
3960 on lac.assignment_limit_id = alst.assignment_limit_id
3961 and ca_sc.staff_type_id = alst.staff_type_id
3962 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
3963 order by null
3964 ) as lac
3965 on ca.linkage_instance_id = lac.linkage_instance_id
3966 and ca.staff_id = lac.staff_id
3967 inner join assignment_limits as al
3968 on lac.assignment_limit_id = al.id
3969 left join buffer_staff_assignments_count_periods_1208161824 as sac
3970 on lac.assignment_limit_id = sac.assignment_limit_id
3971 and lac.staff_id = sac.staff_id
3972 and lac.start_date = sac.start_date
3973 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_per_period_limit
3974
3975 (146.9ms) delete ca
3976 from buffer_combined_availabilities_1208161824 as ca
3977 inner join (
3978 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
3979 sum(lac.assignments_count) as assignments_count
3980 from (
3981 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
3982 from buffer_combined_availabilities_1208161824 as ca
3983 inner join buffer_schedules_1208161824 as sc
3984 on ca.schedule_id = sc.id
3985 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
3986 order by null
3987 ) as ca_sc
3988 inner join buffer_linkage_assignments_count_rolling_1208161824 as lac
3989 on ca_sc.linkage_instance_id = lac.linkage_instance_id
3990 and ca_sc.schedule_on = lac.schedule_on
3991 inner join buffer_assignment_limit_staff_types_1208161824 as alst
3992 on lac.assignment_limit_id = alst.assignment_limit_id
3993 and ca_sc.staff_type_id = alst.staff_type_id
3994 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
3995 order by null
3996 ) as lac
3997 on ca.linkage_instance_id = lac.linkage_instance_id
3998 and ca.staff_id = lac.staff_id
3999 inner join assignment_limits as al
4000 on lac.assignment_limit_id = al.id
4001 left join buffer_staff_assignments_count_rolling_1208161824 as sac
4002 on lac.assignment_limit_id = sac.assignment_limit_id
4003 and lac.staff_id = sac.staff_id
4004 and lac.start_date = sac.start_date
4005 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_rolling_limit
4006
4007 (148.6ms) delete ca
4008 from buffer_combined_availabilities_1208161824 as ca
4009 inner join (
4010 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
4011 count(distinct if(sac.id is null, lac.schedule_on, null)) as assignments_count
4012 from (
4013 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4014 from buffer_combined_availabilities_1208161824 as ca
4015 inner join buffer_schedules_1208161824 as sc
4016 on ca.schedule_id = sc.id
4017 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4018 order by null
4019 ) as ca_sc
4020 inner join buffer_linkage_assignments_count_consecutive_1208161824 as lac
4021 on ca_sc.linkage_instance_id = lac.linkage_instance_id
4022 and ca_sc.schedule_on = lac.schedule_on
4023 inner join buffer_assignment_limit_staff_types_1208161824 as alst
4024 on lac.assignment_limit_id = alst.assignment_limit_id
4025 and ca_sc.staff_type_id = alst.staff_type_id
4026 left join buffer_staff_assignments_count_consecutive_1208161824 as sac
4027 on lac.assignment_limit_id = sac.assignment_limit_id
4028 and ca_sc.staff_id = sac.staff_id
4029 and lac.schedule_on = sac.schedule_on
4030 and lac.start_date = sac.start_date
4031 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
4032 order by null
4033 ) as lac
4034 on ca.linkage_instance_id = lac.linkage_instance_id
4035 and ca.staff_id = lac.staff_id
4036 inner join assignment_limits as al
4037 on lac.assignment_limit_id = al.id
4038 left join (
4039 select assignment_limit_id, staff_id, start_date,
4040 count(schedule_on) as assignments_count
4041 from buffer_staff_assignments_count_consecutive_1208161824
4042 group by assignment_limit_id, staff_id, start_date
4043 ) as sac
4044 on lac.assignment_limit_id = sac.assignment_limit_id
4045 and lac.staff_id = sac.staff_id
4046 and lac.start_date = sac.start_date
4047 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_consecutive_limit
4048
4049 (152.1ms) /* AnnualDayOfWeekMixRule */
4050 delete ca
4051 from
4052 buffer_combined_availabilities_1208161824 as ca
4053 inner join buffer_schedules_1208161824 as sc
4054 on ca.schedule_id = sc.id
4055 inner join buffer_linkage_dow_targets_1208161824 as ldowt
4056 on sc.linkage_instance_id = ldowt.linkage_instance_id
4057 and (dayofweek(sc.schedule_on) - 1) = ldowt.wday
4058 and ldowt.period_offset = -1
4059 and sc.calendar_schedule_id = ldowt.calendar_schedule_id
4060 left join buffer_cumulative_dow_targets_1208161824 as dowt
4061 on ca.staff_id = dowt.staff_id
4062 and (dayofweek(sc.schedule_on) - 1) = dowt.wday
4063 and sc.calendar_schedule_id = dowt.calendar_schedule_id
4064 where
4065 (sc.day_of_week_mask & 127 /* AnnualDayOfWeekMixRule "days of week selection" */) > 0
4066 and (coalesce(dowt.scheduled, 0) + ldowt.scheduled) > (round(coalesce(dowt.raw_target /* raw_target | adjusted_target */, 0), 2));
4067
4068 (146.9ms) select
4069 coalesce(max(
4070 case
4071 when (ct.max_weekday_assignments > 0) then 1
4072 else 0
4073 end
4074 ), 0) as weekday_flag,
4075 coalesce(max(
4076 case
4077 when (ct.max_weekend_assignments > 0) then 1
4078 else 0
4079 end
4080 ), 0) as weekend_flag
4081 from
4082 buffer_auto_populate_slots_1208161824 as aps
4083 inner join call_types as ct
4084 on aps.call_type_id = ct.id
4085
4086 (147.1ms) /* MaxAssignmentsRule */
4087 delete ca
4088 from buffer_combined_availabilities_1208161824 as ca
4089 inner join buffer_schedules_1208161824 as sc
4090 on ca.schedule_id = sc.id
4091 inner join buffer_linkage_call_type_assignments_1208161824 as lcta
4092 on sc.linkage_instance_id = lcta.linkage_instance_id
4093 and sc.call_type_id = lcta.call_type_id
4094 and sc.is_weekend = lcta.is_weekend
4095 and sc.period_offset = lcta.period_offset
4096 and sc.calendar_schedule_id = lcta.calendar_schedule_id
4097 left join buffer_call_type_assignments_1208161824 as cta
4098 on ca.staff_id = cta.staff_id
4099 and sc.call_type_id = cta.call_type_id
4100 and sc.is_weekend = cta.is_weekend
4101 and sc.period_offset = cta.period_offset
4102 and sc.calendar_schedule_id = cta.calendar_schedule_id
4103 where
4104 sc.is_weekend in (NULL) /* "weekday (0), weekend (1)" checkboxes */
4105 and (coalesce(cta.assignments_count, 0) + lcta.assignments_count) > lcta.max_assignments;
4106
4107 (146.7ms) /* NegativeLinkRule */
4108 delete ca
4109 from buffer_combined_availabilities_1208161824 as ca use index (ix_buffer_combined_availabilities_composite_1)
4110 inner join buffer_negative_relations_1208161824 as nr use index (ix_buffer_negative_relations_composite_1)
4111 on ca.schedule_id = nr.schedule_id
4112 and ca.staff_id = nr.staff_id
4113
4114 (150.4ms) /* BrokenLinkageRule */
4115 truncate table buffer_combined_availability_linkages_1208161824
4116
4117 (151.4ms) insert into buffer_combined_availability_linkages_1208161824 (
4118 staff_id,
4119 linkage_instance_id,
4120 slots_count,
4121 is_primary,
4122 has_violations
4123 )
4124 select
4125 staff_id,
4126 linkage_instance_id,
4127 count(1) as slots_count,
4128 min(is_primary) as is_primary,
4129 max(has_violations) as has_violations
4130 from buffer_combined_availabilities_1208161824 use index (ix_buffer_combined_availabilities_composite_2)
4131 group by
4132 staff_id,
4133 linkage_instance_id
4134 order by null
4135
4136 (151.8ms) delete ca
4137 from
4138 buffer_combined_availabilities_1208161824 as ca use index (ix_buffer_combined_availabilities_composite_1)
4139 inner join buffer_schedules_1208161824 as sc
4140 on ca.schedule_id = sc.id
4141 inner join buffer_linkages_1208161824 as l
4142 on sc.linkage_instance_id = l.linkage_instance_id
4143 inner join buffer_combined_availability_linkages_1208161824 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
4144 on ca.staff_id = ls_1.staff_id
4145 and sc.linkage_instance_id = ls_1.linkage_instance_id
4146 left join buffer_schedule_linkages_1208161824 as ls_2 use index (ix_buffer_schedule_linkages_composite_1)
4147 on ca.staff_id = ls_2.staff_id
4148 and sc.linkage_instance_id = ls_2.linkage_instance_id
4149 where (ls_1.slots_count + coalesce(ls_2.slots_count, 0)) < l.slots_count_total /* not covering the whole chain */;
4150
4151INFO : (04-17 21:33:57) --> fill: 45 - Scheduler::AutoPopulate::Queries::QueryScore02
4152INFO : (04-17 21:33:57) --> fill: 46 - Scheduler::AutoPopulate::Queries::QueryScore03
4153INFO : (04-17 21:33:57) --> fill: 47 - Scheduler::AutoPopulate::Queries::QueryScore04
4154INFO : (04-17 21:33:57) --> fill: 48 - Scheduler::AutoPopulate::Queries::Query11
4155 (146.7ms) update buffer_schedules_1208161824 as sc
4156 left join buffer_combined_availabilities_1208161824 as ca
4157 on sc.id = ca.schedule_id
4158 set sc.should_be_evaluated = 0,
4159 sc.should_be_populated = 0
4160 where sc.should_be_evaluated = 1
4161 and ca.id is null
4162
4163INFO : (04-17 21:33:57) --> fill: 49 - Scheduler::AutoPopulate::Queries::DropTables
4164INFO : (04-17 21:33:57) Setting up lists...
4165 (148.2ms) select b_schedules.schedule_on, b_schedules.call_type_id, b_schedules.linkage_instance_id, schedules.id as schedule_id
4166 from buffer_schedules_1208161824 as b_schedules
4167 left join schedules
4168 on schedules.client_id = 319
4169 and schedules.call_type_id = b_schedules.call_type_id
4170 and schedules.schedule_on = b_schedules.schedule_on
4171 where b_schedules.linkage_instance_id != -1
4172 order by b_schedules.linkage_instance_id, b_schedules.schedule_on
4173
4174 Schedule Load (147.1ms) SELECT `schedules`.* FROM `schedules` WHERE `schedules`.`id` = 12579456 LIMIT 1
4175 Schedule Load (280.0ms) SELECT `schedules`.* FROM `schedules` WHERE `schedules`.`id` = 12597364 LIMIT 1
4176INFO : (04-17 21:33:57) Begin to populate. Pre-set: 0. Unscheduled: 75.
4177INFO : (04-17 21:33:57) plan unit: [id:201818] [2018-05-06 - OB]
4178INFO : (04-17 21:33:57) plan unit: [id:201819] [2018-05-13 - OB]
4179INFO : (04-17 21:33:57) plan unit: [id:201820] [2018-05-20 - OB]
4180INFO : (04-17 21:33:57) plan unit: [id:201821] [2018-05-27 - OB]
4181INFO : (04-17 21:33:57) plan unit: [id:1201818] [2018-05-06 - OR]
4182INFO : (04-17 21:33:57) plan unit: [id:1201819] [2018-05-13 - OR]
4183INFO : (04-17 21:33:57) plan unit: [id:1201820] [2018-05-20 - OR]
4184INFO : (04-17 21:33:57) plan unit: [id:1201821] [2018-05-27 - OR]
4185INFO : (04-17 21:33:57) plan unit: [id:2201818] [2018-05-06 - BU]
4186INFO : (04-17 21:33:57) plan unit: [id:2201819] [2018-05-13 - BU]
4187INFO : (04-17 21:33:57) plan unit: [id:2201820] [2018-05-20 - BU]
4188INFO : (04-17 21:33:57) plan unit: [id:2201821] [2018-05-27 - BU]
4189INFO : (04-17 21:33:57) plan unit: [id:4201817] [2018-04-30 - OB], [2018-05-01 - OR], [2018-05-02 - OB], [2018-05-03 - OR], [2018-05-04 - OB]
4190INFO : (04-17 21:33:57) plan unit: [id:4201818] [2018-05-07 - OB], [2018-05-08 - OR], [2018-05-09 - OB], [2018-05-10 - OR], [2018-05-11 - OB]
4191INFO : (04-17 21:33:57) plan unit: [id:4201819] [2018-05-14 - OB], [2018-05-15 - OR], [2018-05-16 - OB], [2018-05-17 - OR], [2018-05-18 - OB]
4192INFO : (04-17 21:33:57) plan unit: [id:4201820] [2018-05-21 - OB], [2018-05-22 - OR], [2018-05-23 - OB], [2018-05-24 - OR], [2018-05-25 - OB]
4193INFO : (04-17 21:33:57) plan unit: [id:4201821] [2018-05-28 - OB], [2018-05-29 - OR], [2018-05-30 - OB], [2018-05-31 - OR], [2018-06-01 - OB]
4194INFO : (04-17 21:33:57) plan unit: [id:5201818] [2018-05-07 - OR]
4195INFO : (04-17 21:33:57) plan unit: [id:5201819] [2018-05-14 - OR]
4196INFO : (04-17 21:33:57) plan unit: [id:5201820] [2018-05-21 - OR]
4197INFO : (04-17 21:33:57) plan unit: [id:5201821] [2018-05-28 - OR]
4198INFO : (04-17 21:33:57) plan unit: [id:6201818] [2018-05-07 - BU]
4199INFO : (04-17 21:33:57) plan unit: [id:6201819] [2018-05-14 - BU]
4200INFO : (04-17 21:33:57) plan unit: [id:6201820] [2018-05-21 - BU]
4201INFO : (04-17 21:33:57) plan unit: [id:6201821] [2018-05-28 - BU]
4202INFO : (04-17 21:33:57) plan unit: [id:8201817] [2018-05-01 - OB]
4203INFO : (04-17 21:33:57) plan unit: [id:8201818] [2018-05-08 - OB]
4204INFO : (04-17 21:33:57) plan unit: [id:8201819] [2018-05-15 - OB]
4205INFO : (04-17 21:33:57) plan unit: [id:8201820] [2018-05-22 - OB]
4206INFO : (04-17 21:33:57) plan unit: [id:8201821] [2018-05-29 - OB]
4207INFO : (04-17 21:33:57) plan unit: [id:9201817] [2018-05-01 - BU]
4208INFO : (04-17 21:33:57) plan unit: [id:9201818] [2018-05-08 - BU]
4209INFO : (04-17 21:33:57) plan unit: [id:9201819] [2018-05-15 - BU]
4210INFO : (04-17 21:33:57) plan unit: [id:9201820] [2018-05-22 - BU]
4211INFO : (04-17 21:33:57) plan unit: [id:9201821] [2018-05-29 - BU]
4212INFO : (04-17 21:33:57) plan unit: [id:11201817] [2018-05-02 - OR]
4213INFO : (04-17 21:33:57) plan unit: [id:11201818] [2018-05-09 - OR]
4214INFO : (04-17 21:33:57) plan unit: [id:11201819] [2018-05-16 - OR]
4215INFO : (04-17 21:33:57) plan unit: [id:11201820] [2018-05-23 - OR]
4216INFO : (04-17 21:33:57) plan unit: [id:11201821] [2018-05-30 - OR]
4217INFO : (04-17 21:33:57) plan unit: [id:12201817] [2018-05-02 - BU]
4218INFO : (04-17 21:33:57) plan unit: [id:12201818] [2018-05-09 - BU]
4219INFO : (04-17 21:33:57) plan unit: [id:12201819] [2018-05-16 - BU]
4220INFO : (04-17 21:33:57) plan unit: [id:12201820] [2018-05-23 - BU]
4221INFO : (04-17 21:33:57) plan unit: [id:12201821] [2018-05-30 - BU]
4222INFO : (04-17 21:33:57) plan unit: [id:14201817] [2018-05-03 - OB]
4223INFO : (04-17 21:33:57) plan unit: [id:14201818] [2018-05-10 - OB]
4224INFO : (04-17 21:33:57) plan unit: [id:14201819] [2018-05-17 - OB]
4225INFO : (04-17 21:33:57) plan unit: [id:14201820] [2018-05-24 - OB]
4226INFO : (04-17 21:33:57) plan unit: [id:14201821] [2018-05-31 - OB]
4227INFO : (04-17 21:33:57) plan unit: [id:15201817] [2018-05-03 - BU]
4228INFO : (04-17 21:33:57) plan unit: [id:15201818] [2018-05-10 - BU]
4229INFO : (04-17 21:33:57) plan unit: [id:15201819] [2018-05-17 - BU]
4230INFO : (04-17 21:33:57) plan unit: [id:15201820] [2018-05-24 - BU]
4231INFO : (04-17 21:33:57) plan unit: [id:15201821] [2018-05-31 - BU]
4232INFO : (04-17 21:33:57) plan unit: [id:17201817] [2018-05-04 - OR]
4233INFO : (04-17 21:33:57) plan unit: [id:17201818] [2018-05-11 - OR]
4234INFO : (04-17 21:33:57) plan unit: [id:17201819] [2018-05-18 - OR]
4235INFO : (04-17 21:33:57) plan unit: [id:17201820] [2018-05-25 - OR]
4236INFO : (04-17 21:33:57) plan unit: [id:18201817] [2018-05-04 - BU]
4237INFO : (04-17 21:33:57) plan unit: [id:18201818] [2018-05-11 - BU]
4238INFO : (04-17 21:33:57) plan unit: [id:18201819] [2018-05-18 - BU]
4239INFO : (04-17 21:33:57) plan unit: [id:18201820] [2018-05-25 - BU]
4240INFO : (04-17 21:33:57) plan unit: [id:20201817] [2018-05-05 - OB]
4241INFO : (04-17 21:33:57) plan unit: [id:20201818] [2018-05-12 - OB]
4242INFO : (04-17 21:33:57) plan unit: [id:20201819] [2018-05-19 - OB]
4243INFO : (04-17 21:33:57) plan unit: [id:20201820] [2018-05-26 - OB]
4244INFO : (04-17 21:33:57) plan unit: [id:21201817] [2018-05-05 - OR]
4245INFO : (04-17 21:33:57) plan unit: [id:21201818] [2018-05-12 - OR]
4246INFO : (04-17 21:33:57) plan unit: [id:21201819] [2018-05-19 - OR]
4247INFO : (04-17 21:33:57) plan unit: [id:21201820] [2018-05-26 - OR]
4248INFO : (04-17 21:33:57) plan unit: [id:22201817] [2018-05-05 - BU]
4249INFO : (04-17 21:33:57) plan unit: [id:22201818] [2018-05-12 - BU]
4250INFO : (04-17 21:33:57) plan unit: [id:22201819] [2018-05-19 - BU]
4251INFO : (04-17 21:33:57) plan unit: [id:22201820] [2018-05-26 - BU]
4252 NegativeLink Load (223.0ms) SELECT `negative_links`.* FROM `negative_links` WHERE `negative_links`.`client_id` = 319
4253 (409.0ms) /* SpecializationOverlapRule */
4254 delete ca
4255 from buffer_combined_availabilities_1208161824 as ca use index (ix_buffer_combined_availabilities_composite_1)
4256 inner join buffer_schedules_1208161824 as sc
4257 on ca.schedule_id = sc.id
4258 inner join buffer_staff_specializations_1208161824 as ssp
4259 on ca.staff_id = ssp.staff_id
4260 inner join max_applicable_call_types as mact
4261 on ssp.specialization_id = mact.specialization_id
4262 and sc.call_type_id = mact.call_type_id
4263 inner join buffer_specialization_daily_counts_1208161824 as sdc use index (ix_buffer_specialization_daily_counts_composite_1)
4264 on ssp.specialization_id = sdc.specialization_id
4265 and sc.schedule_on = sdc.schedule_on
4266 and sdc.staff_id is null
4267 left join buffer_specialization_daily_counts_1208161824 as sdc_2 use index (ix_buffer_specialization_daily_counts_composite_1)
4268 on ssp.specialization_id = sdc_2.specialization_id
4269 and sc.schedule_on = sdc_2.schedule_on
4270 and ca.staff_id = sdc_2.staff_id
4271 where sdc.should_be_evaluated = 1
4272 and (sdc.staffs_scheduled + if(sdc_2.id is null, 1, 0)) > sdc.max_scheduled
4273
4274 (147.4ms) delete ca
4275 from buffer_combined_availabilities_1208161824 as ca
4276 inner join (
4277 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
4278 sum(lac.assignments_count) as assignments_count
4279 from (
4280 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4281 from buffer_combined_availabilities_1208161824 as ca
4282 inner join buffer_schedules_1208161824 as sc
4283 on ca.schedule_id = sc.id
4284 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4285 order by null
4286 ) as ca_sc
4287 inner join buffer_linkage_assignments_count_weeks_1208161824 as lac
4288 on ca_sc.linkage_instance_id = lac.linkage_instance_id
4289 and ca_sc.schedule_on = lac.schedule_on
4290 inner join buffer_assignment_limit_staff_types_1208161824 as alst
4291 on lac.assignment_limit_id = alst.assignment_limit_id
4292 and ca_sc.staff_type_id = alst.staff_type_id
4293 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
4294 order by null
4295 ) as lac
4296 on ca.linkage_instance_id = lac.linkage_instance_id
4297 and ca.staff_id = lac.staff_id
4298 inner join assignment_limits as al
4299 on lac.assignment_limit_id = al.id
4300 left join buffer_staff_assignments_count_weeks_1208161824 as sac
4301 on lac.assignment_limit_id = sac.assignment_limit_id
4302 and lac.staff_id = sac.staff_id
4303 and lac.start_date = sac.start_date
4304 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_weekly_limit
4305
4306 (149.7ms) delete ca
4307 from buffer_combined_availabilities_1208161824 as ca
4308 inner join (
4309 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
4310 sum(lac.assignments_count) as assignments_count
4311 from (
4312 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4313 from buffer_combined_availabilities_1208161824 as ca
4314 inner join buffer_schedules_1208161824 as sc
4315 on ca.schedule_id = sc.id
4316 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4317 order by null
4318 ) as ca_sc
4319 inner join buffer_linkage_assignments_count_periods_1208161824 as lac
4320 on ca_sc.linkage_instance_id = lac.linkage_instance_id
4321 and ca_sc.schedule_on = lac.schedule_on
4322 inner join buffer_assignment_limit_staff_types_1208161824 as alst
4323 on lac.assignment_limit_id = alst.assignment_limit_id
4324 and ca_sc.staff_type_id = alst.staff_type_id
4325 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
4326 order by null
4327 ) as lac
4328 on ca.linkage_instance_id = lac.linkage_instance_id
4329 and ca.staff_id = lac.staff_id
4330 inner join assignment_limits as al
4331 on lac.assignment_limit_id = al.id
4332 left join buffer_staff_assignments_count_periods_1208161824 as sac
4333 on lac.assignment_limit_id = sac.assignment_limit_id
4334 and lac.staff_id = sac.staff_id
4335 and lac.start_date = sac.start_date
4336 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_per_period_limit
4337
4338 (169.2ms) delete ca
4339 from buffer_combined_availabilities_1208161824 as ca
4340 inner join (
4341 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
4342 sum(lac.assignments_count) as assignments_count
4343 from (
4344 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4345 from buffer_combined_availabilities_1208161824 as ca
4346 inner join buffer_schedules_1208161824 as sc
4347 on ca.schedule_id = sc.id
4348 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4349 order by null
4350 ) as ca_sc
4351 inner join buffer_linkage_assignments_count_rolling_1208161824 as lac
4352 on ca_sc.linkage_instance_id = lac.linkage_instance_id
4353 and ca_sc.schedule_on = lac.schedule_on
4354 inner join buffer_assignment_limit_staff_types_1208161824 as alst
4355 on lac.assignment_limit_id = alst.assignment_limit_id
4356 and ca_sc.staff_type_id = alst.staff_type_id
4357 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
4358 order by null
4359 ) as lac
4360 on ca.linkage_instance_id = lac.linkage_instance_id
4361 and ca.staff_id = lac.staff_id
4362 inner join assignment_limits as al
4363 on lac.assignment_limit_id = al.id
4364 left join buffer_staff_assignments_count_rolling_1208161824 as sac
4365 on lac.assignment_limit_id = sac.assignment_limit_id
4366 and lac.staff_id = sac.staff_id
4367 and lac.start_date = sac.start_date
4368 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_rolling_limit
4369
4370 (170.6ms) delete ca
4371 from buffer_combined_availabilities_1208161824 as ca
4372 inner join (
4373 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
4374 count(distinct if(sac.id is null, lac.schedule_on, null)) as assignments_count
4375 from (
4376 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4377 from buffer_combined_availabilities_1208161824 as ca
4378 inner join buffer_schedules_1208161824 as sc
4379 on ca.schedule_id = sc.id
4380 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4381 order by null
4382 ) as ca_sc
4383 inner join buffer_linkage_assignments_count_consecutive_1208161824 as lac
4384 on ca_sc.linkage_instance_id = lac.linkage_instance_id
4385 and ca_sc.schedule_on = lac.schedule_on
4386 inner join buffer_assignment_limit_staff_types_1208161824 as alst
4387 on lac.assignment_limit_id = alst.assignment_limit_id
4388 and ca_sc.staff_type_id = alst.staff_type_id
4389 left join buffer_staff_assignments_count_consecutive_1208161824 as sac
4390 on lac.assignment_limit_id = sac.assignment_limit_id
4391 and ca_sc.staff_id = sac.staff_id
4392 and lac.schedule_on = sac.schedule_on
4393 and lac.start_date = sac.start_date
4394 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
4395 order by null
4396 ) as lac
4397 on ca.linkage_instance_id = lac.linkage_instance_id
4398 and ca.staff_id = lac.staff_id
4399 inner join assignment_limits as al
4400 on lac.assignment_limit_id = al.id
4401 left join (
4402 select assignment_limit_id, staff_id, start_date,
4403 count(schedule_on) as assignments_count
4404 from buffer_staff_assignments_count_consecutive_1208161824
4405 group by assignment_limit_id, staff_id, start_date
4406 ) as sac
4407 on lac.assignment_limit_id = sac.assignment_limit_id
4408 and lac.staff_id = sac.staff_id
4409 and lac.start_date = sac.start_date
4410 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_consecutive_limit
4411
4412 (475.3ms) /* AnnualDayOfWeekMixRule */
4413 delete ca
4414 from
4415 buffer_combined_availabilities_1208161824 as ca
4416 inner join buffer_schedules_1208161824 as sc
4417 on ca.schedule_id = sc.id
4418 inner join buffer_linkage_dow_targets_1208161824 as ldowt
4419 on sc.linkage_instance_id = ldowt.linkage_instance_id
4420 and (dayofweek(sc.schedule_on) - 1) = ldowt.wday
4421 and ldowt.period_offset = -1
4422 and sc.calendar_schedule_id = ldowt.calendar_schedule_id
4423 left join buffer_cumulative_dow_targets_1208161824 as dowt
4424 on ca.staff_id = dowt.staff_id
4425 and (dayofweek(sc.schedule_on) - 1) = dowt.wday
4426 and sc.calendar_schedule_id = dowt.calendar_schedule_id
4427 where
4428 (sc.day_of_week_mask & 127 /* AnnualDayOfWeekMixRule "days of week selection" */) > 0
4429 and (coalesce(dowt.scheduled, 0) + ldowt.scheduled) > (round(coalesce(dowt.raw_target /* raw_target | adjusted_target */, 0), 2));
4430
4431 (169.5ms) select
4432 coalesce(max(
4433 case
4434 when (ct.max_weekday_assignments > 0) then 1
4435 else 0
4436 end
4437 ), 0) as weekday_flag,
4438 coalesce(max(
4439 case
4440 when (ct.max_weekend_assignments > 0) then 1
4441 else 0
4442 end
4443 ), 0) as weekend_flag
4444 from
4445 buffer_auto_populate_slots_1208161824 as aps
4446 inner join call_types as ct
4447 on aps.call_type_id = ct.id
4448
4449 (168.5ms) /* MaxAssignmentsRule */
4450 delete ca
4451 from buffer_combined_availabilities_1208161824 as ca
4452 inner join buffer_schedules_1208161824 as sc
4453 on ca.schedule_id = sc.id
4454 inner join buffer_linkage_call_type_assignments_1208161824 as lcta
4455 on sc.linkage_instance_id = lcta.linkage_instance_id
4456 and sc.call_type_id = lcta.call_type_id
4457 and sc.is_weekend = lcta.is_weekend
4458 and sc.period_offset = lcta.period_offset
4459 and sc.calendar_schedule_id = lcta.calendar_schedule_id
4460 left join buffer_call_type_assignments_1208161824 as cta
4461 on ca.staff_id = cta.staff_id
4462 and sc.call_type_id = cta.call_type_id
4463 and sc.is_weekend = cta.is_weekend
4464 and sc.period_offset = cta.period_offset
4465 and sc.calendar_schedule_id = cta.calendar_schedule_id
4466 where
4467 sc.is_weekend in (NULL) /* "weekday (0), weekend (1)" checkboxes */
4468 and (coalesce(cta.assignments_count, 0) + lcta.assignments_count) > lcta.max_assignments;
4469
4470 (169.7ms) /* NegativeLinkRule */
4471 delete ca
4472 from buffer_combined_availabilities_1208161824 as ca use index (ix_buffer_combined_availabilities_composite_1)
4473 inner join buffer_negative_relations_1208161824 as nr use index (ix_buffer_negative_relations_composite_1)
4474 on ca.schedule_id = nr.schedule_id
4475 and ca.staff_id = nr.staff_id
4476
4477 (170.5ms) /* BrokenLinkageRule */
4478 truncate table buffer_combined_availability_linkages_1208161824
4479
4480 (169.6ms) insert into buffer_combined_availability_linkages_1208161824 (
4481 staff_id,
4482 linkage_instance_id,
4483 slots_count,
4484 is_primary,
4485 has_violations
4486 )
4487 select
4488 staff_id,
4489 linkage_instance_id,
4490 count(1) as slots_count,
4491 min(is_primary) as is_primary,
4492 max(has_violations) as has_violations
4493 from buffer_combined_availabilities_1208161824 use index (ix_buffer_combined_availabilities_composite_2)
4494 group by
4495 staff_id,
4496 linkage_instance_id
4497 order by null
4498
4499 (300.0ms) delete ca
4500 from
4501 buffer_combined_availabilities_1208161824 as ca use index (ix_buffer_combined_availabilities_composite_1)
4502 inner join buffer_schedules_1208161824 as sc
4503 on ca.schedule_id = sc.id
4504 inner join buffer_linkages_1208161824 as l
4505 on sc.linkage_instance_id = l.linkage_instance_id
4506 inner join buffer_combined_availability_linkages_1208161824 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
4507 on ca.staff_id = ls_1.staff_id
4508 and sc.linkage_instance_id = ls_1.linkage_instance_id
4509 left join buffer_schedule_linkages_1208161824 as ls_2 use index (ix_buffer_schedule_linkages_composite_1)
4510 on ca.staff_id = ls_2.staff_id
4511 and sc.linkage_instance_id = ls_2.linkage_instance_id
4512 where (ls_1.slots_count + coalesce(ls_2.slots_count, 0)) < l.slots_count_total /* not covering the whole chain */;
4513
4514 (341.0ms) select straight_join
4515 sc.schedule_on,
4516 sc.call_type_id,
4517 count(distinct ca.staff_id) as available_members_count,
4518 group_concat(
4519 distinct concat(if(ls_1.is_primary = 1, 'p', 's'), ca.staff_id)
4520 order by ls_1.is_primary desc, ca.staff_id
4521 separator ', '
4522 ) as available_members_ids,
4523 sc.linkage_instance_id,
4524 l.slots_count_total as linkage_slots_count
4525 from buffer_combined_availabilities_1208161824 as ca
4526 inner join buffer_schedules_1208161824 as sc
4527 on ca.schedule_id = sc.id
4528 inner join buffer_linkages_1208161824 as l
4529 on sc.linkage_instance_id = l.linkage_instance_id
4530 inner join buffer_combined_availability_linkages_1208161824 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
4531 on ca.staff_id = ls_1.staff_id
4532 and sc.linkage_instance_id = ls_1.linkage_instance_id
4533 and ls_1.has_violations = 0
4534 where sc.should_be_evaluated = 1
4535 and sc.should_be_populated = 1
4536 group by sc.schedule_on, sc.call_type_id, sc.linkage_instance_id, l.slots_count_total
4537 order by available_members_count, sc.schedule_on, sc.display_order
4538 limit 1
4539
4540 (188.2ms) truncate table buffer_rule_scores_1208161824
4541
4542 (151.2ms) truncate table buffer_rule_calc_filters_1208161824
4543
4544 (149.8ms) insert into buffer_rule_calc_filters_1208161824 (
4545 linkage_instance_id,
4546 staff_id
4547 ) values (4201817, 20698)
4548
4549 (151.6ms) /* AnnualDayOfWeekMixRule */
4550 insert into buffer_rule_scores_1208161824 (
4551 linkage_instance_id,
4552 schedule_id,
4553 staff_id,
4554 rule_name,
4555 value
4556 )
4557 select
4558 b_schedules.linkage_instance_id,
4559 b_schedules.id as schedule_id,
4560 availabilities.staff_id,
4561 'AnnualDayOfWeekMixRule' as rule_name,
4562 (
4563 (b_targets.raw_target /* depends on a cumulative targets period */ - b_targets.scheduled) /
4564 b_targets.raw_target /* depends on a cumulative targets period */
4565 ) as value
4566 from
4567 buffer_rule_calc_filters_1208161824 as filters
4568 inner join buffer_schedules_1208161824 as b_schedules
4569 on filters.linkage_instance_id = b_schedules.linkage_instance_id
4570 inner join buffer_combined_availabilities_1208161824 as availabilities
4571 on b_schedules.id = availabilities.schedule_id
4572 and filters.staff_id = availabilities.staff_id
4573 inner join call_types
4574 on b_schedules.call_type_id = call_types.id
4575 and call_types.included_in_targets > 0
4576 inner join buffer_cumulative_dow_targets_1208161824 as b_targets
4577 on availabilities.staff_id = b_targets.staff_id
4578 and (dayofweek(b_schedules.schedule_on) - 1) = b_targets.wday
4579 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
4580 order by null
4581
4582 (150.8ms) truncate table buffer_rule_scores_with_corrections_1208161824
4583
4584 (150.8ms) insert into buffer_rule_scores_with_corrections_1208161824 (
4585 linkage_instance_id, schedule_id, staff_id, rule_name, value
4586 )
4587 select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id, rule_scores.rule_name,
4588 ifnull(rule_scores.value, max_values.max_value + 1) as value
4589 from buffer_rule_scores_1208161824 as rule_scores
4590 inner join (
4591 select rule_name, max(value) as max_value
4592 from buffer_rule_scores_1208161824
4593 group by rule_name
4594 order by null
4595 ) as max_values
4596 on rule_scores.rule_name = max_values.rule_name
4597 order by null
4598
4599 (149.5ms) select linkage_instance_id, staff_id, avg(slot_scores) as scores
4600 from (
4601 select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id,
4602 sum(
4603 if((total_values.total_value > 0), (rule_scores.value / total_values.total_value), 0) *
4604 rules.weight *
4605 total_values.slots_count
4606 ) as slot_scores
4607 from buffer_rule_scores_with_corrections_1208161824 as rule_scores
4608 inner join (
4609 select rule_name, sum(abs(value)) as total_value,
4610 count(distinct schedule_id) as slots_count
4611 from buffer_rule_scores_with_corrections_1208161824
4612 group by rule_name
4613 order by null
4614 ) as total_values
4615 on rule_scores.rule_name = total_values.rule_name
4616 inner join rules
4617 on rule_scores.rule_name = rules.type
4618 where rules.rule_set_id = 1506
4619 and rules.applied = 1
4620 group by rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id
4621 order by null
4622 ) as staff_scores
4623 group by linkage_instance_id, staff_id
4624 order by round(avg(slot_scores), 5) desc, rand()
4625 limit 1
4626
4627 PublishedBlock Load (149.8ms) SELECT `published_blocks`.* FROM `published_blocks` INNER JOIN `blocks` ON `blocks`.`id` = `published_blocks`.`block_id` WHERE `published_blocks`.`client_id` = 319 AND ('2018-05-01' BETWEEN blocks.start_date AND blocks.end_date) AND `published_blocks`.`calendar_schedule_id` = 1381 ORDER BY `published_blocks`.`id` ASC LIMIT 1
4628 (147.8ms) BEGIN
4629 (150.0ms) SELECT COALESCE(pb.updated_at, pbct.updated_at)
4630 FROM call_types AS ct
4631 INNER JOIN calendar_schedules AS cs
4632 ON ct.calendar_schedule_id = cs.id
4633 INNER JOIN blocks AS b
4634 ON b.client_id = ct.client_id
4635 AND b.block_schedule_id = cs.block_schedule_id
4636 AND '2018-05-01' BETWEEN b.start_date AND b.end_date
4637 INNER JOIN published_blocks AS pb
4638 ON pb.client_id = ct.client_id
4639 AND pb.block_id = b.id
4640 AND pb.calendar_schedule_id = cs.id
4641 LEFT JOIN published_block_call_types AS pbct
4642 ON pbct.client_id = ct.client_id
4643 AND pbct.assignment_id = ct.id
4644 AND pbct.assignment_type = 'CallType'
4645 AND pbct.block_id = b.id
4646 AND (
4647 (1 << (DAYOFWEEK('2018-05-01') - 1) & pbct.days_of_week_mask) > 0
4648 )
4649 WHERE ct.id = 12693
4650 AND (
4651 (
4652 pb.assignment_ids IS NULL
4653 AND (1 << (DAYOFWEEK('2018-05-01') - 1) & pb.days_of_week_mask) > 0
4654 )
4655 OR pbct.id IS NOT NULL
4656 )
4657
4658 CallType Load (149.6ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 12693 LIMIT 1
4659 Client Load (149.1ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 319 LIMIT 1
4660 Staff Load (154.6ms) SELECT `staffs`.* FROM `staffs` WHERE `staffs`.`id` = 20698 LIMIT 1
4661 Schedule Exists (148.3ms) SELECT 1 AS one FROM `schedules` WHERE `schedules`.`call_type_id` = 12693 AND `schedules`.`client_id` = 319 AND `schedules`.`schedule_on` = '2018-05-01' LIMIT 1
4662 SQL (167.6ms) 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 (319, 12693, 20698, '2018-05-01', '2018-04-17 21:34:03', '2018-04-17 21:34:03', 0, 3, 'auto_populate_step', 166)
4663 VisibleAssignment Load (148.7ms) SELECT `visible_assignments`.* FROM `visible_assignments` WHERE `visible_assignments`.`client_id` = 319 AND `visible_assignments`.`date` = '2018-05-01' AND `visible_assignments`.`assignment_type` = 'CallType' AND `visible_assignments`.`assignment_id` = 12693 ORDER BY `visible_assignments`.`id` ASC LIMIT 1
4664 (152.4ms) COMMIT
4665FLUSHED: nil:nil
4666 PublishedBlock Load (147.3ms) SELECT `published_blocks`.* FROM `published_blocks` INNER JOIN `blocks` ON `blocks`.`id` = `published_blocks`.`block_id` WHERE `published_blocks`.`client_id` = 319 AND ('2018-05-02' BETWEEN blocks.start_date AND blocks.end_date) AND `published_blocks`.`calendar_schedule_id` = 1381 ORDER BY `published_blocks`.`id` ASC LIMIT 1
4667 (146.6ms) BEGIN
4668 (148.0ms) SELECT COALESCE(pb.updated_at, pbct.updated_at)
4669 FROM call_types AS ct
4670 INNER JOIN calendar_schedules AS cs
4671 ON ct.calendar_schedule_id = cs.id
4672 INNER JOIN blocks AS b
4673 ON b.client_id = ct.client_id
4674 AND b.block_schedule_id = cs.block_schedule_id
4675 AND '2018-05-02' BETWEEN b.start_date AND b.end_date
4676 INNER JOIN published_blocks AS pb
4677 ON pb.client_id = ct.client_id
4678 AND pb.block_id = b.id
4679 AND pb.calendar_schedule_id = cs.id
4680 LEFT JOIN published_block_call_types AS pbct
4681 ON pbct.client_id = ct.client_id
4682 AND pbct.assignment_id = ct.id
4683 AND pbct.assignment_type = 'CallType'
4684 AND pbct.block_id = b.id
4685 AND (
4686 (1 << (DAYOFWEEK('2018-05-02') - 1) & pbct.days_of_week_mask) > 0
4687 )
4688 WHERE ct.id = 12692
4689 AND (
4690 (
4691 pb.assignment_ids IS NULL
4692 AND (1 << (DAYOFWEEK('2018-05-02') - 1) & pb.days_of_week_mask) > 0
4693 )
4694 OR pbct.id IS NOT NULL
4695 )
4696
4697 CallType Load (149.1ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 12692 LIMIT 1
4698 Client Load (149.8ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 319 LIMIT 1
4699 Staff Load (149.7ms) SELECT `staffs`.* FROM `staffs` WHERE `staffs`.`id` = 20698 LIMIT 1
4700 Schedule Exists (146.8ms) SELECT 1 AS one FROM `schedules` WHERE `schedules`.`call_type_id` = 12692 AND `schedules`.`client_id` = 319 AND `schedules`.`schedule_on` = '2018-05-02' LIMIT 1
4701 SQL (151.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 (319, 12692, 20698, '2018-05-02', '2018-04-17 21:34:05', '2018-04-17 21:34:05', 0, 4, 'auto_populate_step', 166)
4702 VisibleAssignment Load (147.5ms) SELECT `visible_assignments`.* FROM `visible_assignments` WHERE `visible_assignments`.`client_id` = 319 AND `visible_assignments`.`date` = '2018-05-02' AND `visible_assignments`.`assignment_type` = 'CallType' AND `visible_assignments`.`assignment_id` = 12692 ORDER BY `visible_assignments`.`id` ASC LIMIT 1
4703 (149.2ms) COMMIT
4704FLUSHED: nil:nil
4705 PublishedBlock Load (147.8ms) SELECT `published_blocks`.* FROM `published_blocks` INNER JOIN `blocks` ON `blocks`.`id` = `published_blocks`.`block_id` WHERE `published_blocks`.`client_id` = 319 AND ('2018-05-03' BETWEEN blocks.start_date AND blocks.end_date) AND `published_blocks`.`calendar_schedule_id` = 1381 ORDER BY `published_blocks`.`id` ASC LIMIT 1
4706 (147.2ms) BEGIN
4707 (149.4ms) SELECT COALESCE(pb.updated_at, pbct.updated_at)
4708 FROM call_types AS ct
4709 INNER JOIN calendar_schedules AS cs
4710 ON ct.calendar_schedule_id = cs.id
4711 INNER JOIN blocks AS b
4712 ON b.client_id = ct.client_id
4713 AND b.block_schedule_id = cs.block_schedule_id
4714 AND '2018-05-03' BETWEEN b.start_date AND b.end_date
4715 INNER JOIN published_blocks AS pb
4716 ON pb.client_id = ct.client_id
4717 AND pb.block_id = b.id
4718 AND pb.calendar_schedule_id = cs.id
4719 LEFT JOIN published_block_call_types AS pbct
4720 ON pbct.client_id = ct.client_id
4721 AND pbct.assignment_id = ct.id
4722 AND pbct.assignment_type = 'CallType'
4723 AND pbct.block_id = b.id
4724 AND (
4725 (1 << (DAYOFWEEK('2018-05-03') - 1) & pbct.days_of_week_mask) > 0
4726 )
4727 WHERE ct.id = 12693
4728 AND (
4729 (
4730 pb.assignment_ids IS NULL
4731 AND (1 << (DAYOFWEEK('2018-05-03') - 1) & pb.days_of_week_mask) > 0
4732 )
4733 OR pbct.id IS NOT NULL
4734 )
4735
4736 CallType Load (147.6ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 12693 LIMIT 1
4737 Client Load (150.4ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 319 LIMIT 1
4738 Staff Load (148.0ms) SELECT `staffs`.* FROM `staffs` WHERE `staffs`.`id` = 20698 LIMIT 1
4739 Schedule Exists (146.5ms) SELECT 1 AS one FROM `schedules` WHERE `schedules`.`call_type_id` = 12693 AND `schedules`.`client_id` = 319 AND `schedules`.`schedule_on` = '2018-05-03' LIMIT 1
4740 SQL (151.7ms) 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 (319, 12693, 20698, '2018-05-03', '2018-04-17 21:34:06', '2018-04-17 21:34:06', 0, 5, 'auto_populate_step', 166)
4741 VisibleAssignment Load (153.1ms) SELECT `visible_assignments`.* FROM `visible_assignments` WHERE `visible_assignments`.`client_id` = 319 AND `visible_assignments`.`date` = '2018-05-03' AND `visible_assignments`.`assignment_type` = 'CallType' AND `visible_assignments`.`assignment_id` = 12693 ORDER BY `visible_assignments`.`id` ASC LIMIT 1
4742 (149.6ms) COMMIT
4743FLUSHED: nil:nil
4744 PublishedBlock Load (147.8ms) SELECT `published_blocks`.* FROM `published_blocks` INNER JOIN `blocks` ON `blocks`.`id` = `published_blocks`.`block_id` WHERE `published_blocks`.`client_id` = 319 AND ('2018-05-04' BETWEEN blocks.start_date AND blocks.end_date) AND `published_blocks`.`calendar_schedule_id` = 1381 ORDER BY `published_blocks`.`id` ASC LIMIT 1
4745 (146.9ms) BEGIN
4746 (150.0ms) SELECT COALESCE(pb.updated_at, pbct.updated_at)
4747 FROM call_types AS ct
4748 INNER JOIN calendar_schedules AS cs
4749 ON ct.calendar_schedule_id = cs.id
4750 INNER JOIN blocks AS b
4751 ON b.client_id = ct.client_id
4752 AND b.block_schedule_id = cs.block_schedule_id
4753 AND '2018-05-04' BETWEEN b.start_date AND b.end_date
4754 INNER JOIN published_blocks AS pb
4755 ON pb.client_id = ct.client_id
4756 AND pb.block_id = b.id
4757 AND pb.calendar_schedule_id = cs.id
4758 LEFT JOIN published_block_call_types AS pbct
4759 ON pbct.client_id = ct.client_id
4760 AND pbct.assignment_id = ct.id
4761 AND pbct.assignment_type = 'CallType'
4762 AND pbct.block_id = b.id
4763 AND (
4764 (1 << (DAYOFWEEK('2018-05-04') - 1) & pbct.days_of_week_mask) > 0
4765 )
4766 WHERE ct.id = 12692
4767 AND (
4768 (
4769 pb.assignment_ids IS NULL
4770 AND (1 << (DAYOFWEEK('2018-05-04') - 1) & pb.days_of_week_mask) > 0
4771 )
4772 OR pbct.id IS NOT NULL
4773 )
4774
4775 CallType Load (149.4ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 12692 LIMIT 1
4776 Client Load (151.1ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 319 LIMIT 1
4777 Staff Load (149.4ms) SELECT `staffs`.* FROM `staffs` WHERE `staffs`.`id` = 20698 LIMIT 1
4778 Schedule Exists (146.7ms) SELECT 1 AS one FROM `schedules` WHERE `schedules`.`call_type_id` = 12692 AND `schedules`.`client_id` = 319 AND `schedules`.`schedule_on` = '2018-05-04' LIMIT 1
4779 SQL (151.3ms) 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 (319, 12692, 20698, '2018-05-04', '2018-04-17 21:34:08', '2018-04-17 21:34:08', 0, 6, 'auto_populate_step', 166)
4780 VisibleAssignment Load (150.2ms) SELECT `visible_assignments`.* FROM `visible_assignments` WHERE `visible_assignments`.`client_id` = 319 AND `visible_assignments`.`date` = '2018-05-04' AND `visible_assignments`.`assignment_type` = 'CallType' AND `visible_assignments`.`assignment_id` = 12692 ORDER BY `visible_assignments`.`id` ASC LIMIT 1
4781 (149.0ms) COMMIT
4782FLUSHED: nil:nil
4783 (149.9ms) UPDATE buffer_schedules_1208161824
4784 SET staff_id = 20698,
4785 should_be_populated = 0,
4786 should_be_evaluated = 0
4787 WHERE
4788 call_type_id = 12692
4789 AND schedule_on = '2018-04-30'
4790
4791 (149.5ms) delete from buffer_combined_availabilities_1208161824
4792 where linkage_instance_id = 4201817
4793
4794 (149.6ms) UPDATE buffer_rule_calc_schedules_1208161824
4795 SET staff_id = 20698
4796 WHERE call_type_id = 12692
4797 AND schedule_on = '2018-04-30'
4798
4799 (149.2ms) INSERT INTO buffer_rule_calc_schedules_1208161824
4800 SET staff_id = 20698,
4801 call_type_id = 12692,
4802 schedule_on = '2018-04-30',
4803 day_of_week_mask = 2
4804
4805 (147.7ms) /* NegativeLinkRule */
4806 UPDATE buffer_negative_relations_1208161824
4807 SET staff_id = 20698
4808 WHERE affected_by_schedule_id = (
4809 SELECT id
4810 FROM buffer_schedules_1208161824
4811 WHERE schedule_on = '2018-04-30'
4812 AND call_type_id = 12692
4813 )
4814
4815 (158.9ms) /* SpecializationOverlapRule */
4816 update buffer_staff_specializations_1208161824 as st_sp
4817 inner join max_applicable_call_types as mact
4818 on st_sp.specialization_id = mact.specialization_id
4819 and mact.call_type_id = 12692
4820 inner join buffer_specialization_daily_counts_1208161824 as sp_dc
4821 on st_sp.specialization_id = sp_dc.specialization_id
4822 and sp_dc.staff_id is null
4823 and sp_dc.schedule_on = '2018-04-30'
4824 left join buffer_specialization_daily_counts_1208161824 as sp_dc_2
4825 on st_sp.specialization_id = sp_dc_2.specialization_id
4826 and st_sp.staff_id = sp_dc_2.staff_id
4827 and sp_dc_2.schedule_on = '2018-04-30'
4828 set sp_dc.staffs_scheduled = sp_dc.staffs_scheduled + 1
4829 where st_sp.staff_id = 20698
4830 and sp_dc_2.id is null
4831
4832 (147.7ms) insert into buffer_specialization_daily_counts_1208161824 (
4833 specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
4834 )
4835 select sp.id as specialization_id,
4836 20698 as staff_id,
4837 '2018-04-30' as schedule_on,
4838 1 as staffs_scheduled,
4839 sp.max_scheduled,
4840 sp_dc.should_be_evaluated
4841 from buffer_staff_specializations_1208161824 as st_sp
4842 inner join specializations as sp
4843 on st_sp.specialization_id = sp.id
4844 inner join max_applicable_call_types as mact
4845 on st_sp.specialization_id = mact.specialization_id
4846 and mact.call_type_id = 12692
4847 inner join buffer_specialization_daily_counts_1208161824 as sp_dc
4848 on st_sp.specialization_id = sp_dc.specialization_id
4849 and sp_dc.staff_id is null
4850 and sp_dc.schedule_on = '2018-04-30'
4851 left join buffer_specialization_daily_counts_1208161824 as sp_dc_2
4852 on st_sp.specialization_id = sp_dc_2.specialization_id
4853 and st_sp.staff_id = sp_dc_2.staff_id
4854 and sp_dc_2.schedule_on = '2018-04-30'
4855 where st_sp.staff_id = 20698
4856 and sp_dc_2.id is null
4857
4858 (148.5ms) /* MaxAssignmentsRule */
4859 delete from buffer_linkage_call_type_assignments_1208161824
4860 where linkage_instance_id = 4201817;
4861
4862 (147.0ms) /* MaxAssignmentsRule */
4863 update
4864 buffer_schedules_1208161824 as sc
4865 inner join call_types as ct
4866 on sc.call_type_id = ct.id
4867 and ct.active = 1
4868 inner join buffer_call_type_assignments_1208161824 as cta
4869 on sc.staff_id = cta.staff_id
4870 and sc.call_type_id = cta.call_type_id
4871 and sc.is_weekend = cta.is_weekend
4872 and sc.period_offset = cta.period_offset
4873 and sc.calendar_schedule_id = cta.calendar_schedule_id
4874 set cta.assignments_count = cta.assignments_count + 1
4875 where
4876 sc.schedule_on = '2018-04-30'
4877 and sc.call_type_id = 12692
4878 and sc.staff_id = 20698
4879
4880 (148.7ms) insert into buffer_call_type_assignments_1208161824 (
4881 staff_id,
4882 call_type_id,
4883 is_weekend,
4884 period_offset,
4885 calendar_schedule_id,
4886 assignments_count
4887 )
4888 select
4889 sc.staff_id,
4890 sc.call_type_id,
4891 sc.is_weekend,
4892 sc.period_offset,
4893 sc.calendar_schedule_id,
4894 1 as assignments_count
4895 from buffer_schedules_1208161824 as sc
4896 where
4897 sc.staff_id = 20698
4898 and sc.schedule_on = '2018-04-30'
4899 and sc.call_type_id = 12692
4900
4901 (149.3ms) /* UnassignedDaysRule */
4902 delete from buffer_linkage_assigned_days_1208161824
4903 where linkage_instance_id = 4201817
4904
4905 (147.7ms) /* UnassignedDaysRule */
4906 UPDATE buffer_staff_assigned_days_1208161824 as sad
4907 inner join call_types as ct
4908 on ct.id = 12692
4909 and ct.unassigned_day = 0
4910 SET sad.is_assigned = 1
4911 WHERE sad.staff_id = 20698
4912 AND sad.schedule_on = '2018-04-30'
4913
4914 (148.9ms) /* MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule */
4915 delete from buffer_linkage_dow_targets_1208161824
4916 where linkage_instance_id = 4201817
4917
4918 (149.4ms) /* AnnualDayOfWeekMixRule */
4919 update buffer_schedules_1208161824 as sc
4920 inner join buffer_counter_increments_1208161824 as ci
4921 on sc.id = ci.schedule_id
4922 and ci.affects_cumulative_targets = 1
4923 and ci.calls > 0
4924 inner join buffer_cumulative_dow_targets_1208161824 as t
4925 on sc.staff_id = t.staff_id
4926 and (dayofweek(sc.schedule_on) - 1) = t.wday
4927 and sc.calendar_schedule_id = t.calendar_schedule_id
4928 set t.scheduled = t.scheduled + ci.calls
4929 where sc.schedule_on = '2018-04-30'
4930 and sc.call_type_id = 12692
4931 and sc.staff_id = 20698
4932
4933 (150.2ms) /* AssignmentLimitsPerPeriod */
4934 /* Unique Key: assignment_limit_id, staff_id, start_date */
4935 insert into buffer_staff_assignments_count_periods_1208161824 (
4936 assignment_limit_id, staff_id, start_date, end_date, assignments_count
4937 )
4938 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
4939 1 as assignments_count
4940 from buffer_schedules_1208161824 as sc
4941 inner join buffer_assignment_limit_call_types_1208161824 as alct
4942 on sc.call_type_id = alct.call_type_id
4943 inner join assignment_limits as al
4944 on alct.assignment_limit_id = al.id
4945 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
4946 and al.max_per_period_limit is not null
4947 inner join assign_staff_types as ast
4948 on sc.staff_id = ast.staff_id
4949 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
4950 inner join buffer_assignment_limit_staff_types_1208161824 as alst
4951 on alct.assignment_limit_id = alst.assignment_limit_id
4952 and ast.staff_type_id = alst.staff_type_id
4953 inner join (
4954 select assignment_limit_id, start_date, end_date
4955 from buffer_linkage_assignments_count_periods_1208161824
4956 group by assignment_limit_id, start_date, end_date
4957 order by null
4958 ) as lac
4959 on alct.assignment_limit_id = lac.assignment_limit_id
4960 and sc.schedule_on between lac.start_date and lac.end_date
4961 where sc.schedule_on = '2018-04-30'
4962 and sc.call_type_id = 12692
4963 and sc.staff_id = 20698
4964 on duplicate key update
4965 assignments_count = assignments_count + 1
4966
4967 (149.8ms) /* AssignmentLimitsPerWeek */
4968 /* Unique Key: assignment_limit_id, staff_id, start_date */
4969 insert into buffer_staff_assignments_count_weeks_1208161824 (
4970 assignment_limit_id, staff_id, start_date, end_date, assignments_count
4971 )
4972 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
4973 1 as assignments_count
4974 from buffer_schedules_1208161824 as sc
4975 inner join buffer_assignment_limit_call_types_1208161824 as alct
4976 on sc.call_type_id = alct.call_type_id
4977 inner join assignment_limits as al
4978 on alct.assignment_limit_id = al.id
4979 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
4980 and al.max_weekly_limit is not null
4981 inner join assign_staff_types as ast
4982 on sc.staff_id = ast.staff_id
4983 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
4984 inner join buffer_assignment_limit_staff_types_1208161824 as alst
4985 on alct.assignment_limit_id = alst.assignment_limit_id
4986 and ast.staff_type_id = alst.staff_type_id
4987 inner join (
4988 select assignment_limit_id, start_date, end_date
4989 from buffer_linkage_assignments_count_weeks_1208161824
4990 group by assignment_limit_id, start_date, end_date
4991 order by null
4992 ) as lac
4993 on alct.assignment_limit_id = lac.assignment_limit_id
4994 and sc.schedule_on between lac.start_date and lac.end_date
4995 where sc.schedule_on = '2018-04-30'
4996 and sc.call_type_id = 12692
4997 and sc.staff_id = 20698
4998 on duplicate key update
4999 assignments_count = assignments_count + 1
5000
5001 (148.2ms) /* AssignmentLimitsRolling */
5002 /* Unique Key: assignment_limit_id, staff_id, start_date */
5003 insert into buffer_staff_assignments_count_rolling_1208161824 (
5004 assignment_limit_id, staff_id, start_date, end_date, assignments_count
5005 )
5006 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
5007 1 as assignments_count
5008 from buffer_schedules_1208161824 as sc
5009 inner join buffer_assignment_limit_call_types_1208161824 as alct
5010 on sc.call_type_id = alct.call_type_id
5011 inner join assignment_limits as al
5012 on alct.assignment_limit_id = al.id
5013 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
5014 and al.max_rolling_period is not null
5015 and al.max_rolling_limit is not null
5016 inner join assign_staff_types as ast
5017 on sc.staff_id = ast.staff_id
5018 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
5019 inner join buffer_assignment_limit_staff_types_1208161824 as alst
5020 on alct.assignment_limit_id = alst.assignment_limit_id
5021 and ast.staff_type_id = alst.staff_type_id
5022 inner join (
5023 select assignment_limit_id, start_date, end_date
5024 from buffer_linkage_assignments_count_rolling_1208161824
5025 group by assignment_limit_id, start_date, end_date
5026 order by null
5027 ) as lac
5028 on alct.assignment_limit_id = lac.assignment_limit_id
5029 and sc.schedule_on between lac.start_date and lac.end_date
5030 where sc.schedule_on = '2018-04-30'
5031 and sc.call_type_id = 12692
5032 and sc.staff_id = 20698
5033 on duplicate key update
5034 assignments_count = assignments_count + 1
5035
5036 (149.4ms) /* AssignmentLimitsConsecutive */
5037 /* Unique Key: assignment_limit_id, staff_id, schedule_on, start_date */
5038 insert ignore into buffer_staff_assignments_count_consecutive_1208161824 (
5039 assignment_limit_id, staff_id, schedule_on, start_date, end_date
5040 )
5041 select lac.assignment_limit_id, sc.staff_id, sc.schedule_on, lac.start_date, lac.end_date
5042 from buffer_schedules_1208161824 as sc
5043 inner join buffer_assignment_limit_call_types_1208161824 as alct
5044 on sc.call_type_id = alct.call_type_id
5045 inner join assignment_limits as al
5046 on alct.assignment_limit_id = al.id
5047 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
5048 and al.max_consecutive_limit is not null
5049 inner join assign_staff_types as ast
5050 on sc.staff_id = ast.staff_id
5051 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
5052 inner join buffer_assignment_limit_staff_types_1208161824 as alst
5053 on alct.assignment_limit_id = alst.assignment_limit_id
5054 and ast.staff_type_id = alst.staff_type_id
5055 inner join (
5056 select assignment_limit_id, start_date, end_date
5057 from buffer_linkage_assignments_count_consecutive_1208161824
5058 group by assignment_limit_id, start_date, end_date
5059 order by null
5060 ) as lac
5061 on alct.assignment_limit_id = lac.assignment_limit_id
5062 and sc.schedule_on between lac.start_date and lac.end_date
5063 where sc.schedule_on = '2018-04-30'
5064 and sc.call_type_id = 12692
5065 and sc.staff_id = 20698
5066
5067 (149.0ms) UPDATE buffer_schedules_1208161824
5068 SET staff_id = 20698,
5069 should_be_populated = 0,
5070 should_be_evaluated = 0
5071 WHERE
5072 call_type_id = 12693
5073 AND schedule_on = '2018-05-01'
5074
5075 (148.8ms) delete from buffer_combined_availabilities_1208161824
5076 where linkage_instance_id = 4201817
5077
5078 (148.5ms) UPDATE buffer_rule_calc_schedules_1208161824
5079 SET staff_id = 20698
5080 WHERE call_type_id = 12693
5081 AND schedule_on = '2018-05-01'
5082
5083 (148.7ms) INSERT INTO buffer_rule_calc_schedules_1208161824
5084 SET staff_id = 20698,
5085 call_type_id = 12693,
5086 schedule_on = '2018-05-01',
5087 day_of_week_mask = 4
5088
5089 (146.7ms) /* NegativeLinkRule */
5090 UPDATE buffer_negative_relations_1208161824
5091 SET staff_id = 20698
5092 WHERE affected_by_schedule_id = (
5093 SELECT id
5094 FROM buffer_schedules_1208161824
5095 WHERE schedule_on = '2018-05-01'
5096 AND call_type_id = 12693
5097 )
5098
5099 (147.0ms) /* SpecializationOverlapRule */
5100 update buffer_staff_specializations_1208161824 as st_sp
5101 inner join max_applicable_call_types as mact
5102 on st_sp.specialization_id = mact.specialization_id
5103 and mact.call_type_id = 12693
5104 inner join buffer_specialization_daily_counts_1208161824 as sp_dc
5105 on st_sp.specialization_id = sp_dc.specialization_id
5106 and sp_dc.staff_id is null
5107 and sp_dc.schedule_on = '2018-05-01'
5108 left join buffer_specialization_daily_counts_1208161824 as sp_dc_2
5109 on st_sp.specialization_id = sp_dc_2.specialization_id
5110 and st_sp.staff_id = sp_dc_2.staff_id
5111 and sp_dc_2.schedule_on = '2018-05-01'
5112 set sp_dc.staffs_scheduled = sp_dc.staffs_scheduled + 1
5113 where st_sp.staff_id = 20698
5114 and sp_dc_2.id is null
5115
5116 (146.9ms) insert into buffer_specialization_daily_counts_1208161824 (
5117 specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
5118 )
5119 select sp.id as specialization_id,
5120 20698 as staff_id,
5121 '2018-05-01' as schedule_on,
5122 1 as staffs_scheduled,
5123 sp.max_scheduled,
5124 sp_dc.should_be_evaluated
5125 from buffer_staff_specializations_1208161824 as st_sp
5126 inner join specializations as sp
5127 on st_sp.specialization_id = sp.id
5128 inner join max_applicable_call_types as mact
5129 on st_sp.specialization_id = mact.specialization_id
5130 and mact.call_type_id = 12693
5131 inner join buffer_specialization_daily_counts_1208161824 as sp_dc
5132 on st_sp.specialization_id = sp_dc.specialization_id
5133 and sp_dc.staff_id is null
5134 and sp_dc.schedule_on = '2018-05-01'
5135 left join buffer_specialization_daily_counts_1208161824 as sp_dc_2
5136 on st_sp.specialization_id = sp_dc_2.specialization_id
5137 and st_sp.staff_id = sp_dc_2.staff_id
5138 and sp_dc_2.schedule_on = '2018-05-01'
5139 where st_sp.staff_id = 20698
5140 and sp_dc_2.id is null
5141
5142 (148.4ms) /* MaxAssignmentsRule */
5143 delete from buffer_linkage_call_type_assignments_1208161824
5144 where linkage_instance_id = 4201817;
5145
5146 (149.3ms) /* MaxAssignmentsRule */
5147 update
5148 buffer_schedules_1208161824 as sc
5149 inner join call_types as ct
5150 on sc.call_type_id = ct.id
5151 and ct.active = 1
5152 inner join buffer_call_type_assignments_1208161824 as cta
5153 on sc.staff_id = cta.staff_id
5154 and sc.call_type_id = cta.call_type_id
5155 and sc.is_weekend = cta.is_weekend
5156 and sc.period_offset = cta.period_offset
5157 and sc.calendar_schedule_id = cta.calendar_schedule_id
5158 set cta.assignments_count = cta.assignments_count + 1
5159 where
5160 sc.schedule_on = '2018-05-01'
5161 and sc.call_type_id = 12693
5162 and sc.staff_id = 20698
5163
5164 (149.1ms) insert into buffer_call_type_assignments_1208161824 (
5165 staff_id,
5166 call_type_id,
5167 is_weekend,
5168 period_offset,
5169 calendar_schedule_id,
5170 assignments_count
5171 )
5172 select
5173 sc.staff_id,
5174 sc.call_type_id,
5175 sc.is_weekend,
5176 sc.period_offset,
5177 sc.calendar_schedule_id,
5178 1 as assignments_count
5179 from buffer_schedules_1208161824 as sc
5180 where
5181 sc.staff_id = 20698
5182 and sc.schedule_on = '2018-05-01'
5183 and sc.call_type_id = 12693
5184
5185 (146.5ms) /* UnassignedDaysRule */
5186 delete from buffer_linkage_assigned_days_1208161824
5187 where linkage_instance_id = 4201817
5188
5189 (149.2ms) /* UnassignedDaysRule */
5190 UPDATE buffer_staff_assigned_days_1208161824 as sad
5191 inner join call_types as ct
5192 on ct.id = 12693
5193 and ct.unassigned_day = 0
5194 SET sad.is_assigned = 1
5195 WHERE sad.staff_id = 20698
5196 AND sad.schedule_on = '2018-05-01'
5197
5198 (149.6ms) /* MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule */
5199 delete from buffer_linkage_dow_targets_1208161824
5200 where linkage_instance_id = 4201817
5201
5202 (150.2ms) /* AnnualDayOfWeekMixRule */
5203 update buffer_schedules_1208161824 as sc
5204 inner join buffer_counter_increments_1208161824 as ci
5205 on sc.id = ci.schedule_id
5206 and ci.affects_cumulative_targets = 1
5207 and ci.calls > 0
5208 inner join buffer_cumulative_dow_targets_1208161824 as t
5209 on sc.staff_id = t.staff_id
5210 and (dayofweek(sc.schedule_on) - 1) = t.wday
5211 and sc.calendar_schedule_id = t.calendar_schedule_id
5212 set t.scheduled = t.scheduled + ci.calls
5213 where sc.schedule_on = '2018-05-01'
5214 and sc.call_type_id = 12693
5215 and sc.staff_id = 20698
5216
5217 (148.3ms) /* AssignmentLimitsPerPeriod */
5218 /* Unique Key: assignment_limit_id, staff_id, start_date */
5219 insert into buffer_staff_assignments_count_periods_1208161824 (
5220 assignment_limit_id, staff_id, start_date, end_date, assignments_count
5221 )
5222 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
5223 1 as assignments_count
5224 from buffer_schedules_1208161824 as sc
5225 inner join buffer_assignment_limit_call_types_1208161824 as alct
5226 on sc.call_type_id = alct.call_type_id
5227 inner join assignment_limits as al
5228 on alct.assignment_limit_id = al.id
5229 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
5230 and al.max_per_period_limit is not null
5231 inner join assign_staff_types as ast
5232 on sc.staff_id = ast.staff_id
5233 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
5234 inner join buffer_assignment_limit_staff_types_1208161824 as alst
5235 on alct.assignment_limit_id = alst.assignment_limit_id
5236 and ast.staff_type_id = alst.staff_type_id
5237 inner join (
5238 select assignment_limit_id, start_date, end_date
5239 from buffer_linkage_assignments_count_periods_1208161824
5240 group by assignment_limit_id, start_date, end_date
5241 order by null
5242 ) as lac
5243 on alct.assignment_limit_id = lac.assignment_limit_id
5244 and sc.schedule_on between lac.start_date and lac.end_date
5245 where sc.schedule_on = '2018-05-01'
5246 and sc.call_type_id = 12693
5247 and sc.staff_id = 20698
5248 on duplicate key update
5249 assignments_count = assignments_count + 1
5250
5251 (148.1ms) /* AssignmentLimitsPerWeek */
5252 /* Unique Key: assignment_limit_id, staff_id, start_date */
5253 insert into buffer_staff_assignments_count_weeks_1208161824 (
5254 assignment_limit_id, staff_id, start_date, end_date, assignments_count
5255 )
5256 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
5257 1 as assignments_count
5258 from buffer_schedules_1208161824 as sc
5259 inner join buffer_assignment_limit_call_types_1208161824 as alct
5260 on sc.call_type_id = alct.call_type_id
5261 inner join assignment_limits as al
5262 on alct.assignment_limit_id = al.id
5263 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
5264 and al.max_weekly_limit is not null
5265 inner join assign_staff_types as ast
5266 on sc.staff_id = ast.staff_id
5267 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
5268 inner join buffer_assignment_limit_staff_types_1208161824 as alst
5269 on alct.assignment_limit_id = alst.assignment_limit_id
5270 and ast.staff_type_id = alst.staff_type_id
5271 inner join (
5272 select assignment_limit_id, start_date, end_date
5273 from buffer_linkage_assignments_count_weeks_1208161824
5274 group by assignment_limit_id, start_date, end_date
5275 order by null
5276 ) as lac
5277 on alct.assignment_limit_id = lac.assignment_limit_id
5278 and sc.schedule_on between lac.start_date and lac.end_date
5279 where sc.schedule_on = '2018-05-01'
5280 and sc.call_type_id = 12693
5281 and sc.staff_id = 20698
5282 on duplicate key update
5283 assignments_count = assignments_count + 1
5284
5285 (147.5ms) /* AssignmentLimitsRolling */
5286 /* Unique Key: assignment_limit_id, staff_id, start_date */
5287 insert into buffer_staff_assignments_count_rolling_1208161824 (
5288 assignment_limit_id, staff_id, start_date, end_date, assignments_count
5289 )
5290 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
5291 1 as assignments_count
5292 from buffer_schedules_1208161824 as sc
5293 inner join buffer_assignment_limit_call_types_1208161824 as alct
5294 on sc.call_type_id = alct.call_type_id
5295 inner join assignment_limits as al
5296 on alct.assignment_limit_id = al.id
5297 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
5298 and al.max_rolling_period is not null
5299 and al.max_rolling_limit is not null
5300 inner join assign_staff_types as ast
5301 on sc.staff_id = ast.staff_id
5302 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
5303 inner join buffer_assignment_limit_staff_types_1208161824 as alst
5304 on alct.assignment_limit_id = alst.assignment_limit_id
5305 and ast.staff_type_id = alst.staff_type_id
5306 inner join (
5307 select assignment_limit_id, start_date, end_date
5308 from buffer_linkage_assignments_count_rolling_1208161824
5309 group by assignment_limit_id, start_date, end_date
5310 order by null
5311 ) as lac
5312 on alct.assignment_limit_id = lac.assignment_limit_id
5313 and sc.schedule_on between lac.start_date and lac.end_date
5314 where sc.schedule_on = '2018-05-01'
5315 and sc.call_type_id = 12693
5316 and sc.staff_id = 20698
5317 on duplicate key update
5318 assignments_count = assignments_count + 1
5319
5320 (148.4ms) /* AssignmentLimitsConsecutive */
5321 /* Unique Key: assignment_limit_id, staff_id, schedule_on, start_date */
5322 insert ignore into buffer_staff_assignments_count_consecutive_1208161824 (
5323 assignment_limit_id, staff_id, schedule_on, start_date, end_date
5324 )
5325 select lac.assignment_limit_id, sc.staff_id, sc.schedule_on, lac.start_date, lac.end_date
5326 from buffer_schedules_1208161824 as sc
5327 inner join buffer_assignment_limit_call_types_1208161824 as alct
5328 on sc.call_type_id = alct.call_type_id
5329 inner join assignment_limits as al
5330 on alct.assignment_limit_id = al.id
5331 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
5332 and al.max_consecutive_limit is not null
5333 inner join assign_staff_types as ast
5334 on sc.staff_id = ast.staff_id
5335 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
5336 inner join buffer_assignment_limit_staff_types_1208161824 as alst
5337 on alct.assignment_limit_id = alst.assignment_limit_id
5338 and ast.staff_type_id = alst.staff_type_id
5339 inner join (
5340 select assignment_limit_id, start_date, end_date
5341 from buffer_linkage_assignments_count_consecutive_1208161824
5342 group by assignment_limit_id, start_date, end_date
5343 order by null
5344 ) as lac
5345 on alct.assignment_limit_id = lac.assignment_limit_id
5346 and sc.schedule_on between lac.start_date and lac.end_date
5347 where sc.schedule_on = '2018-05-01'
5348 and sc.call_type_id = 12693
5349 and sc.staff_id = 20698
5350
5351 (149.5ms) UPDATE buffer_schedules_1208161824
5352 SET staff_id = 20698,
5353 should_be_populated = 0,
5354 should_be_evaluated = 0
5355 WHERE
5356 call_type_id = 12692
5357 AND schedule_on = '2018-05-02'
5358
5359 (148.8ms) delete from buffer_combined_availabilities_1208161824
5360 where linkage_instance_id = 4201817
5361
5362 (146.8ms) UPDATE buffer_rule_calc_schedules_1208161824
5363 SET staff_id = 20698
5364 WHERE call_type_id = 12692
5365 AND schedule_on = '2018-05-02'
5366
5367 (148.7ms) INSERT INTO buffer_rule_calc_schedules_1208161824
5368 SET staff_id = 20698,
5369 call_type_id = 12692,
5370 schedule_on = '2018-05-02',
5371 day_of_week_mask = 8
5372
5373 (146.6ms) /* NegativeLinkRule */
5374 UPDATE buffer_negative_relations_1208161824
5375 SET staff_id = 20698
5376 WHERE affected_by_schedule_id = (
5377 SELECT id
5378 FROM buffer_schedules_1208161824
5379 WHERE schedule_on = '2018-05-02'
5380 AND call_type_id = 12692
5381 )
5382
5383 (147.7ms) /* SpecializationOverlapRule */
5384 update buffer_staff_specializations_1208161824 as st_sp
5385 inner join max_applicable_call_types as mact
5386 on st_sp.specialization_id = mact.specialization_id
5387 and mact.call_type_id = 12692
5388 inner join buffer_specialization_daily_counts_1208161824 as sp_dc
5389 on st_sp.specialization_id = sp_dc.specialization_id
5390 and sp_dc.staff_id is null
5391 and sp_dc.schedule_on = '2018-05-02'
5392 left join buffer_specialization_daily_counts_1208161824 as sp_dc_2
5393 on st_sp.specialization_id = sp_dc_2.specialization_id
5394 and st_sp.staff_id = sp_dc_2.staff_id
5395 and sp_dc_2.schedule_on = '2018-05-02'
5396 set sp_dc.staffs_scheduled = sp_dc.staffs_scheduled + 1
5397 where st_sp.staff_id = 20698
5398 and sp_dc_2.id is null
5399
5400 (147.2ms) insert into buffer_specialization_daily_counts_1208161824 (
5401 specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
5402 )
5403 select sp.id as specialization_id,
5404 20698 as staff_id,
5405 '2018-05-02' as schedule_on,
5406 1 as staffs_scheduled,
5407 sp.max_scheduled,
5408 sp_dc.should_be_evaluated
5409 from buffer_staff_specializations_1208161824 as st_sp
5410 inner join specializations as sp
5411 on st_sp.specialization_id = sp.id
5412 inner join max_applicable_call_types as mact
5413 on st_sp.specialization_id = mact.specialization_id
5414 and mact.call_type_id = 12692
5415 inner join buffer_specialization_daily_counts_1208161824 as sp_dc
5416 on st_sp.specialization_id = sp_dc.specialization_id
5417 and sp_dc.staff_id is null
5418 and sp_dc.schedule_on = '2018-05-02'
5419 left join buffer_specialization_daily_counts_1208161824 as sp_dc_2
5420 on st_sp.specialization_id = sp_dc_2.specialization_id
5421 and st_sp.staff_id = sp_dc_2.staff_id
5422 and sp_dc_2.schedule_on = '2018-05-02'
5423 where st_sp.staff_id = 20698
5424 and sp_dc_2.id is null
5425
5426 (149.4ms) /* MaxAssignmentsRule */
5427 delete from buffer_linkage_call_type_assignments_1208161824
5428 where linkage_instance_id = 4201817;
5429
5430 (148.2ms) /* MaxAssignmentsRule */
5431 update
5432 buffer_schedules_1208161824 as sc
5433 inner join call_types as ct
5434 on sc.call_type_id = ct.id
5435 and ct.active = 1
5436 inner join buffer_call_type_assignments_1208161824 as cta
5437 on sc.staff_id = cta.staff_id
5438 and sc.call_type_id = cta.call_type_id
5439 and sc.is_weekend = cta.is_weekend
5440 and sc.period_offset = cta.period_offset
5441 and sc.calendar_schedule_id = cta.calendar_schedule_id
5442 set cta.assignments_count = cta.assignments_count + 1
5443 where
5444 sc.schedule_on = '2018-05-02'
5445 and sc.call_type_id = 12692
5446 and sc.staff_id = 20698
5447
5448 (149.3ms) insert into buffer_call_type_assignments_1208161824 (
5449 staff_id,
5450 call_type_id,
5451 is_weekend,
5452 period_offset,
5453 calendar_schedule_id,
5454 assignments_count
5455 )
5456 select
5457 sc.staff_id,
5458 sc.call_type_id,
5459 sc.is_weekend,
5460 sc.period_offset,
5461 sc.calendar_schedule_id,
5462 1 as assignments_count
5463 from buffer_schedules_1208161824 as sc
5464 where
5465 sc.staff_id = 20698
5466 and sc.schedule_on = '2018-05-02'
5467 and sc.call_type_id = 12692
5468
5469 (147.4ms) /* UnassignedDaysRule */
5470 delete from buffer_linkage_assigned_days_1208161824
5471 where linkage_instance_id = 4201817
5472
5473 (149.3ms) /* UnassignedDaysRule */
5474 UPDATE buffer_staff_assigned_days_1208161824 as sad
5475 inner join call_types as ct
5476 on ct.id = 12692
5477 and ct.unassigned_day = 0
5478 SET sad.is_assigned = 1
5479 WHERE sad.staff_id = 20698
5480 AND sad.schedule_on = '2018-05-02'
5481
5482 (152.0ms) /* MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule */
5483 delete from buffer_linkage_dow_targets_1208161824
5484 where linkage_instance_id = 4201817
5485
5486 (153.3ms) /* AnnualDayOfWeekMixRule */
5487 update buffer_schedules_1208161824 as sc
5488 inner join buffer_counter_increments_1208161824 as ci
5489 on sc.id = ci.schedule_id
5490 and ci.affects_cumulative_targets = 1
5491 and ci.calls > 0
5492 inner join buffer_cumulative_dow_targets_1208161824 as t
5493 on sc.staff_id = t.staff_id
5494 and (dayofweek(sc.schedule_on) - 1) = t.wday
5495 and sc.calendar_schedule_id = t.calendar_schedule_id
5496 set t.scheduled = t.scheduled + ci.calls
5497 where sc.schedule_on = '2018-05-02'
5498 and sc.call_type_id = 12692
5499 and sc.staff_id = 20698
5500
5501 (148.9ms) /* AssignmentLimitsPerPeriod */
5502 /* Unique Key: assignment_limit_id, staff_id, start_date */
5503 insert into buffer_staff_assignments_count_periods_1208161824 (
5504 assignment_limit_id, staff_id, start_date, end_date, assignments_count
5505 )
5506 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
5507 1 as assignments_count
5508 from buffer_schedules_1208161824 as sc
5509 inner join buffer_assignment_limit_call_types_1208161824 as alct
5510 on sc.call_type_id = alct.call_type_id
5511 inner join assignment_limits as al
5512 on alct.assignment_limit_id = al.id
5513 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
5514 and al.max_per_period_limit is not null
5515 inner join assign_staff_types as ast
5516 on sc.staff_id = ast.staff_id
5517 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
5518 inner join buffer_assignment_limit_staff_types_1208161824 as alst
5519 on alct.assignment_limit_id = alst.assignment_limit_id
5520 and ast.staff_type_id = alst.staff_type_id
5521 inner join (
5522 select assignment_limit_id, start_date, end_date
5523 from buffer_linkage_assignments_count_periods_1208161824
5524 group by assignment_limit_id, start_date, end_date
5525 order by null
5526 ) as lac
5527 on alct.assignment_limit_id = lac.assignment_limit_id
5528 and sc.schedule_on between lac.start_date and lac.end_date
5529 where sc.schedule_on = '2018-05-02'
5530 and sc.call_type_id = 12692
5531 and sc.staff_id = 20698
5532 on duplicate key update
5533 assignments_count = assignments_count + 1
5534
5535 (147.8ms) /* AssignmentLimitsPerWeek */
5536 /* Unique Key: assignment_limit_id, staff_id, start_date */
5537 insert into buffer_staff_assignments_count_weeks_1208161824 (
5538 assignment_limit_id, staff_id, start_date, end_date, assignments_count
5539 )
5540 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
5541 1 as assignments_count
5542 from buffer_schedules_1208161824 as sc
5543 inner join buffer_assignment_limit_call_types_1208161824 as alct
5544 on sc.call_type_id = alct.call_type_id
5545 inner join assignment_limits as al
5546 on alct.assignment_limit_id = al.id
5547 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
5548 and al.max_weekly_limit is not null
5549 inner join assign_staff_types as ast
5550 on sc.staff_id = ast.staff_id
5551 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
5552 inner join buffer_assignment_limit_staff_types_1208161824 as alst
5553 on alct.assignment_limit_id = alst.assignment_limit_id
5554 and ast.staff_type_id = alst.staff_type_id
5555 inner join (
5556 select assignment_limit_id, start_date, end_date
5557 from buffer_linkage_assignments_count_weeks_1208161824
5558 group by assignment_limit_id, start_date, end_date
5559 order by null
5560 ) as lac
5561 on alct.assignment_limit_id = lac.assignment_limit_id
5562 and sc.schedule_on between lac.start_date and lac.end_date
5563 where sc.schedule_on = '2018-05-02'
5564 and sc.call_type_id = 12692
5565 and sc.staff_id = 20698
5566 on duplicate key update
5567 assignments_count = assignments_count + 1
5568
5569 (150.2ms) /* AssignmentLimitsRolling */
5570 /* Unique Key: assignment_limit_id, staff_id, start_date */
5571 insert into buffer_staff_assignments_count_rolling_1208161824 (
5572 assignment_limit_id, staff_id, start_date, end_date, assignments_count
5573 )
5574 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
5575 1 as assignments_count
5576 from buffer_schedules_1208161824 as sc
5577 inner join buffer_assignment_limit_call_types_1208161824 as alct
5578 on sc.call_type_id = alct.call_type_id
5579 inner join assignment_limits as al
5580 on alct.assignment_limit_id = al.id
5581 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
5582 and al.max_rolling_period is not null
5583 and al.max_rolling_limit is not null
5584 inner join assign_staff_types as ast
5585 on sc.staff_id = ast.staff_id
5586 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
5587 inner join buffer_assignment_limit_staff_types_1208161824 as alst
5588 on alct.assignment_limit_id = alst.assignment_limit_id
5589 and ast.staff_type_id = alst.staff_type_id
5590 inner join (
5591 select assignment_limit_id, start_date, end_date
5592 from buffer_linkage_assignments_count_rolling_1208161824
5593 group by assignment_limit_id, start_date, end_date
5594 order by null
5595 ) as lac
5596 on alct.assignment_limit_id = lac.assignment_limit_id
5597 and sc.schedule_on between lac.start_date and lac.end_date
5598 where sc.schedule_on = '2018-05-02'
5599 and sc.call_type_id = 12692
5600 and sc.staff_id = 20698
5601 on duplicate key update
5602 assignments_count = assignments_count + 1
5603
5604 (147.3ms) /* AssignmentLimitsConsecutive */
5605 /* Unique Key: assignment_limit_id, staff_id, schedule_on, start_date */
5606 insert ignore into buffer_staff_assignments_count_consecutive_1208161824 (
5607 assignment_limit_id, staff_id, schedule_on, start_date, end_date
5608 )
5609 select lac.assignment_limit_id, sc.staff_id, sc.schedule_on, lac.start_date, lac.end_date
5610 from buffer_schedules_1208161824 as sc
5611 inner join buffer_assignment_limit_call_types_1208161824 as alct
5612 on sc.call_type_id = alct.call_type_id
5613 inner join assignment_limits as al
5614 on alct.assignment_limit_id = al.id
5615 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
5616 and al.max_consecutive_limit is not null
5617 inner join assign_staff_types as ast
5618 on sc.staff_id = ast.staff_id
5619 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
5620 inner join buffer_assignment_limit_staff_types_1208161824 as alst
5621 on alct.assignment_limit_id = alst.assignment_limit_id
5622 and ast.staff_type_id = alst.staff_type_id
5623 inner join (
5624 select assignment_limit_id, start_date, end_date
5625 from buffer_linkage_assignments_count_consecutive_1208161824
5626 group by assignment_limit_id, start_date, end_date
5627 order by null
5628 ) as lac
5629 on alct.assignment_limit_id = lac.assignment_limit_id
5630 and sc.schedule_on between lac.start_date and lac.end_date
5631 where sc.schedule_on = '2018-05-02'
5632 and sc.call_type_id = 12692
5633 and sc.staff_id = 20698
5634
5635 (148.7ms) UPDATE buffer_schedules_1208161824
5636 SET staff_id = 20698,
5637 should_be_populated = 0,
5638 should_be_evaluated = 0
5639 WHERE
5640 call_type_id = 12693
5641 AND schedule_on = '2018-05-03'
5642
5643 (148.2ms) delete from buffer_combined_availabilities_1208161824
5644 where linkage_instance_id = 4201817
5645
5646 (146.6ms) UPDATE buffer_rule_calc_schedules_1208161824
5647 SET staff_id = 20698
5648 WHERE call_type_id = 12693
5649 AND schedule_on = '2018-05-03'
5650
5651 (149.0ms) INSERT INTO buffer_rule_calc_schedules_1208161824
5652 SET staff_id = 20698,
5653 call_type_id = 12693,
5654 schedule_on = '2018-05-03',
5655 day_of_week_mask = 16
5656
5657 (148.1ms) /* NegativeLinkRule */
5658 UPDATE buffer_negative_relations_1208161824
5659 SET staff_id = 20698
5660 WHERE affected_by_schedule_id = (
5661 SELECT id
5662 FROM buffer_schedules_1208161824
5663 WHERE schedule_on = '2018-05-03'
5664 AND call_type_id = 12693
5665 )
5666
5667 (147.6ms) /* SpecializationOverlapRule */
5668 update buffer_staff_specializations_1208161824 as st_sp
5669 inner join max_applicable_call_types as mact
5670 on st_sp.specialization_id = mact.specialization_id
5671 and mact.call_type_id = 12693
5672 inner join buffer_specialization_daily_counts_1208161824 as sp_dc
5673 on st_sp.specialization_id = sp_dc.specialization_id
5674 and sp_dc.staff_id is null
5675 and sp_dc.schedule_on = '2018-05-03'
5676 left join buffer_specialization_daily_counts_1208161824 as sp_dc_2
5677 on st_sp.specialization_id = sp_dc_2.specialization_id
5678 and st_sp.staff_id = sp_dc_2.staff_id
5679 and sp_dc_2.schedule_on = '2018-05-03'
5680 set sp_dc.staffs_scheduled = sp_dc.staffs_scheduled + 1
5681 where st_sp.staff_id = 20698
5682 and sp_dc_2.id is null
5683
5684 (148.5ms) insert into buffer_specialization_daily_counts_1208161824 (
5685 specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
5686 )
5687 select sp.id as specialization_id,
5688 20698 as staff_id,
5689 '2018-05-03' as schedule_on,
5690 1 as staffs_scheduled,
5691 sp.max_scheduled,
5692 sp_dc.should_be_evaluated
5693 from buffer_staff_specializations_1208161824 as st_sp
5694 inner join specializations as sp
5695 on st_sp.specialization_id = sp.id
5696 inner join max_applicable_call_types as mact
5697 on st_sp.specialization_id = mact.specialization_id
5698 and mact.call_type_id = 12693
5699 inner join buffer_specialization_daily_counts_1208161824 as sp_dc
5700 on st_sp.specialization_id = sp_dc.specialization_id
5701 and sp_dc.staff_id is null
5702 and sp_dc.schedule_on = '2018-05-03'
5703 left join buffer_specialization_daily_counts_1208161824 as sp_dc_2
5704 on st_sp.specialization_id = sp_dc_2.specialization_id
5705 and st_sp.staff_id = sp_dc_2.staff_id
5706 and sp_dc_2.schedule_on = '2018-05-03'
5707 where st_sp.staff_id = 20698
5708 and sp_dc_2.id is null
5709
5710 (151.2ms) /* MaxAssignmentsRule */
5711 delete from buffer_linkage_call_type_assignments_1208161824
5712 where linkage_instance_id = 4201817;
5713
5714 (151.1ms) /* MaxAssignmentsRule */
5715 update
5716 buffer_schedules_1208161824 as sc
5717 inner join call_types as ct
5718 on sc.call_type_id = ct.id
5719 and ct.active = 1
5720 inner join buffer_call_type_assignments_1208161824 as cta
5721 on sc.staff_id = cta.staff_id
5722 and sc.call_type_id = cta.call_type_id
5723 and sc.is_weekend = cta.is_weekend
5724 and sc.period_offset = cta.period_offset
5725 and sc.calendar_schedule_id = cta.calendar_schedule_id
5726 set cta.assignments_count = cta.assignments_count + 1
5727 where
5728 sc.schedule_on = '2018-05-03'
5729 and sc.call_type_id = 12693
5730 and sc.staff_id = 20698
5731
5732 (149.5ms) /* UnassignedDaysRule */
5733 delete from buffer_linkage_assigned_days_1208161824
5734 where linkage_instance_id = 4201817
5735
5736 (148.9ms) /* UnassignedDaysRule */
5737 UPDATE buffer_staff_assigned_days_1208161824 as sad
5738 inner join call_types as ct
5739 on ct.id = 12693
5740 and ct.unassigned_day = 0
5741 SET sad.is_assigned = 1
5742 WHERE sad.staff_id = 20698
5743 AND sad.schedule_on = '2018-05-03'
5744
5745 (169.0ms) /* MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule */
5746 delete from buffer_linkage_dow_targets_1208161824
5747 where linkage_instance_id = 4201817
5748
5749 (149.4ms) /* AnnualDayOfWeekMixRule */
5750 update buffer_schedules_1208161824 as sc
5751 inner join buffer_counter_increments_1208161824 as ci
5752 on sc.id = ci.schedule_id
5753 and ci.affects_cumulative_targets = 1
5754 and ci.calls > 0
5755 inner join buffer_cumulative_dow_targets_1208161824 as t
5756 on sc.staff_id = t.staff_id
5757 and (dayofweek(sc.schedule_on) - 1) = t.wday
5758 and sc.calendar_schedule_id = t.calendar_schedule_id
5759 set t.scheduled = t.scheduled + ci.calls
5760 where sc.schedule_on = '2018-05-03'
5761 and sc.call_type_id = 12693
5762 and sc.staff_id = 20698
5763
5764 (149.2ms) /* AssignmentLimitsPerPeriod */
5765 /* Unique Key: assignment_limit_id, staff_id, start_date */
5766 insert into buffer_staff_assignments_count_periods_1208161824 (
5767 assignment_limit_id, staff_id, start_date, end_date, assignments_count
5768 )
5769 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
5770 1 as assignments_count
5771 from buffer_schedules_1208161824 as sc
5772 inner join buffer_assignment_limit_call_types_1208161824 as alct
5773 on sc.call_type_id = alct.call_type_id
5774 inner join assignment_limits as al
5775 on alct.assignment_limit_id = al.id
5776 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
5777 and al.max_per_period_limit is not null
5778 inner join assign_staff_types as ast
5779 on sc.staff_id = ast.staff_id
5780 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
5781 inner join buffer_assignment_limit_staff_types_1208161824 as alst
5782 on alct.assignment_limit_id = alst.assignment_limit_id
5783 and ast.staff_type_id = alst.staff_type_id
5784 inner join (
5785 select assignment_limit_id, start_date, end_date
5786 from buffer_linkage_assignments_count_periods_1208161824
5787 group by assignment_limit_id, start_date, end_date
5788 order by null
5789 ) as lac
5790 on alct.assignment_limit_id = lac.assignment_limit_id
5791 and sc.schedule_on between lac.start_date and lac.end_date
5792 where sc.schedule_on = '2018-05-03'
5793 and sc.call_type_id = 12693
5794 and sc.staff_id = 20698
5795 on duplicate key update
5796 assignments_count = assignments_count + 1
5797
5798 (147.8ms) /* AssignmentLimitsPerWeek */
5799 /* Unique Key: assignment_limit_id, staff_id, start_date */
5800 insert into buffer_staff_assignments_count_weeks_1208161824 (
5801 assignment_limit_id, staff_id, start_date, end_date, assignments_count
5802 )
5803 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
5804 1 as assignments_count
5805 from buffer_schedules_1208161824 as sc
5806 inner join buffer_assignment_limit_call_types_1208161824 as alct
5807 on sc.call_type_id = alct.call_type_id
5808 inner join assignment_limits as al
5809 on alct.assignment_limit_id = al.id
5810 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
5811 and al.max_weekly_limit is not null
5812 inner join assign_staff_types as ast
5813 on sc.staff_id = ast.staff_id
5814 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
5815 inner join buffer_assignment_limit_staff_types_1208161824 as alst
5816 on alct.assignment_limit_id = alst.assignment_limit_id
5817 and ast.staff_type_id = alst.staff_type_id
5818 inner join (
5819 select assignment_limit_id, start_date, end_date
5820 from buffer_linkage_assignments_count_weeks_1208161824
5821 group by assignment_limit_id, start_date, end_date
5822 order by null
5823 ) as lac
5824 on alct.assignment_limit_id = lac.assignment_limit_id
5825 and sc.schedule_on between lac.start_date and lac.end_date
5826 where sc.schedule_on = '2018-05-03'
5827 and sc.call_type_id = 12693
5828 and sc.staff_id = 20698
5829 on duplicate key update
5830 assignments_count = assignments_count + 1
5831
5832 (147.4ms) /* AssignmentLimitsRolling */
5833 /* Unique Key: assignment_limit_id, staff_id, start_date */
5834 insert into buffer_staff_assignments_count_rolling_1208161824 (
5835 assignment_limit_id, staff_id, start_date, end_date, assignments_count
5836 )
5837 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
5838 1 as assignments_count
5839 from buffer_schedules_1208161824 as sc
5840 inner join buffer_assignment_limit_call_types_1208161824 as alct
5841 on sc.call_type_id = alct.call_type_id
5842 inner join assignment_limits as al
5843 on alct.assignment_limit_id = al.id
5844 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
5845 and al.max_rolling_period is not null
5846 and al.max_rolling_limit is not null
5847 inner join assign_staff_types as ast
5848 on sc.staff_id = ast.staff_id
5849 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
5850 inner join buffer_assignment_limit_staff_types_1208161824 as alst
5851 on alct.assignment_limit_id = alst.assignment_limit_id
5852 and ast.staff_type_id = alst.staff_type_id
5853 inner join (
5854 select assignment_limit_id, start_date, end_date
5855 from buffer_linkage_assignments_count_rolling_1208161824
5856 group by assignment_limit_id, start_date, end_date
5857 order by null
5858 ) as lac
5859 on alct.assignment_limit_id = lac.assignment_limit_id
5860 and sc.schedule_on between lac.start_date and lac.end_date
5861 where sc.schedule_on = '2018-05-03'
5862 and sc.call_type_id = 12693
5863 and sc.staff_id = 20698
5864 on duplicate key update
5865 assignments_count = assignments_count + 1
5866
5867 (148.4ms) /* AssignmentLimitsConsecutive */
5868 /* Unique Key: assignment_limit_id, staff_id, schedule_on, start_date */
5869 insert ignore into buffer_staff_assignments_count_consecutive_1208161824 (
5870 assignment_limit_id, staff_id, schedule_on, start_date, end_date
5871 )
5872 select lac.assignment_limit_id, sc.staff_id, sc.schedule_on, lac.start_date, lac.end_date
5873 from buffer_schedules_1208161824 as sc
5874 inner join buffer_assignment_limit_call_types_1208161824 as alct
5875 on sc.call_type_id = alct.call_type_id
5876 inner join assignment_limits as al
5877 on alct.assignment_limit_id = al.id
5878 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
5879 and al.max_consecutive_limit is not null
5880 inner join assign_staff_types as ast
5881 on sc.staff_id = ast.staff_id
5882 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
5883 inner join buffer_assignment_limit_staff_types_1208161824 as alst
5884 on alct.assignment_limit_id = alst.assignment_limit_id
5885 and ast.staff_type_id = alst.staff_type_id
5886 inner join (
5887 select assignment_limit_id, start_date, end_date
5888 from buffer_linkage_assignments_count_consecutive_1208161824
5889 group by assignment_limit_id, start_date, end_date
5890 order by null
5891 ) as lac
5892 on alct.assignment_limit_id = lac.assignment_limit_id
5893 and sc.schedule_on between lac.start_date and lac.end_date
5894 where sc.schedule_on = '2018-05-03'
5895 and sc.call_type_id = 12693
5896 and sc.staff_id = 20698
5897
5898 (149.8ms) UPDATE buffer_schedules_1208161824
5899 SET staff_id = 20698,
5900 should_be_populated = 0,
5901 should_be_evaluated = 0
5902 WHERE
5903 call_type_id = 12692
5904 AND schedule_on = '2018-05-04'
5905
5906 (149.9ms) delete from buffer_combined_availabilities_1208161824
5907 where linkage_instance_id = 4201817
5908
5909 (147.0ms) UPDATE buffer_rule_calc_schedules_1208161824
5910 SET staff_id = 20698
5911 WHERE call_type_id = 12692
5912 AND schedule_on = '2018-05-04'
5913
5914 (149.1ms) INSERT INTO buffer_rule_calc_schedules_1208161824
5915 SET staff_id = 20698,
5916 call_type_id = 12692,
5917 schedule_on = '2018-05-04',
5918 day_of_week_mask = 32
5919
5920 (146.8ms) /* NegativeLinkRule */
5921 UPDATE buffer_negative_relations_1208161824
5922 SET staff_id = 20698
5923 WHERE affected_by_schedule_id = (
5924 SELECT id
5925 FROM buffer_schedules_1208161824
5926 WHERE schedule_on = '2018-05-04'
5927 AND call_type_id = 12692
5928 )
5929
5930 (147.8ms) /* SpecializationOverlapRule */
5931 update buffer_staff_specializations_1208161824 as st_sp
5932 inner join max_applicable_call_types as mact
5933 on st_sp.specialization_id = mact.specialization_id
5934 and mact.call_type_id = 12692
5935 inner join buffer_specialization_daily_counts_1208161824 as sp_dc
5936 on st_sp.specialization_id = sp_dc.specialization_id
5937 and sp_dc.staff_id is null
5938 and sp_dc.schedule_on = '2018-05-04'
5939 left join buffer_specialization_daily_counts_1208161824 as sp_dc_2
5940 on st_sp.specialization_id = sp_dc_2.specialization_id
5941 and st_sp.staff_id = sp_dc_2.staff_id
5942 and sp_dc_2.schedule_on = '2018-05-04'
5943 set sp_dc.staffs_scheduled = sp_dc.staffs_scheduled + 1
5944 where st_sp.staff_id = 20698
5945 and sp_dc_2.id is null
5946
5947 (147.9ms) insert into buffer_specialization_daily_counts_1208161824 (
5948 specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
5949 )
5950 select sp.id as specialization_id,
5951 20698 as staff_id,
5952 '2018-05-04' as schedule_on,
5953 1 as staffs_scheduled,
5954 sp.max_scheduled,
5955 sp_dc.should_be_evaluated
5956 from buffer_staff_specializations_1208161824 as st_sp
5957 inner join specializations as sp
5958 on st_sp.specialization_id = sp.id
5959 inner join max_applicable_call_types as mact
5960 on st_sp.specialization_id = mact.specialization_id
5961 and mact.call_type_id = 12692
5962 inner join buffer_specialization_daily_counts_1208161824 as sp_dc
5963 on st_sp.specialization_id = sp_dc.specialization_id
5964 and sp_dc.staff_id is null
5965 and sp_dc.schedule_on = '2018-05-04'
5966 left join buffer_specialization_daily_counts_1208161824 as sp_dc_2
5967 on st_sp.specialization_id = sp_dc_2.specialization_id
5968 and st_sp.staff_id = sp_dc_2.staff_id
5969 and sp_dc_2.schedule_on = '2018-05-04'
5970 where st_sp.staff_id = 20698
5971 and sp_dc_2.id is null
5972
5973 (151.3ms) /* MaxAssignmentsRule */
5974 delete from buffer_linkage_call_type_assignments_1208161824
5975 where linkage_instance_id = 4201817;
5976
5977 (151.0ms) /* MaxAssignmentsRule */
5978 update
5979 buffer_schedules_1208161824 as sc
5980 inner join call_types as ct
5981 on sc.call_type_id = ct.id
5982 and ct.active = 1
5983 inner join buffer_call_type_assignments_1208161824 as cta
5984 on sc.staff_id = cta.staff_id
5985 and sc.call_type_id = cta.call_type_id
5986 and sc.is_weekend = cta.is_weekend
5987 and sc.period_offset = cta.period_offset
5988 and sc.calendar_schedule_id = cta.calendar_schedule_id
5989 set cta.assignments_count = cta.assignments_count + 1
5990 where
5991 sc.schedule_on = '2018-05-04'
5992 and sc.call_type_id = 12692
5993 and sc.staff_id = 20698
5994
5995 (149.2ms) /* UnassignedDaysRule */
5996 delete from buffer_linkage_assigned_days_1208161824
5997 where linkage_instance_id = 4201817
5998
5999 (149.2ms) /* UnassignedDaysRule */
6000 UPDATE buffer_staff_assigned_days_1208161824 as sad
6001 inner join call_types as ct
6002 on ct.id = 12692
6003 and ct.unassigned_day = 0
6004 SET sad.is_assigned = 1
6005 WHERE sad.staff_id = 20698
6006 AND sad.schedule_on = '2018-05-04'
6007
6008 (149.2ms) /* MonthlyDayOfWeekMixRule, AnnualDayOfWeekMixRule */
6009 delete from buffer_linkage_dow_targets_1208161824
6010 where linkage_instance_id = 4201817
6011
6012 (150.5ms) /* AnnualDayOfWeekMixRule */
6013 update buffer_schedules_1208161824 as sc
6014 inner join buffer_counter_increments_1208161824 as ci
6015 on sc.id = ci.schedule_id
6016 and ci.affects_cumulative_targets = 1
6017 and ci.calls > 0
6018 inner join buffer_cumulative_dow_targets_1208161824 as t
6019 on sc.staff_id = t.staff_id
6020 and (dayofweek(sc.schedule_on) - 1) = t.wday
6021 and sc.calendar_schedule_id = t.calendar_schedule_id
6022 set t.scheduled = t.scheduled + ci.calls
6023 where sc.schedule_on = '2018-05-04'
6024 and sc.call_type_id = 12692
6025 and sc.staff_id = 20698
6026
6027 (148.1ms) /* AssignmentLimitsPerPeriod */
6028 /* Unique Key: assignment_limit_id, staff_id, start_date */
6029 insert into buffer_staff_assignments_count_periods_1208161824 (
6030 assignment_limit_id, staff_id, start_date, end_date, assignments_count
6031 )
6032 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
6033 1 as assignments_count
6034 from buffer_schedules_1208161824 as sc
6035 inner join buffer_assignment_limit_call_types_1208161824 as alct
6036 on sc.call_type_id = alct.call_type_id
6037 inner join assignment_limits as al
6038 on alct.assignment_limit_id = al.id
6039 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
6040 and al.max_per_period_limit is not null
6041 inner join assign_staff_types as ast
6042 on sc.staff_id = ast.staff_id
6043 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
6044 inner join buffer_assignment_limit_staff_types_1208161824 as alst
6045 on alct.assignment_limit_id = alst.assignment_limit_id
6046 and ast.staff_type_id = alst.staff_type_id
6047 inner join (
6048 select assignment_limit_id, start_date, end_date
6049 from buffer_linkage_assignments_count_periods_1208161824
6050 group by assignment_limit_id, start_date, end_date
6051 order by null
6052 ) as lac
6053 on alct.assignment_limit_id = lac.assignment_limit_id
6054 and sc.schedule_on between lac.start_date and lac.end_date
6055 where sc.schedule_on = '2018-05-04'
6056 and sc.call_type_id = 12692
6057 and sc.staff_id = 20698
6058 on duplicate key update
6059 assignments_count = assignments_count + 1
6060
6061 (149.2ms) /* AssignmentLimitsPerWeek */
6062 /* Unique Key: assignment_limit_id, staff_id, start_date */
6063 insert into buffer_staff_assignments_count_weeks_1208161824 (
6064 assignment_limit_id, staff_id, start_date, end_date, assignments_count
6065 )
6066 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
6067 1 as assignments_count
6068 from buffer_schedules_1208161824 as sc
6069 inner join buffer_assignment_limit_call_types_1208161824 as alct
6070 on sc.call_type_id = alct.call_type_id
6071 inner join assignment_limits as al
6072 on alct.assignment_limit_id = al.id
6073 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
6074 and al.max_weekly_limit is not null
6075 inner join assign_staff_types as ast
6076 on sc.staff_id = ast.staff_id
6077 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
6078 inner join buffer_assignment_limit_staff_types_1208161824 as alst
6079 on alct.assignment_limit_id = alst.assignment_limit_id
6080 and ast.staff_type_id = alst.staff_type_id
6081 inner join (
6082 select assignment_limit_id, start_date, end_date
6083 from buffer_linkage_assignments_count_weeks_1208161824
6084 group by assignment_limit_id, start_date, end_date
6085 order by null
6086 ) as lac
6087 on alct.assignment_limit_id = lac.assignment_limit_id
6088 and sc.schedule_on between lac.start_date and lac.end_date
6089 where sc.schedule_on = '2018-05-04'
6090 and sc.call_type_id = 12692
6091 and sc.staff_id = 20698
6092 on duplicate key update
6093 assignments_count = assignments_count + 1
6094
6095 (149.2ms) /* AssignmentLimitsRolling */
6096 /* Unique Key: assignment_limit_id, staff_id, start_date */
6097 insert into buffer_staff_assignments_count_rolling_1208161824 (
6098 assignment_limit_id, staff_id, start_date, end_date, assignments_count
6099 )
6100 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
6101 1 as assignments_count
6102 from buffer_schedules_1208161824 as sc
6103 inner join buffer_assignment_limit_call_types_1208161824 as alct
6104 on sc.call_type_id = alct.call_type_id
6105 inner join assignment_limits as al
6106 on alct.assignment_limit_id = al.id
6107 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
6108 and al.max_rolling_period is not null
6109 and al.max_rolling_limit is not null
6110 inner join assign_staff_types as ast
6111 on sc.staff_id = ast.staff_id
6112 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
6113 inner join buffer_assignment_limit_staff_types_1208161824 as alst
6114 on alct.assignment_limit_id = alst.assignment_limit_id
6115 and ast.staff_type_id = alst.staff_type_id
6116 inner join (
6117 select assignment_limit_id, start_date, end_date
6118 from buffer_linkage_assignments_count_rolling_1208161824
6119 group by assignment_limit_id, start_date, end_date
6120 order by null
6121 ) as lac
6122 on alct.assignment_limit_id = lac.assignment_limit_id
6123 and sc.schedule_on between lac.start_date and lac.end_date
6124 where sc.schedule_on = '2018-05-04'
6125 and sc.call_type_id = 12692
6126 and sc.staff_id = 20698
6127 on duplicate key update
6128 assignments_count = assignments_count + 1
6129
6130 (294.8ms) /* AssignmentLimitsConsecutive */
6131 /* Unique Key: assignment_limit_id, staff_id, schedule_on, start_date */
6132 insert ignore into buffer_staff_assignments_count_consecutive_1208161824 (
6133 assignment_limit_id, staff_id, schedule_on, start_date, end_date
6134 )
6135 select lac.assignment_limit_id, sc.staff_id, sc.schedule_on, lac.start_date, lac.end_date
6136 from buffer_schedules_1208161824 as sc
6137 inner join buffer_assignment_limit_call_types_1208161824 as alct
6138 on sc.call_type_id = alct.call_type_id
6139 inner join assignment_limits as al
6140 on alct.assignment_limit_id = al.id
6141 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
6142 and al.max_consecutive_limit is not null
6143 inner join assign_staff_types as ast
6144 on sc.staff_id = ast.staff_id
6145 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
6146 inner join buffer_assignment_limit_staff_types_1208161824 as alst
6147 on alct.assignment_limit_id = alst.assignment_limit_id
6148 and ast.staff_type_id = alst.staff_type_id
6149 inner join (
6150 select assignment_limit_id, start_date, end_date
6151 from buffer_linkage_assignments_count_consecutive_1208161824
6152 group by assignment_limit_id, start_date, end_date
6153 order by null
6154 ) as lac
6155 on alct.assignment_limit_id = lac.assignment_limit_id
6156 and sc.schedule_on between lac.start_date and lac.end_date
6157 where sc.schedule_on = '2018-05-04'
6158 and sc.call_type_id = 12692
6159 and sc.staff_id = 20698
6160
6161**Airbrake: closed