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