· 8 years ago · Apr 15, 2018, 12:10 AM
1(132.2ms) 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 (134.6ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
3 CalendarSchedule Load (134.1ms) SELECT `calendar_schedules`.* FROM `calendar_schedules` WHERE `calendar_schedules`.`client_id` = 6 AND `calendar_schedules`.`id` = 6 ORDER BY `calendar_schedules`.`position` ASC LIMIT 1
4 CallType Load (132.7ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` IN (46, 47, 48, 49, 51)
5 CalendarSchedule Load (132.5ms) SELECT `calendar_schedules`.* FROM `calendar_schedules` WHERE `calendar_schedules`.`client_id` = 6 AND `calendar_schedules`.`id` = 6 ORDER BY `calendar_schedules`.`position` ASC LIMIT 1
6 Block Load (131.8ms) SELECT `blocks`.* FROM `blocks` INNER JOIN `block_schedules` ON `blocks`.`block_schedule_id` = `block_schedules`.`id` WHERE `block_schedules`.`id` = 6 AND `blocks`.`id` = 17779 ORDER BY start_date asc, end_date asc LIMIT 1
7 BlockSchedule Load (131.8ms) SELECT `block_schedules`.* FROM `block_schedules` WHERE `block_schedules`.`id` = 6 LIMIT 1
8 PopulationTimeframe Load (132.9ms) 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 (131.9ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1530 LIMIT 1
10 Block Load (132.9ms) 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-12-01' AND blocks.end_date <= '2017-12-31') ORDER BY start_date asc, end_date asc
11INFO : (04-06 20:53:01) phase: Scheduler::Base
12INFO : (04-06 20:53:01) from: 2017-12-01 to: 2017-12-31
13 Rule Load (133.3ms) SELECT `rules`.* FROM `rules` WHERE `rules`.`rule_set_id` = 1530 ORDER BY applied desc, weight desc
14INFO : (04-06 20:53:02) rule configurations: TARGET FIXES TESTING 2
15 - 'Cumulative Weekend / Weekday Point Targets' applied {"opt1"=>{"applied"=>"1"}, "opt2"=>{"applied"=>"1"}, "threshold"=>"0"} weight:5
16 - 'Cumulative Assignment Targets' not applied
17 - 'Cumulative Combined Assignment Targets' not applied
18 - 'Cumulative Daily Assignment Targets' not applied
19 - 'Cumulative Day of Week Targets' not applied
20 - 'Cumulative Hour Targets' not applied
21 - 'Cumulative Point Targets' not applied
22 - 'Cumulative Weekend / Weekday Assignment Targets' not applied
23 - 'Cumulative Weekend / Weekday Combined Assignment Targets' not applied
24 - 'Cumulative Weekend / Weekday Hour Targets' not applied
25 - 'Current Assignment Targets' not applied
26 - 'Current Combined Assignment Targets' not applied
27 - 'Current Daily Assignment Targets' not applied
28 - 'Current Day of Week Targets' not applied
29 - 'Current Hour Targets' not applied
30 - 'Current Point Targets' not applied
31 - 'Current Weekend / Weekday Assignment Targets' not applied
32 - 'Current Weekend / Weekday Combined Assignment Targets' not applied
33 - 'Current Weekend / Weekday Hour Targets' not applied
34 - 'Current Weekend / Weekday Point Targets' not applied
35 - 'Pending Call Requests' not applied
36 - 'Pending No-call Requests' not applied
37 - 'Assignments Per Day' not applied
38 - 'Days Between Assignments' not applied
39 - 'Days Between Same Assignment' not applied
40 - 'Unassigned Days' not applied
41 - 'Weeks Between Same Assignment On Same Day Of Week' not applied
42 - 'Weeks Between Same Day Of Week' not applied
43INFO : (04-06 20:53:02) started: Scheduler::Cache::Collector.collect_all
44INFO : (04-06 20:53:02) collect_staffs
45 Staff Load (135.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 (133.7ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6
47 StaffSpecialization Load (131.8ms) 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 (135.0ms) SELECT `specializations`.* FROM `specializations` WHERE `specializations`.`id` = 7 ORDER BY `specializations`.`priority` ASC
49 StaffCallType Load (264.7ms) SELECT `staff_call_types`.* FROM `staff_call_types` WHERE `staff_call_types`.`staff_id` IN (66, 77, 68, 74, 72, 3351, 79, 80, 6913, 81, 65, 18125, 70, 6960, 71, 73, 20694, 75, 18127, 78, 8510)
50INFO : (04-06 20:53:04) initial eligibles: [66,77,68,74,72,3351,79,80,6913,81,65,18125,70,6960,71,73,20694,75,18127,78,8510]
51INFO : (04-06 20:53:04) collect_call_types
52 CallType Load (134.0ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`client_id` = 6 AND `call_types`.`active` = 1 ORDER BY `call_types`.`display_order` ASC
53INFO : (04-06 20:53:04) initial call types: [46,47,48,49,51,2716,397,1343,1344]
54INFO : (04-06 20:53:04) collect_chain_links
55 ChainLink Load (131.7ms) SELECT `chain_links`.* FROM `chain_links` WHERE `chain_links`.`client_id` = 6
56INFO : (04-06 20:53:04) collect_linkages
57INFO : (04-06 20:53:04) collect_schedules
58 Schedule Load (131.4ms) SELECT `schedules`.* FROM `schedules` WHERE `schedules`.`client_id` = 6 AND (`schedules`.`schedule_on` BETWEEN '2017-12-01' AND '2017-12-31')
59INFO : (04-06 20:53:05) collect_slots
60INFO : (04-06 20:53:05) collect_approved_call_requests
61 Request Load (134.0ms) SELECT `requests`.* FROM `requests` INNER JOIN `staffs` ON `staffs`.`id` = `requests`.`staff_id` WHERE `requests`.`client_id` = 6 AND `requests`.`request_type` = 1 AND `requests`.`status` = 1 AND (`requests`.`schedule_on` BETWEEN '2017-12-01' AND '2017-12-31') ORDER BY requests.schedule_on ASC, staffs.request_priority ASC, requests.created_at ASC
62INFO : (04-06 20:53:05) collect_approved_no_call_requests
63 Request Load (132.7ms) SELECT `requests`.* FROM `requests` WHERE `requests`.`client_id` = 6 AND `requests`.`request_type` = 0 AND `requests`.`status` = 1 AND (`requests`.`schedule_on` BETWEEN '2017-12-01' AND '2017-12-31') ORDER BY requests.schedule_on asc, requests.created_at asc
64INFO : (04-06 20:53:05) finished: Scheduler::Cache::Collector.collect_all
65INFO : (04-06 20:53:05) begin to process requests
66 CallType Load (133.1ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`calendar_schedule_id` = 6 AND `call_types`.`active` = 1
67 (138.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 (133.7ms) SELECT distinct requests.* FROM `requests` INNER JOIN `request_call_types` ON `request_call_types`.`request_id` = `requests`.`id` WHERE `requests`.`client_id` = 6 AND `requests`.`status` = 1 AND `requests`.`request_type` = 1 AND `request_call_types`.`call_type_id` IN (46, 47, 48, 49, 51, 397, 1343, 1344, 2716) AND (requests.schedule_on > '2017-09-30')
69 SQL (149.9ms) UPDATE `schedules` SET `schedules`.`populate_method` = 'auto_approved_request', `schedules`.`creator_id` = 166 WHERE `schedules`.`client_id` = 6 AND 1=0
70INFO : (04-06 20:53:06) end of requests processing
71 Block Load (132.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-12-31' AND blocks.end_date >= '2017-12-31') ORDER BY start_date asc, end_date asc LIMIT 1
72 Client Load (135.2ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
73 NegativeLink Load (131.8ms) SELECT `negative_links`.* FROM `negative_links` WHERE `negative_links`.`client_id` = 6
74INFO : (04-06 20:53:07) <-- clear: 0 - Scheduler::AutoPopulate::Queries::CreateTables
75INFO : (04-06 20:53:07) <-- clear: 1 - Scheduler::AutoPopulate::Queries::AutoPopulateSlots
76INFO : (04-06 20:53:07) <-- clear: 2 - Scheduler::AutoPopulate::Queries::Query003
77INFO : (04-06 20:53:07) <-- clear: 3 - Scheduler::AutoPopulate::Queries::Query005
78INFO : (04-06 20:53:07) <-- clear: 4 - Scheduler::AutoPopulate::Queries::Query01
79INFO : (04-06 20:53:07) <-- clear: 5 - Scheduler::AutoPopulate::Queries::Query012
80INFO : (04-06 20:53:07) <-- clear: 6 - Scheduler::AutoPopulate::Queries::QueryTargets
81INFO : (04-06 20:53:07) <-- clear: 7 - Scheduler::AutoPopulate::Queries::Query013
82INFO : (04-06 20:53:07) <-- clear: 8 - Scheduler::AutoPopulate::Queries::Query014
83INFO : (04-06 20:53:07) <-- clear: 9 - Scheduler::AutoPopulate::Queries::Query015
84INFO : (04-06 20:53:07) <-- clear: 10 - Scheduler::AutoPopulate::Queries::Query02
85INFO : (04-06 20:53:07) <-- clear: 11 - Scheduler::AutoPopulate::Queries::Query03
86INFO : (04-06 20:53:07) <-- clear: 12 - Scheduler::AutoPopulate::Queries::Query04
87INFO : (04-06 20:53:07) <-- clear: 13 - Scheduler::AutoPopulate::Queries::Query045
88INFO : (04-06 20:53:07) <-- clear: 14 - Scheduler::AutoPopulate::Queries::QueryA
89INFO : (04-06 20:53:07) <-- clear: 15 - Scheduler::AutoPopulate::Queries::QueryB
90INFO : (04-06 20:53:07) <-- clear: 16 - Scheduler::AutoPopulate::Queries::Query05
91INFO : (04-06 20:53:07) <-- clear: 17 - Scheduler::AutoPopulate::Queries::Query06
92INFO : (04-06 20:53:07) <-- clear: 18 - Scheduler::AutoPopulate::Queries::Query07
93INFO : (04-06 20:53:07) <-- clear: 19 - Scheduler::AutoPopulate::Queries::Query0702
94INFO : (04-06 20:53:07) <-- clear: 20 - Scheduler::AutoPopulate::Queries::Query0705
95INFO : (04-06 20:53:07) <-- clear: 21 - Scheduler::AutoPopulate::Queries::Query0706
96INFO : (04-06 20:53:07) <-- clear: 22 - Scheduler::AutoPopulate::Queries::Query0707
97INFO : (04-06 20:53:07) <-- clear: 23 - Scheduler::AutoPopulate::Queries::Query0708
98INFO : (04-06 20:53:07) <-- clear: 24 - Scheduler::AutoPopulate::Queries::Query0709
99INFO : (04-06 20:53:07) <-- clear: 25 - Scheduler::AutoPopulate::Queries::Query07_10_AL
100INFO : (04-06 20:53:07) <-- clear: 26 - Scheduler::AutoPopulate::Queries::Query07_10_AL_01
101INFO : (04-06 20:53:07) <-- clear: 27 - Scheduler::AutoPopulate::Queries::Query07_10_AL_02
102INFO : (04-06 20:53:07) <-- clear: 28 - Scheduler::AutoPopulate::Queries::Query07_10_AL_03
103INFO : (04-06 20:53:07) <-- clear: 29 - Scheduler::AutoPopulate::Queries::Query07_10_AL_04
104INFO : (04-06 20:53:07) <-- clear: 30 - Scheduler::AutoPopulate::Queries::Query08
105INFO : (04-06 20:53:07) <-- clear: 31 - Scheduler::AutoPopulate::Queries::Query085
106INFO : (04-06 20:53:07) <-- clear: 32 - Scheduler::AutoPopulate::Queries::Query09
107INFO : (04-06 20:53:07) <-- clear: 33 - Scheduler::AutoPopulate::Queries::Query092
108INFO : (04-06 20:53:07) <-- clear: 34 - Scheduler::AutoPopulate::Queries::Query093
109INFO : (04-06 20:53:07) <-- clear: 35 - Scheduler::AutoPopulate::Queries::Query095
110INFO : (04-06 20:53:07) <-- clear: 36 - Scheduler::AutoPopulate::Queries::Query097
111INFO : (04-06 20:53:07) <-- clear: 37 - Scheduler::AutoPopulate::Queries::Query098
112INFO : (04-06 20:53:07) <-- clear: 38 - Scheduler::AutoPopulate::Queries::Query09_09_AL_01
113INFO : (04-06 20:53:07) <-- clear: 39 - Scheduler::AutoPopulate::Queries::Query09_09_AL_02
114INFO : (04-06 20:53:07) <-- clear: 40 - Scheduler::AutoPopulate::Queries::Query09_09_AL_03
115INFO : (04-06 20:53:07) <-- clear: 41 - Scheduler::AutoPopulate::Queries::Query09_09_AL_04
116INFO : (04-06 20:53:07) <-- clear: 42 - Scheduler::AutoPopulate::Queries::Query09_12_Points
117INFO : (04-06 20:53:07) <-- clear: 43 - Scheduler::AutoPopulate::Queries::Query09_12_Hours
118INFO : (04-06 20:53:07) <-- clear: 44 - Scheduler::AutoPopulate::Queries::Query10
119INFO : (04-06 20:53:07) <-- clear: 45 - Scheduler::AutoPopulate::Queries::QueryScore02
120INFO : (04-06 20:53:07) <-- clear: 46 - Scheduler::AutoPopulate::Queries::QueryScore03
121INFO : (04-06 20:53:07) <-- clear: 47 - Scheduler::AutoPopulate::Queries::QueryScore04
122INFO : (04-06 20:53:07) <-- clear: 48 - Scheduler::AutoPopulate::Queries::Query11
123INFO : (04-06 20:53:07) <-- clear: 49 - Scheduler::AutoPopulate::Queries::DropTables
124 (133.0ms) DROP TABLE IF EXISTS buffer_annual_hour_targets_1458117728
125 (132.9ms) DROP TABLE IF EXISTS buffer_annual_point_targets_1458117728
126 (133.0ms) DROP TABLE IF EXISTS buffer_annual_targets_staff_totals_1458117728
127 (133.4ms) DROP TABLE IF EXISTS buffer_auto_populate_slots_1458117728
128 (133.0ms) DROP TABLE IF EXISTS buffer_call_days_targets_1458117728
129 (133.2ms) DROP TABLE IF EXISTS buffer_call_type_targets_1458117728
130 (133.2ms) DROP TABLE IF EXISTS buffer_cumulative_cd_targets_1458117728
131 (133.2ms) DROP TABLE IF EXISTS buffer_cumulative_ct_targets_1458117728
132 (134.3ms) DROP TABLE IF EXISTS buffer_cumulative_dow_targets_1458117728
133 (133.1ms) DROP TABLE IF EXISTS buffer_cumulative_hour_targets_1458117728
134 (133.1ms) DROP TABLE IF EXISTS buffer_cumulative_oa_targets_1458117728
135 (134.6ms) DROP TABLE IF EXISTS buffer_cumulative_point_targets_1458117728
136 (133.6ms) DROP TABLE IF EXISTS buffer_current_cd_targets_1458117728
137 (133.5ms) DROP TABLE IF EXISTS buffer_current_ct_targets_1458117728
138 (133.0ms) DROP TABLE IF EXISTS buffer_current_dow_targets_1458117728
139 (133.1ms) DROP TABLE IF EXISTS buffer_current_hour_targets_1458117728
140 (132.8ms) DROP TABLE IF EXISTS buffer_current_oa_targets_1458117728
141 (133.1ms) DROP TABLE IF EXISTS buffer_current_point_targets_1458117728
142 (133.3ms) DROP TABLE IF EXISTS buffer_day_of_week_targets_1458117728
143 (133.7ms) DROP TABLE IF EXISTS buffer_hour_targets_1458117728
144 (133.3ms) DROP TABLE IF EXISTS buffer_linkage_call_days_targets_1458117728
145 (132.9ms) DROP TABLE IF EXISTS buffer_linkage_call_type_targets_1458117728
146 (134.4ms) DROP TABLE IF EXISTS buffer_linkage_targets_1458117728
147 (133.0ms) DROP TABLE IF EXISTS buffer_linkage_hour_targets_1458117728
148 (133.5ms) DROP TABLE IF EXISTS buffer_linkage_point_targets_1458117728
149 (133.5ms) DROP TABLE IF EXISTS buffer_location_privileges_1458117728
150 (133.9ms) DROP TABLE IF EXISTS buffer_periods_1458117728
151 (133.3ms) DROP TABLE IF EXISTS buffer_point_targets_1458117728
152 (133.5ms) DROP TABLE IF EXISTS buffer_schedules_1458117728
153 (132.9ms) DROP TABLE IF EXISTS buffer_target_call_types_1458117728
154 (133.6ms) DROP TABLE IF EXISTS buffer_target_daily_points_1458117728
155 (133.1ms) DROP TABLE IF EXISTS buffer_target_dates_list_1458117728
156 (133.8ms) DROP TABLE IF EXISTS buffer_target_primary_availabilities_1458117728
157 (133.5ms) DROP TABLE IF EXISTS buffer_targets_1458117728
158 (133.2ms) DROP TABLE IF EXISTS buffer_tmp_targets_availabilities_1458117728
159 (134.0ms) DROP TABLE IF EXISTS buffer_tmp_targets_availabilities_exclusions_1458117728
160 (133.2ms) DROP TABLE IF EXISTS buffer_tmp_targets_client_totals_1458117728
161 (132.7ms) DROP TABLE IF EXISTS buffer_tmp_targets_scheduled_1458117728
162 (137.2ms) DROP TABLE IF EXISTS buffer_tmp_targets_staff_totals_1458117728
163 (133.3ms) DROP TABLE IF EXISTS buffer_assignment_limit_call_types_1458117728
164 (133.6ms) DROP TABLE IF EXISTS buffer_assignment_limit_periods_1458117728
165 (133.3ms) DROP TABLE IF EXISTS buffer_assignment_limit_staff_types_1458117728
166 (132.9ms) DROP TABLE IF EXISTS buffer_auto_populate_slots_1458117728
167 (133.4ms) DROP TABLE IF EXISTS buffer_call_type_assignments_1458117728
168 (133.1ms) DROP TABLE IF EXISTS buffer_combined_availabilities_1458117728
169 (133.3ms) DROP TABLE IF EXISTS buffer_combined_availability_linkages_1458117728
170 (132.9ms) DROP TABLE IF EXISTS buffer_counter_increments_1458117728
171 (133.5ms) DROP TABLE IF EXISTS buffer_linkage_assigned_days_1458117728
172 (133.2ms) DROP TABLE IF EXISTS buffer_linkage_assignments_count_consecutive_1458117728
173 (149.5ms) DROP TABLE IF EXISTS buffer_linkage_assignments_count_periods_1458117728
174 (133.0ms) DROP TABLE IF EXISTS buffer_linkage_assignments_count_rolling_1458117728
175 (133.6ms) DROP TABLE IF EXISTS buffer_linkage_assignments_count_weeks_1458117728
176 (132.9ms) DROP TABLE IF EXISTS buffer_linkage_call_type_assignments_1458117728
177 (133.4ms) DROP TABLE IF EXISTS buffer_linkage_dow_targets_1458117728
178 (133.2ms) DROP TABLE IF EXISTS buffer_linkage_patterns_1458117728
179 (133.3ms) DROP TABLE IF EXISTS buffer_linkages_1458117728
180 (133.5ms) DROP TABLE IF EXISTS buffer_location_privileges_1458117728
181 (133.1ms) DROP TABLE IF EXISTS buffer_min_distances_1458117728
182 (132.8ms) DROP TABLE IF EXISTS buffer_negative_relations_1458117728
183 (132.9ms) DROP TABLE IF EXISTS buffer_rule_calc_filters_1458117728
184 (133.3ms) DROP TABLE IF EXISTS buffer_rule_calc_schedules_1458117728
185 (133.2ms) DROP TABLE IF EXISTS buffer_rule_scores_1458117728
186 (139.2ms) DROP TABLE IF EXISTS buffer_rule_scores_with_corrections_1458117728
187 (133.5ms) DROP TABLE IF EXISTS buffer_schedule_linkages_1458117728
188 (133.4ms) DROP TABLE IF EXISTS buffer_schedules_linkage_patterns_1458117728
189 (133.0ms) DROP TABLE IF EXISTS buffer_specialization_daily_counts_1458117728
190 (133.4ms) DROP TABLE IF EXISTS buffer_staff_assigned_days_1458117728
191 (133.1ms) DROP TABLE IF EXISTS buffer_staff_assignments_count_periods_1458117728
192 (132.7ms) DROP TABLE IF EXISTS buffer_staff_assignments_count_rolling_1458117728
193 (132.9ms) DROP TABLE IF EXISTS buffer_staff_assignments_count_weeks_1458117728
194 (132.8ms) DROP TABLE IF EXISTS buffer_staff_assignments_count_consecutive_1458117728
195 (133.5ms) DROP TABLE IF EXISTS buffer_staff_daily_counts_1458117728
196 (134.9ms) DROP TABLE IF EXISTS buffer_staff_specializations_1458117728
197 (132.9ms) DROP TABLE IF EXISTS buffer_static_availabilities_1458117728
198 (133.0ms) DROP TABLE IF EXISTS buffer_target_assignments_1458117728
199 (131.0ms) delete from buffer_target_dates
200 where session_id = 1458117728
201 and client_id = 6
202
203INFO : (04-06 20:53:17) --> fill: 0 - Scheduler::AutoPopulate::Queries::CreateTables
204 (136.2ms) CREATE TABLE IF NOT EXISTS buffer_assignment_limit_call_types_1458117728 LIKE buffer_assignment_limit_call_types
205 (135.9ms) CREATE TABLE IF NOT EXISTS buffer_assignment_limit_periods_1458117728 LIKE buffer_assignment_limit_periods
206 (137.3ms) CREATE TABLE IF NOT EXISTS buffer_assignment_limit_staff_types_1458117728 LIKE buffer_assignment_limit_staff_types
207 (136.3ms) CREATE TABLE IF NOT EXISTS buffer_auto_populate_slots_1458117728 LIKE buffer_auto_populate_slots
208 (136.4ms) CREATE TABLE IF NOT EXISTS buffer_call_type_assignments_1458117728 LIKE buffer_call_type_assignments
209 (144.2ms) CREATE TABLE IF NOT EXISTS buffer_combined_availabilities_1458117728 LIKE buffer_combined_availabilities
210 (136.2ms) CREATE TABLE IF NOT EXISTS buffer_combined_availability_linkages_1458117728 LIKE buffer_combined_availability_linkages
211 (135.3ms) CREATE TABLE IF NOT EXISTS buffer_counter_increments_1458117728 LIKE buffer_counter_increments
212 (135.5ms) CREATE TABLE IF NOT EXISTS buffer_linkage_assigned_days_1458117728 LIKE buffer_linkage_assigned_days
213 (135.9ms) CREATE TABLE IF NOT EXISTS buffer_linkage_assignments_count_consecutive_1458117728 LIKE buffer_linkage_assignments_count_consecutive
214 (135.8ms) CREATE TABLE IF NOT EXISTS buffer_linkage_assignments_count_periods_1458117728 LIKE buffer_linkage_assignments_count_periods
215 (135.9ms) CREATE TABLE IF NOT EXISTS buffer_linkage_assignments_count_rolling_1458117728 LIKE buffer_linkage_assignments_count_rolling
216 (135.4ms) CREATE TABLE IF NOT EXISTS buffer_linkage_assignments_count_weeks_1458117728 LIKE buffer_linkage_assignments_count_weeks
217 (135.7ms) CREATE TABLE IF NOT EXISTS buffer_linkage_call_type_assignments_1458117728 LIKE buffer_linkage_call_type_assignments
218 (137.1ms) CREATE TABLE IF NOT EXISTS buffer_linkage_dow_targets_1458117728 LIKE buffer_linkage_dow_targets
219 (136.6ms) CREATE TABLE IF NOT EXISTS buffer_linkage_patterns_1458117728 LIKE buffer_linkage_patterns
220 (135.8ms) CREATE TABLE IF NOT EXISTS buffer_linkages_1458117728 LIKE buffer_linkages
221 (136.0ms) CREATE TABLE IF NOT EXISTS buffer_location_privileges_1458117728 LIKE buffer_location_privileges
222 (136.7ms) CREATE TABLE IF NOT EXISTS buffer_min_distances_1458117728 LIKE buffer_min_distances
223 (231.4ms) CREATE TABLE IF NOT EXISTS buffer_negative_relations_1458117728 LIKE buffer_negative_relations
224 (136.2ms) CREATE TABLE IF NOT EXISTS buffer_rule_calc_filters_1458117728 LIKE buffer_rule_calc_filters
225 (136.4ms) CREATE TABLE IF NOT EXISTS buffer_rule_calc_schedules_1458117728 LIKE buffer_rule_calc_schedules
226 (136.5ms) CREATE TABLE IF NOT EXISTS buffer_rule_scores_1458117728 LIKE buffer_rule_scores
227 (136.8ms) CREATE TABLE IF NOT EXISTS buffer_rule_scores_with_corrections_1458117728 LIKE buffer_rule_scores_with_corrections
228 (136.9ms) CREATE TABLE IF NOT EXISTS buffer_schedule_linkages_1458117728 LIKE buffer_schedule_linkages
229 (136.3ms) CREATE TABLE IF NOT EXISTS buffer_schedules_linkage_patterns_1458117728 LIKE buffer_schedules_linkage_patterns
230 (136.0ms) CREATE TABLE IF NOT EXISTS buffer_specialization_daily_counts_1458117728 LIKE buffer_specialization_daily_counts
231 (136.5ms) CREATE TABLE IF NOT EXISTS buffer_staff_assigned_days_1458117728 LIKE buffer_staff_assigned_days
232 (136.0ms) CREATE TABLE IF NOT EXISTS buffer_staff_assignments_count_periods_1458117728 LIKE buffer_staff_assignments_count_periods
233 (136.2ms) CREATE TABLE IF NOT EXISTS buffer_staff_assignments_count_rolling_1458117728 LIKE buffer_staff_assignments_count_rolling
234 (135.8ms) CREATE TABLE IF NOT EXISTS buffer_staff_assignments_count_weeks_1458117728 LIKE buffer_staff_assignments_count_weeks
235 (136.2ms) CREATE TABLE IF NOT EXISTS buffer_staff_assignments_count_consecutive_1458117728 LIKE buffer_staff_assignments_count_consecutive
236 (136.1ms) CREATE TABLE IF NOT EXISTS buffer_staff_daily_counts_1458117728 LIKE buffer_staff_daily_counts
237 (136.4ms) CREATE TABLE IF NOT EXISTS buffer_staff_specializations_1458117728 LIKE buffer_staff_specializations
238 (137.1ms) CREATE TABLE IF NOT EXISTS buffer_static_availabilities_1458117728 LIKE buffer_static_availabilities
239 (149.2ms) CREATE TABLE IF NOT EXISTS buffer_target_assignments_1458117728 LIKE buffer_target_assignments
240 (136.3ms) CREATE TABLE IF NOT EXISTS buffer_annual_hour_targets_1458117728 LIKE buffer_annual_hour_targets
241 (143.6ms) CREATE TABLE IF NOT EXISTS buffer_annual_point_targets_1458117728 LIKE buffer_annual_point_targets
242 (137.0ms) CREATE TABLE IF NOT EXISTS buffer_annual_targets_staff_totals_1458117728 LIKE buffer_annual_targets_staff_totals
243 (133.3ms) CREATE TABLE IF NOT EXISTS buffer_auto_populate_slots_1458117728 LIKE buffer_auto_populate_slots
244 (136.3ms) CREATE TABLE IF NOT EXISTS buffer_call_days_targets_1458117728 LIKE buffer_call_days_targets
245 (136.0ms) CREATE TABLE IF NOT EXISTS buffer_call_type_targets_1458117728 LIKE buffer_call_type_targets
246 (136.7ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_cd_targets_1458117728 LIKE buffer_cumulative_cd_targets
247 (140.0ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_ct_targets_1458117728 LIKE buffer_cumulative_ct_targets
248 (135.8ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_dow_targets_1458117728 LIKE buffer_cumulative_dow_targets
249 (136.0ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_hour_targets_1458117728 LIKE buffer_cumulative_hour_targets
250 (136.5ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_oa_targets_1458117728 LIKE buffer_cumulative_oa_targets
251 (136.1ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_point_targets_1458117728 LIKE buffer_cumulative_point_targets
252 (135.4ms) CREATE TABLE IF NOT EXISTS buffer_current_cd_targets_1458117728 LIKE buffer_current_cd_targets
253 (137.0ms) CREATE TABLE IF NOT EXISTS buffer_current_ct_targets_1458117728 LIKE buffer_current_ct_targets
254 (136.1ms) CREATE TABLE IF NOT EXISTS buffer_current_dow_targets_1458117728 LIKE buffer_current_dow_targets
255 (144.0ms) CREATE TABLE IF NOT EXISTS buffer_current_hour_targets_1458117728 LIKE buffer_current_hour_targets
256 (136.5ms) CREATE TABLE IF NOT EXISTS buffer_current_oa_targets_1458117728 LIKE buffer_current_oa_targets
257 (136.4ms) CREATE TABLE IF NOT EXISTS buffer_current_point_targets_1458117728 LIKE buffer_current_point_targets
258 (139.3ms) CREATE TABLE IF NOT EXISTS buffer_day_of_week_targets_1458117728 LIKE buffer_day_of_week_targets
259 (136.7ms) CREATE TABLE IF NOT EXISTS buffer_hour_targets_1458117728 LIKE buffer_hour_targets
260 (135.9ms) CREATE TABLE IF NOT EXISTS buffer_linkage_call_days_targets_1458117728 LIKE buffer_linkage_call_days_targets
261 (136.2ms) CREATE TABLE IF NOT EXISTS buffer_linkage_call_type_targets_1458117728 LIKE buffer_linkage_call_type_targets
262 (137.6ms) CREATE TABLE IF NOT EXISTS buffer_linkage_targets_1458117728 LIKE buffer_linkage_targets
263 (144.3ms) CREATE TABLE IF NOT EXISTS buffer_linkage_hour_targets_1458117728 LIKE buffer_linkage_hour_targets
264 (136.5ms) CREATE TABLE IF NOT EXISTS buffer_linkage_point_targets_1458117728 LIKE buffer_linkage_point_targets
265 (133.5ms) CREATE TABLE IF NOT EXISTS buffer_location_privileges_1458117728 LIKE buffer_location_privileges
266 (136.3ms) CREATE TABLE IF NOT EXISTS buffer_periods_1458117728 LIKE buffer_periods
267 (135.8ms) CREATE TABLE IF NOT EXISTS buffer_point_targets_1458117728 LIKE buffer_point_targets
268 (136.0ms) CREATE TABLE IF NOT EXISTS buffer_schedules_1458117728 LIKE buffer_schedules
269 (135.9ms) CREATE TABLE IF NOT EXISTS buffer_target_call_types_1458117728 LIKE buffer_target_call_types
270 (135.9ms) CREATE TABLE IF NOT EXISTS buffer_target_daily_points_1458117728 LIKE buffer_target_daily_points
271 (135.9ms) CREATE TABLE IF NOT EXISTS buffer_target_dates_list_1458117728 LIKE buffer_target_dates_list
272 (135.8ms) CREATE TABLE IF NOT EXISTS buffer_target_primary_availabilities_1458117728 LIKE buffer_target_primary_availabilities
273 (145.0ms) CREATE TABLE IF NOT EXISTS buffer_targets_1458117728 LIKE buffer_targets
274 (136.6ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_availabilities_1458117728 LIKE buffer_tmp_targets_availabilities
275 (135.6ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_availabilities_exclusions_1458117728 LIKE buffer_tmp_targets_availabilities_exclusions
276 (136.8ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_client_totals_1458117728 LIKE buffer_tmp_targets_client_totals
277 (143.3ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_scheduled_1458117728 LIKE buffer_tmp_targets_scheduled
278 (136.0ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_staff_totals_1458117728 LIKE buffer_tmp_targets_staff_totals
279INFO : (04-06 20:53:28) --> fill: 1 - Scheduler::AutoPopulate::Queries::AutoPopulateSlots
280 (133.3ms) 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-12-01' AND '2017-12-31'
295
296 AutopopulateExclusion Load (131.7ms) SELECT `autopopulate_exclusions`.* FROM `autopopulate_exclusions` WHERE `autopopulate_exclusions`.`client_id` = 6 AND `autopopulate_exclusions`.`schedule_on` IN ('2017-12-01', '2017-12-02', '2017-12-03', '2017-12-04', '2017-12-05', '2017-12-06', '2017-12-07', '2017-12-08', '2017-12-09', '2017-12-10', '2017-12-11', '2017-12-12', '2017-12-13', '2017-12-14', '2017-12-15', '2017-12-16', '2017-12-17', '2017-12-18', '2017-12-19', '2017-12-20', '2017-12-21', '2017-12-22', '2017-12-23', '2017-12-24', '2017-12-25', '2017-12-26', '2017-12-27', '2017-12-28', '2017-12-29', '2017-12-30', '2017-12-31')
297 (136.1ms) INSERT INTO buffer_auto_populate_slots_1458117728
298 (schedule_on, day_of_week_mask, call_type_id, display_order, should_be_populated)
299 VALUES ('2017-12-01', '32', '46', '0', 1), ('2017-12-01', '32', '47', '2', 1), ('2017-12-01', '32', '48', '3', 1), ('2017-12-01', '32', '49', '4', 1), ('2017-12-01', '32', '51', '7', 1), ('2017-12-02', '64', '46', '0', 1), ('2017-12-02', '64', '48', '3', 1), ('2017-12-03', '1', '46', '0', 1), ('2017-12-03', '1', '48', '3', 1), ('2017-12-04', '2', '46', '0', 1), ('2017-12-04', '2', '47', '2', 1), ('2017-12-04', '2', '48', '3', 1), ('2017-12-04', '2', '49', '4', 1), ('2017-12-04', '2', '51', '7', 1), ('2017-12-05', '4', '46', '0', 1), ('2017-12-05', '4', '47', '2', 1), ('2017-12-05', '4', '48', '3', 1), ('2017-12-05', '4', '49', '4', 1), ('2017-12-05', '4', '51', '7', 1), ('2017-12-06', '8', '46', '0', 1), ('2017-12-06', '8', '47', '2', 1), ('2017-12-06', '8', '48', '3', 1), ('2017-12-06', '8', '49', '4', 1), ('2017-12-06', '8', '51', '7', 1), ('2017-12-07', '16', '46', '0', 1), ('2017-12-07', '16', '47', '2', 1), ('2017-12-07', '16', '48', '3', 1), ('2017-12-07', '16', '49', '4', 1), ('2017-12-07', '16', '51', '7', 1), ('2017-12-08', '32', '46', '0', 1), ('2017-12-08', '32', '47', '2', 1), ('2017-12-08', '32', '48', '3', 1), ('2017-12-08', '32', '49', '4', 1), ('2017-12-08', '32', '51', '7', 1), ('2017-12-09', '64', '46', '0', 1), ('2017-12-09', '64', '48', '3', 1), ('2017-12-10', '1', '46', '0', 1), ('2017-12-10', '1', '48', '3', 1), ('2017-12-11', '2', '46', '0', 1), ('2017-12-11', '2', '47', '2', 1), ('2017-12-11', '2', '48', '3', 1), ('2017-12-11', '2', '49', '4', 1), ('2017-12-11', '2', '51', '7', 1), ('2017-12-12', '4', '46', '0', 1), ('2017-12-12', '4', '47', '2', 1), ('2017-12-12', '4', '48', '3', 1), ('2017-12-12', '4', '49', '4', 1), ('2017-12-12', '4', '51', '7', 1), ('2017-12-13', '8', '46', '0', 1), ('2017-12-13', '8', '47', '2', 1), ('2017-12-13', '8', '48', '3', 1), ('2017-12-13', '8', '49', '4', 1), ('2017-12-13', '8', '51', '7', 1), ('2017-12-14', '16', '46', '0', 1), ('2017-12-14', '16', '47', '2', 1), ('2017-12-14', '16', '48', '3', 1), ('2017-12-14', '16', '49', '4', 1), ('2017-12-14', '16', '51', '7', 1), ('2017-12-15', '32', '46', '0', 1), ('2017-12-15', '32', '47', '2', 1), ('2017-12-15', '32', '48', '3', 1), ('2017-12-15', '32', '49', '4', 1), ('2017-12-15', '32', '51', '7', 1), ('2017-12-16', '64', '46', '0', 1), ('2017-12-16', '64', '48', '3', 1), ('2017-12-17', '1', '46', '0', 1), ('2017-12-17', '1', '48', '3', 1), ('2017-12-18', '2', '46', '0', 1), ('2017-12-18', '2', '47', '2', 1), ('2017-12-18', '2', '48', '3', 1), ('2017-12-18', '2', '49', '4', 1), ('2017-12-18', '2', '51', '7', 1), ('2017-12-19', '4', '46', '0', 1), ('2017-12-19', '4', '47', '2', 1), ('2017-12-19', '4', '48', '3', 1), ('2017-12-19', '4', '49', '4', 1), ('2017-12-19', '4', '51', '7', 1), ('2017-12-20', '8', '46', '0', 1), ('2017-12-20', '8', '47', '2', 1), ('2017-12-20', '8', '48', '3', 1), ('2017-12-20', '8', '49', '4', 1), ('2017-12-20', '8', '51', '7', 1), ('2017-12-21', '16', '46', '0', 1), ('2017-12-21', '16', '47', '2', 1), ('2017-12-21', '16', '48', '3', 1), ('2017-12-21', '16', '49', '4', 1), ('2017-12-21', '16', '51', '7', 1), ('2017-12-22', '32', '46', '0', 1), ('2017-12-22', '32', '47', '2', 1), ('2017-12-22', '32', '48', '3', 1), ('2017-12-22', '32', '49', '4', 1), ('2017-12-22', '32', '51', '7', 1), ('2017-12-23', '64', '46', '0', 1), ('2017-12-23', '64', '48', '3', 1), ('2017-12-24', '1', '46', '0', 1), ('2017-12-24', '1', '48', '3', 1), ('2017-12-25', '2', '46', '0', 1), ('2017-12-25', '2', '47', '2', 1), ('2017-12-25', '2', '48', '3', 1), ('2017-12-25', '2', '49', '4', 1), ('2017-12-25', '2', '51', '7', 1), ('2017-12-26', '4', '46', '0', 1), ('2017-12-26', '4', '47', '2', 1), ('2017-12-26', '4', '48', '3', 1), ('2017-12-26', '4', '49', '4', 1), ('2017-12-26', '4', '51', '7', 1), ('2017-12-27', '8', '46', '0', 1), ('2017-12-27', '8', '47', '2', 1), ('2017-12-27', '8', '48', '3', 1), ('2017-12-27', '8', '49', '4', 1), ('2017-12-27', '8', '51', '7', 1), ('2017-12-28', '16', '46', '0', 1), ('2017-12-28', '16', '47', '2', 1), ('2017-12-28', '16', '48', '3', 1), ('2017-12-28', '16', '49', '4', 1), ('2017-12-28', '16', '51', '7', 1), ('2017-12-29', '32', '46', '0', 1), ('2017-12-29', '32', '47', '2', 1), ('2017-12-29', '32', '48', '3', 1), ('2017-12-29', '32', '49', '4', 1), ('2017-12-29', '32', '51', '7', 1), ('2017-12-30', '64', '46', '0', 1), ('2017-12-30', '64', '48', '3', 1), ('2017-12-31', '1', '46', '0', 1), ('2017-12-31', '1', '48', '3', 1)
300
301INFO : (04-06 20:53:28) --> fill: 2 - Scheduler::AutoPopulate::Queries::Query003
302 (135.0ms) insert into buffer_auto_populate_slots_1458117728/* 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_1458117728/* 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_1458117728/* client_id */ as auto_populate_slots_2
332 on date_add(
333 auto_populate_slots.schedule_on,
334 interval soft_linkages.offset day
335 ) = auto_populate_slots_2.schedule_on
336 and soft_linkages.linked_call_type_id = auto_populate_slots_2.call_type_id
337 inner join call_types
338 on soft_linkages.linked_call_type_id = call_types.id
339 where auto_populate_slots_2.id is null
340 order by null
341
342INFO : (04-06 20:53:28) --> fill: 3 - Scheduler::AutoPopulate::Queries::Query005
343 (158.8ms) insert into buffer_auto_populate_slots_1458117728 (
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_1458117728 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_1458117728 as auto_populate_slots_2
373 on date_add(
374 auto_populate_slots.schedule_on,
375 interval linkage_relations.distance_in_days day
376 ) = auto_populate_slots_2.schedule_on
377 and linkage_relations.linked_call_type_id = auto_populate_slots_2.call_type_id
378 inner join call_types
379 on linkage_relations.linked_call_type_id = call_types.id
380 where auto_populate_slots_2.id is null
381 order by null
382
383INFO : (04-06 20:53:28) --> fill: 4 - Scheduler::AutoPopulate::Queries::Query01
384 (166.3ms) 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_1458117728/* 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 (148.8ms) insert into buffer_schedules_1458117728 (
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_1458117728 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_1458117728 as auto_populate_slots_2
494 on date_add(
495 auto_populate_slots.schedule_on,
496 interval linkage_relations.distance_in_days day
497 ) = auto_populate_slots_2.schedule_on
498 and linkage_relations.linked_call_type_id = auto_populate_slots_2.call_type_id
499 left join schedules
500 on auto_populate_slots_2.call_type_id = schedules.call_type_id
501 and auto_populate_slots_2.schedule_on = schedules.schedule_on
502 order by null
503 ) as t1
504 group by
505 call_type_id,
506 staff_id,
507 schedule_on,
508 day_of_week_mask,
509 display_order,
510 week_number
511 order by null
512
513INFO : (04-06 20:53:29) --> fill: 5 - Scheduler::AutoPopulate::Queries::Query012
514 (165.4ms) update
515 buffer_schedules_1458117728 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 (131.4ms) SELECT `block_schedules`.* FROM `block_schedules` WHERE `block_schedules`.`id` = 6 LIMIT 1
528 (137.1ms) insert into buffer_periods_1458117728 (
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_1458117728 as sc
569 inner join buffer_auto_populate_slots_1458117728 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 (139.6ms) update
618 buffer_schedules_1458117728 as sc
619 inner join buffer_periods_1458117728 as p
620 on sc.calendar_schedule_id = p.calendar_schedule_id
621 and sc.schedule_on between p.start_date and p.end_date
622 set sc.period_offset = p.period_offset
623
624INFO : (04-06 20:53:29) --> fill: 6 - Scheduler::AutoPopulate::Queries::QueryTargets
625 (131.6ms) delete from buffer_target_dates
626 where session_id = 1458117728
627
628 (132.0ms) select distinct calendar_schedule_id
629 from buffer_periods_1458117728
630
631 (261.2ms) 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 1458117728 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 FALSE
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 FALSE
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 FALSE
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 FALSE
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.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 FALSE
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_1458117728
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_1458117728 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 - 527.033ms
1028 (132.1ms) select
1029 max(build_cd_targets) as build_cd_targets,
1030 max(build_ct_targets) as build_ct_targets,
1031 max(build_oa_targets) as build_oa_targets,
1032 max(build_dow_targets) as build_dow_targets,
1033 max(build_point_targets) as build_point_targets,
1034 max(build_hour_targets) as build_hour_targets
1035 from buffer_target_dates
1036 where session_id = 1458117728
1037 order by null
1038
1039Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets02 - 132.653ms
1040 (131.5ms) select distinct calendar_schedule_id
1041 from buffer_target_dates
1042 where
1043 session_id = 1458117728
1044 and build_point_targets = 1
1045
1046 (133.6ms) truncate table buffer_target_call_types_1458117728
1047
1048 (137.0ms) insert into buffer_target_call_types_1458117728 (
1049 id,
1050 target_group_id,
1051 assignment_id,
1052 assignment_type,
1053 calendar_schedule_id,
1054 days_of_week_mask,
1055 hours,
1056 points_days_of_week_mask,
1057 included_in_targets,
1058 all_staff_types,
1059 location_id
1060 )
1061 select
1062 ct.id,
1063 0 as target_group_id,
1064 ct.id as assignment_id,
1065 'CallType' as assignment_type,
1066 ct.calendar_schedule_id,
1067 ct.days_of_week_mask,
1068 null as hours,
1069 sum((1 << dp.day)) as points_days_of_week_mask,
1070 ct.included_in_targets,
1071 ct.all_staff_types,
1072 ct.location_id
1073 from
1074 call_types as ct
1075 inner join assignment_annotations as aa
1076 on ct.id = aa.assignmentable_id
1077 and aa.assignmentable_type = 'CallType'
1078 and aa.annotation_id = 0 /* annotation = "None" */
1079 and aa.applicable = 1
1080 inner join assignment_annotation_daily_points as dp
1081 on aa.id = dp.assignment_annotation_id
1082 and dp.point != 0
1083 and dp.day <= 6
1084 where
1085 ct.calendar_schedule_id in (6)
1086 and ct.active = 1
1087 and ct.days_of_week_mask > 0
1088 group by
1089 ct.id,
1090 ct.calendar_schedule_id,
1091 ct.days_of_week_mask,
1092 ct.included_in_targets,
1093 ct.all_staff_types,
1094 ct.location_id
1095 order by null
1096
1097 (134.8ms) insert into buffer_target_daily_points_1458117728 (
1098 call_type_id,
1099 day,
1100 point
1101 )
1102 select
1103 ct.id as call_type_id,
1104 dp.day,
1105 dp.point
1106 from buffer_target_call_types_1458117728 as ct
1107 inner join assignment_annotations as aa
1108 on ct.id = aa.assignmentable_id
1109 and aa.assignmentable_type = 'CallType'
1110 and aa.annotation_id = 0 /* annotation = "None" */
1111 and aa.applicable = 1
1112 inner join assignment_annotation_daily_points as dp
1113 on aa.id = dp.assignment_annotation_id
1114 where dp.point != 0
1115 order by null
1116
1117Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets02Points - 538.771ms
1118 (131.2ms) select id from buffer_target_call_types_1458117728 limit 1
1119 Block Exists (131.2ms) SELECT 1 AS one FROM `blocks` INNER JOIN `published_blocks` ON `published_blocks`.`block_id` = `blocks`.`id` INNER JOIN `block_schedules` ON `blocks`.`block_schedule_id` = `block_schedules`.`id` WHERE `block_schedules`.`id` = 6 LIMIT 1
1120 Block Load (134.0ms) SELECT `blocks`.* FROM `blocks` INNER JOIN `published_blocks` ON `published_blocks`.`block_id` = `blocks`.`id` INNER JOIN `block_schedules` ON `blocks`.`block_schedule_id` = `block_schedules`.`id` WHERE `block_schedules`.`id` = 6 ORDER BY start_date DESC, end_date DESC, blocks.start_date DESC LIMIT 1
1121 Block Load (131.6ms) SELECT `blocks`.* FROM `blocks` WHERE `blocks`.`client_id` = 6 AND `blocks`.`block_schedule_id` = 6 AND (blocks.end_date > '2017-09-30') AND (blocks.id != 16540) ORDER BY start_date asc LIMIT 1
1122 (133.4ms) truncate table buffer_location_privileges_1458117728
1123
1124 (136.0ms) insert into buffer_location_privileges_1458117728 (
1125 staff_id,
1126 location_id,
1127 begin_date,
1128 end_date
1129 )
1130 select
1131 s.id as staff_id,
1132 l.location_id,
1133 '0000-00-00' as begin_date,
1134 '9999-12-31' as end_date
1135 from (
1136 select
1137 l.id as location_id
1138 from
1139 buffer_target_call_types_1458117728 as ct
1140 inner join locations as l
1141 on ct.location_id = l.id
1142 and l.active = 1
1143 group by
1144 l.id
1145 order by null
1146 ) as l
1147 inner join staffs as s
1148 on s.client_id = 6
1149 and s.active = 1
1150 and s.take_call = 1
1151 left join location_privileges as lp
1152 on s.id = lp.staff_id
1153 where
1154 lp.id is null
1155 union
1156 select
1157 lp.staff_id,
1158 lp.location_id,
1159 lp.begin_date,
1160 coalesce(lp.end_date, '9999-12-31') as end_date
1161 from (
1162 select
1163 l.id as location_id
1164 from
1165 buffer_target_call_types_1458117728 as ct
1166 inner join locations as l
1167 on ct.location_id = l.id
1168 and l.active = 1
1169 group by
1170 l.id
1171 order by null
1172 ) as l
1173 inner join location_privileges as lp
1174 on l.location_id = lp.location_id
1175 order by null
1176
1177 (133.9ms) truncate table buffer_target_primary_availabilities_1458117728
1178
1179 (135.8ms) insert into buffer_target_primary_availabilities_1458117728 (
1180 staff_id,
1181 call_type_id,
1182 target_group_id,
1183 assignment_id,
1184 assignment_type,
1185 calendar_schedule_id,
1186 day_of_week_mask,
1187 is_weekend,
1188 staff_type_id,
1189 st_begin_date,
1190 st_end_date,
1191 location_id,
1192 lp_begin_date,
1193 lp_end_date,
1194 included_in_targets
1195 )
1196 select straight_join
1197 s.id as staff_id,
1198 ct.id as call_type_id,
1199 ct.target_group_id,
1200 ct.assignment_id,
1201 ct.assignment_type,
1202 ct.calendar_schedule_id,
1203 t1.day_of_week_mask,
1204 t1.is_weekend,
1205 ast.staff_type_id,
1206 ast.begin_date as st_begin_date,
1207 coalesce(ast.end_date, '9999-12-31') as st_end_date,
1208 lp.location_id,
1209 lp.begin_date as lp_begin_date,
1210 lp.end_date as lp_end_date,
1211 ct.included_in_targets
1212 from (
1213 select 1 as day_of_week_mask, 1 as is_weekend
1214 union select 2, 0
1215 union select 4, 0
1216 union select 8, 0
1217 union select 16, 0
1218 union select 32, 0
1219 union select 64, 1
1220 ) as t1
1221 inner join buffer_target_call_types_1458117728 as ct
1222 on (t1.day_of_week_mask & ct.days_of_week_mask) > 0
1223 and ct.all_staff_types = 1
1224 inner join staff_call_types as sct
1225 on ct.id = sct.call_type_id
1226 -- 2nd and 3rd passes (points & hours)
1227 and t1.day_of_week_mask & sct.days_of_week_mask > 0
1228
1229 inner join staffs as s
1230 on sct.staff_id = s.id
1231 and s.active = 1
1232 and s.take_call = 1
1233 inner join buffer_location_privileges_1458117728 as lp
1234 on s.id = lp.staff_id
1235 and ct.location_id = lp.location_id
1236 and coalesce(lp.end_date, '9999-12-31') >= '2017-10-01' /* current targets begin date */
1237 inner join assign_staff_types as ast
1238 on s.id = ast.staff_id
1239 and coalesce(ast.end_date, '9999-12-31') >= '2017-10-01' /* current targets begin date */
1240 -- 2nd and 3rd passes (points & hours)
1241 inner join staff_types as st
1242 on ast.staff_type_id = st.id
1243
1244 where
1245 ast.begin_date <= coalesce(lp.end_date, '9999-12-31')
1246 and lp.begin_date <= coalesce(ast.end_date, '9999-12-31')
1247 -- 2nd and 3rd passes (points & hours)
1248 and ct.calendar_schedule_id = st.point_hour_schedule_id
1249
1250 order by null
1251
1252 (148.8ms) insert into buffer_target_primary_availabilities_1458117728 (
1253 staff_id,
1254 call_type_id,
1255 target_group_id,
1256 assignment_id,
1257 assignment_type,
1258 calendar_schedule_id,
1259 day_of_week_mask,
1260 is_weekend,
1261 staff_type_id,
1262 st_begin_date,
1263 st_end_date,
1264 location_id,
1265 lp_begin_date,
1266 lp_end_date,
1267 included_in_targets
1268 )
1269 select straight_join
1270 s.id as staff_id,
1271 ct.id as call_type_id,
1272 ct.target_group_id,
1273 ct.assignment_id,
1274 ct.assignment_type,
1275 ct.calendar_schedule_id,
1276 t1.day_of_week_mask,
1277 t1.is_weekend,
1278 ast.staff_type_id,
1279 ast.begin_date as st_begin_date,
1280 coalesce(ast.end_date, '9999-12-31') as st_end_date,
1281 lp.location_id,
1282 lp.begin_date as lp_begin_date,
1283 lp.end_date as lp_end_date,
1284 ct.included_in_targets
1285 from (
1286 select 1 as day_of_week_mask, 1 as is_weekend
1287 union select 2, 0
1288 union select 4, 0
1289 union select 8, 0
1290 union select 16, 0
1291 union select 32, 0
1292 union select 64, 1
1293 ) as t1
1294 inner join buffer_target_call_types_1458117728 as ct
1295 on (t1.day_of_week_mask & ct.days_of_week_mask) > 0
1296 and ct.all_staff_types = 0
1297 inner join staff_call_types as sct
1298 on ct.id = sct.call_type_id
1299 -- 2nd and 3rd passes (points & hours)
1300 and t1.day_of_week_mask & sct.days_of_week_mask > 0
1301
1302 inner join staffs as s
1303 on sct.staff_id = s.id
1304 and s.active = 1
1305 and s.take_call = 1
1306 inner join buffer_location_privileges_1458117728 as lp
1307 on s.id = lp.staff_id
1308 and ct.location_id = lp.location_id
1309 and coalesce(lp.end_date, '9999-12-31') >= '2017-10-01' /* current targets begin date */
1310 inner join assign_staff_types as ast
1311 on s.id = ast.staff_id
1312 and coalesce(ast.end_date, '9999-12-31') >= '2017-10-01' /* current targets begin date */
1313 inner join eligible_staff_types as est
1314 on ct.id = est.call_type_id
1315 and ast.staff_type_id = est.staff_type_id
1316 -- 2nd and 3rd passes (points & hours)
1317 inner join staff_types as st
1318 on ast.staff_type_id = st.id
1319
1320 where
1321 ast.begin_date <= coalesce(lp.end_date, '9999-12-31')
1322 and lp.begin_date <= coalesce(ast.end_date, '9999-12-31')
1323 -- 2nd and 3rd passes (points & hours)
1324 and ct.calendar_schedule_id = st.point_hour_schedule_id
1325
1326 order by null
1327
1328Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0201 - 1100.765ms
1329 (131.5ms) select id from buffer_target_primary_availabilities_1458117728 limit 1
1330 (137.4ms) insert into buffer_annual_point_targets_1458117728 (
1331 staff_id,
1332 calendar_schedule_id,
1333 is_weekend,
1334 points,
1335 estimated_vacation,
1336 available_days,
1337 relative_capacity
1338 )
1339 select
1340 t1.staff_id,
1341 t1.calendar_schedule_id,
1342 t1.is_weekend,
1343 0 as points, /* will be calculated on the next step */
1344 coalesce(t2.estimated_vacation, 0) as estimated_vacation,
1345 (t1.available_days - coalesce(t2.estimated_vacation, 0)) as available_days,
1346 0 as relative_capacity /* will be calculated on the next step */
1347 from (
1348 select
1349 staff_id,
1350 calendar_schedule_id,
1351 is_weekend,
1352 case
1353 when (is_weekend = 0) then (5 * 52)
1354 else (2 * 52)
1355 end as available_days
1356 from buffer_target_primary_availabilities_1458117728
1357 group by
1358 staff_id,
1359 calendar_schedule_id,
1360 is_weekend
1361 order by null
1362 ) as t1
1363 left join (
1364 select
1365 staff_id,
1366 is_weekend,
1367 sum(coalesce(allocated, 0)) as estimated_vacation
1368 from annual_targets
1369 where client_id = 6
1370 and assignment_id = -1
1371 and assignment_type = 'Vacation'
1372 group by
1373 staff_id,
1374 is_weekend
1375 order by null
1376 ) as t2
1377 on t1.staff_id = t2.staff_id
1378 and t1.is_weekend = t2.is_weekend
1379 order by null
1380
1381 (136.3ms) update
1382 buffer_annual_point_targets_1458117728 as apt
1383 inner join (
1384 select
1385 calendar_schedule_id,
1386 is_weekend,
1387 sum(available_days) as available_days_total
1388 from buffer_annual_point_targets_1458117728
1389 group by
1390 calendar_schedule_id,
1391 is_weekend
1392 order by null
1393 ) as t1
1394 on apt.calendar_schedule_id = t1.calendar_schedule_id
1395 and apt.is_weekend = t1.is_weekend
1396 inner join (
1397 select
1398 ct.calendar_schedule_id,
1399 t1.is_weekend,
1400 sum(dp.point) * 52 as points_total
1401 from (
1402 select 0 as wday, 1 as day_of_week_mask, 1 as is_weekend
1403 union select 1, 2, 0
1404 union select 2, 4, 0
1405 union select 3, 8, 0
1406 union select 4, 16, 0
1407 union select 5, 32, 0
1408 union select 6, 64, 1
1409 ) as t1
1410 inner join buffer_target_call_types_1458117728 as ct
1411 on (t1.day_of_week_mask & ct.days_of_week_mask) > 0
1412 inner join buffer_target_daily_points_1458117728 as dp
1413 on ct.id = dp.call_type_id
1414 and t1.wday = dp.day
1415 group by
1416 ct.calendar_schedule_id,
1417 t1.is_weekend
1418 order by null
1419 ) as t2
1420 on apt.calendar_schedule_id = t2.calendar_schedule_id
1421 and apt.is_weekend = t2.is_weekend
1422 left join annual_target_points as apt_2
1423 on apt.staff_id = apt_2.staff_id
1424 and apt.calendar_schedule_id = apt_2.calendar_schedule_id
1425 and apt.is_weekend = apt_2.is_weekend
1426 set apt.points =
1427 case
1428 when (apt_2.id is not null) then apt_2.points
1429 when (t1.available_days_total > 0)
1430 then (t2.points_total * apt.available_days / t1.available_days_total)
1431 else 0.0
1432 end
1433
1434 (133.6ms) update
1435 buffer_annual_point_targets_1458117728 as apt
1436 inner join target_autopopulate_timeframes as ts
1437 on apt.calendar_schedule_id = ts.calendar_schedule_id
1438 and ts.annual_target_view = 'fte'
1439 left join annual_target_points as apt_2
1440 on apt.staff_id = apt_2.staff_id
1441 and apt.calendar_schedule_id = apt_2.calendar_schedule_id
1442 and apt.is_weekend = apt_2.is_weekend
1443 set apt.points = 1.0
1444 where
1445 apt.points != 0
1446 and apt_2.id is null
1447
1448 (134.5ms) update
1449 buffer_annual_point_targets_1458117728 as apt
1450 inner join (
1451 select
1452 calendar_schedule_id,
1453 is_weekend,
1454 sum(points) as points_total,
1455 sum(available_days) as available_days_total
1456 from buffer_annual_point_targets_1458117728
1457 where points != 0
1458 group by
1459 calendar_schedule_id,
1460 is_weekend
1461 order by null
1462 ) as t1
1463 on apt.calendar_schedule_id = t1.calendar_schedule_id
1464 and apt.is_weekend = t1.is_weekend
1465 set apt.relative_capacity =
1466 case
1467 when (t1.points_total > 0 and t1.available_days_total > 0)
1468 then (apt.points / t1.points_total) / (apt.available_days / t1.available_days_total) * 100
1469 else 0
1470 end
1471
1472Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0205 - 544.0350000000001ms
1473 (134.9ms) truncate table buffer_target_dates_list_1458117728
1474
1475 (146.6ms) insert into buffer_target_dates_list_1458117728 (
1476 block_id,
1477 calendar_schedule_id,
1478 date,
1479 day_of_week_mask,
1480 is_weekend
1481 ,dp_day_primary ,dp_day_secondary /* 2nd pass */
1482 )
1483 select
1484 dl.block_id,
1485 dl.calendar_schedule_id,
1486 dl.date,
1487 (1 << (dayofweek(dl.date) - 1)) as day_of_week_mask,
1488 case
1489 when (dayofweek(dl.date) between 2 /* Monday */ and 6 /* Friday */) then 0
1490 else 1
1491 end as is_weekend
1492 /* 2nd pass */
1493 ,case
1494 when (hl.id is null) then (dayofweek(dl.date) - 1)
1495 when (dl.date = hl.observed_date) then 7
1496 else 8
1497 end as dp_day_primary
1498 ,(dayofweek(dl.date) - 1) as dp_day_secondary
1499
1500 from(
1501 select
1502 td.block_id,
1503 td.calendar_schedule_id,
1504 date_add(td.start_date, interval ns.item_number day) as date
1505 from
1506 buffer_target_dates as td
1507 inner join numeric_sequence as ns
1508 on ns.item_number <= datediff(td.end_date, td.start_date)
1509 where
1510 td.session_id = 1458117728
1511 and td.build_point_targets = 1
1512 order by null
1513 ) as dl
1514 /* 2nd pass */
1515 left join (
1516 select
1517 hd.id,
1518 hd.observed_date,
1519 case
1520 when (hd.observed_date > hd.extended_date) then hd.extended_date
1521 else hd.observed_date
1522 end as date_from,
1523 case
1524 when (hd.observed_date < hd.extended_date) then hd.extended_date
1525 else hd.observed_date
1526 end as date_to
1527 from
1528 holidays as h
1529 inner join holiday_dates as hd
1530 on h.id = hd.holiday_id
1531 inner join (
1532 select
1533 year(min(start_date)) as year_from,
1534 year(max(end_date)) as year_to
1535 from buffer_target_dates
1536 where
1537 session_id = 1458117728 /* session_id */
1538 and build_point_targets = 1
1539 order by null
1540 ) as y
1541 on hd.year between y.year_from and y.year_to
1542 where
1543 h.client_id = 6 /* client_id */
1544 and (
1545 h.observed = 1
1546 or h.extended = 1
1547 )
1548 order by null
1549 ) as hl
1550 on dl.date between hl.date_from and hl.date_to
1551
1552 order by null
1553
1554 (133.3ms) truncate table buffer_tmp_targets_availabilities_1458117728
1555
1556 (158.3ms) insert into buffer_tmp_targets_availabilities_1458117728 (
1557 block_id,
1558 calendar_schedule_id,
1559 date,
1560 day_of_week_mask,
1561 is_weekend,
1562 call_type_id,
1563 assignment_id,
1564 assignment_type,
1565 staff_id,
1566 included_in_targets
1567 )
1568 select
1569 dl.block_id,
1570 dl.calendar_schedule_id,
1571 dl.date,
1572 dl.day_of_week_mask,
1573 dl.is_weekend,
1574 pa.call_type_id,
1575 pa.assignment_id,
1576 pa.assignment_type,
1577 pa.staff_id,
1578 pa.included_in_targets
1579 from
1580 buffer_target_dates_list_1458117728 as dl
1581 inner join buffer_target_primary_availabilities_1458117728 as pa
1582 on dl.calendar_schedule_id = pa.calendar_schedule_id
1583 and dl.day_of_week_mask = pa.day_of_week_mask
1584 and dl.date between pa.st_begin_date and pa.st_end_date
1585 and dl.date between pa.lp_begin_date and pa.lp_end_date
1586 inner join staff_types as st
1587 on pa.staff_type_id = st.id
1588 and st.active = 1
1589 order by null
1590
1591 (134.4ms) truncate table buffer_tmp_targets_availabilities_exclusions_1458117728
1592
1593 (142.9ms) insert into buffer_tmp_targets_availabilities_exclusions_1458117728 (id)
1594 select ta.id
1595 from
1596 buffer_tmp_targets_availabilities_1458117728 as ta
1597 inner join staff_rotations as sr use index (ix_staff_rotations_composite_1)
1598 on ta.staff_id = sr.staff_id
1599 and ta.date between sr.start_date and sr.end_date
1600 inner join rotations as r
1601 on sr.rotation_id = r.id
1602 and r.active = 1
1603 left join rotation_call_types as rct
1604 on sr.rotation_id = rct.rotation_id
1605 and ta.call_type_id = rct.call_type_id
1606 -- 2nd and 3rd passes
1607 and ta.day_of_week_mask & rct.days_of_week_mask > 0
1608
1609 left join daily_rotations as dr
1610 on ta.date = dr.schedule_on
1611 and ta.staff_id = dr.staff_id
1612 where
1613 rct.id is null
1614 and dr.id is null
1615 order by null
1616
1617 (152.6ms) insert into buffer_tmp_targets_availabilities_exclusions_1458117728 (id)
1618 select ta.id
1619 from
1620 buffer_tmp_targets_availabilities_1458117728 as ta
1621 inner join daily_rotations as dr
1622 on ta.date = dr.schedule_on
1623 and ta.staff_id = dr.staff_id
1624 inner join rotations as r
1625 on dr.rotation_id = r.id
1626 and r.active = 1
1627 left join rotation_call_types as rct
1628 on dr.rotation_id = rct.rotation_id
1629 and ta.call_type_id = rct.call_type_id
1630 -- 2nd and 3rd passes
1631 and ta.day_of_week_mask & rct.days_of_week_mask > 0
1632
1633 where rct.id is null
1634 order by null
1635
1636 (149.3ms) insert into buffer_tmp_targets_availabilities_exclusions_1458117728 (id)
1637 select ta.id
1638 from
1639 buffer_tmp_targets_availabilities_1458117728 as ta
1640 inner join target_autopopulate_timeframes as ts
1641 on ta.calendar_schedule_id = ts.calendar_schedule_id
1642 -- 2nd pass
1643 and ts.available_days_in_points = 1
1644
1645 inner join vacations as v
1646 on ta.date = v.schedule_on
1647 and ta.staff_id = v.staff_id
1648 and v.status = 3 /* status = fulfilled */
1649 order by null
1650
1651Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets03 - 1155.829ms
1652 (131.5ms) select distinct calendar_schedule_id
1653 from buffer_target_dates
1654 where
1655 session_id = 1458117728
1656 and build_point_targets = 1
1657
1658 (133.7ms) truncate buffer_tmp_targets_scheduled_1458117728
1659
1660 (630.6ms) insert into buffer_tmp_targets_scheduled_1458117728 (
1661 block_id,
1662 calendar_schedule_id,
1663 staff_id,
1664 assignment_id,
1665 assignment_type,
1666 day_of_week_mask,
1667 is_weekend,
1668 scheduled,
1669 other_scheduled
1670 )
1671 select
1672 dl.block_id,
1673 dl.calendar_schedule_id,
1674 sc.staff_id,
1675 0 as assignment_id,
1676 '' as assignment_type,
1677 0 as day_of_week_mask,
1678 dl.is_weekend,
1679 sum(
1680 case
1681 when (dl.calendar_schedule_id = ct.calendar_schedule_id)
1682 then coalesce(dp.point, dp_2.point, 0.0)
1683 else 0.0
1684 end
1685 ) as _scheduled,
1686 sum(
1687 case
1688 when (dl.calendar_schedule_id != ct.calendar_schedule_id)
1689 then coalesce(dp.point, dp_2.point, 0.0)
1690 else 0.0
1691 end
1692 ) as _other_scheduled
1693 from
1694 buffer_target_dates_list_1458117728 as dl
1695 inner join schedules as sc
1696 on dl.date = sc.schedule_on
1697 and sc.client_id = 6 /* client_id */
1698 inner join (
1699 select
1700 ct.id,
1701 ct.calendar_schedule_id,
1702 aa.id as assignment_annotation_id
1703 from
1704 call_types as ct
1705 inner join assignment_annotations as aa
1706 on ct.id = aa.assignmentable_id
1707 and aa.assignmentable_type = 'CallType'
1708 and aa.annotation_id = 0 /* annotation = "None" */
1709 and aa.applicable = 1
1710 inner join assignment_annotation_daily_points as dp
1711 on aa.id = dp.assignment_annotation_id
1712 and dp.point != 0
1713 where
1714 ct.client_id = 6 /* client_id */
1715 and ct.active = 1
1716 group by
1717 ct.id,
1718 ct.calendar_schedule_id,
1719 aa.id
1720 order by null
1721 ) as ct
1722 on sc.call_type_id = ct.id
1723 left join assignment_annotation_daily_points as dp
1724 on ct.assignment_annotation_id = dp.assignment_annotation_id
1725 and dl.dp_day_primary = dp.day
1726 left join assignment_annotation_daily_points as dp_2
1727 on ct.assignment_annotation_id = dp_2.assignment_annotation_id
1728 and dl.dp_day_secondary = dp_2.day
1729 inner join assign_staff_types as ast
1730 on sc.staff_id = ast.staff_id
1731 and dl.date between ast.begin_date and coalesce(ast.end_date, '9999-12-31')
1732 inner join staff_types as st
1733 on ast.staff_type_id = st.id
1734 and dl.calendar_schedule_id = st.point_hour_schedule_id
1735 group by
1736 dl.block_id,
1737 dl.calendar_schedule_id,
1738 sc.staff_id,
1739 dl.is_weekend
1740 having
1741 _scheduled != 0
1742 or _other_scheduled != 0
1743 order by null
1744
1745 (133.5ms) truncate table buffer_tmp_targets_staff_totals_1458117728
1746
1747 (138.4ms) insert into buffer_tmp_targets_staff_totals_1458117728 (
1748 block_id,
1749 calendar_schedule_id,
1750 staff_id,
1751 assignment_id,
1752 assignment_type,
1753 day_of_week_mask,
1754 is_weekend,
1755 relative_capacity,
1756 available_days,
1757 weighted_days,
1758 scheduled,
1759 other_scheduled
1760 )
1761 select
1762 t1.block_id,
1763 t1.calendar_schedule_id,
1764 t1.staff_id,
1765 0 as assignment_id,
1766 '' as assignment_type,
1767 0 as day_of_week_mask,
1768 t1.is_weekend,
1769 apt.relative_capacity,
1770 t1.available_days,
1771 (t1.available_days * apt.relative_capacity / 100) as weighted_days,
1772 coalesce(sch_t._scheduled, 0.0) as scheduled,
1773 coalesce(sch_t._other_scheduled, 0.0) as other_scheduled
1774 from (
1775 select
1776 ta.block_id,
1777 ta.calendar_schedule_id,
1778 ta.staff_id,
1779 ta.is_weekend,
1780 count(distinct ta.date) as available_days
1781 from
1782 buffer_tmp_targets_availabilities_1458117728 as ta
1783 left join buffer_tmp_targets_availabilities_exclusions_1458117728 as tae
1784 on ta.id = tae.id
1785 where tae.id is null
1786 group by
1787 ta.block_id,
1788 ta.calendar_schedule_id,
1789 ta.staff_id,
1790 ta.is_weekend
1791 order by null
1792 ) as t1
1793 inner join buffer_annual_point_targets_1458117728 as apt
1794 on t1.staff_id = apt.staff_id
1795 and t1.calendar_schedule_id = apt.calendar_schedule_id
1796 and t1.is_weekend = apt.is_weekend
1797 left join (
1798 select
1799 block_id,
1800 calendar_schedule_id,
1801 staff_id,
1802 is_weekend,
1803 sum(scheduled) as _scheduled,
1804 sum(other_scheduled) as _other_scheduled
1805 from buffer_tmp_targets_scheduled_1458117728
1806 group by
1807 block_id,
1808 calendar_schedule_id,
1809 staff_id,
1810 is_weekend
1811 order by null
1812 ) as sch_t
1813 on t1.block_id = sch_t.block_id
1814 and t1.calendar_schedule_id = sch_t.calendar_schedule_id
1815 and t1.staff_id = sch_t.staff_id
1816 and t1.is_weekend = sch_t.is_weekend
1817 order by null
1818
1819 (134.0ms) truncate table buffer_tmp_targets_client_totals_1458117728
1820
1821 (153.4ms) insert into buffer_tmp_targets_client_totals_1458117728 (
1822 block_id,
1823 calendar_schedule_id,
1824 assignment_id,
1825 assignment_type,
1826 day_of_week_mask,
1827 is_weekend,
1828 targets_total,
1829 weighted_days_total
1830 )
1831 select
1832 st.block_id,
1833 st.calendar_schedule_id,
1834 0 as assignment_id,
1835 '' as assignment_type,
1836 0 as day_of_week_mask,
1837 st.is_weekend,
1838 cp.points_total as targets_total,
1839 sum(st.weighted_days) as weighted_days_total
1840 from
1841 buffer_tmp_targets_staff_totals_1458117728 as st
1842 inner join (
1843 select
1844 dl.block_id,
1845 dl.calendar_schedule_id,
1846 dl.is_weekend,
1847 sum(
1848 case
1849 when
1850 (
1851 (
1852 ts.use_non_targeted_staff = 0
1853 or sc.id is null
1854 or pa.staff_id is not null
1855 )
1856 and (
1857 ts.remove_slots_from_denominator_targets = 0
1858 or ae.id is null
1859 )
1860 ) then coalesce(dp.point, dp_2.point, 0.0)
1861 else 0.0
1862 end
1863 ) as points_total
1864 from
1865 buffer_target_dates_list_1458117728 as dl
1866 inner join buffer_target_call_types_1458117728 as ct
1867 on dl.calendar_schedule_id = ct.calendar_schedule_id
1868 and (dl.day_of_week_mask & ct.points_days_of_week_mask) > 0
1869 left join buffer_target_daily_points_1458117728 as dp
1870 on ct.id = dp.call_type_id
1871 and dl.dp_day_primary = dp.day
1872 left join buffer_target_daily_points_1458117728 as dp_2
1873 on ct.id = dp_2.call_type_id
1874 and dl.dp_day_secondary = dp_2.day
1875 inner join target_autopopulate_timeframes as ts
1876 on dl.calendar_schedule_id = ts.calendar_schedule_id
1877 left join schedules as sc
1878 on dl.date = sc.schedule_on
1879 and ct.id = sc.call_type_id
1880 left join buffer_target_primary_availabilities_1458117728 as pa
1881 on sc.staff_id = pa.staff_id
1882 and ct.id = pa.call_type_id
1883 and dl.day_of_week_mask = pa.day_of_week_mask
1884 and dl.date between pa.st_begin_date and pa.st_end_date
1885 and dl.date between pa.lp_begin_date and pa.lp_end_date
1886 left join autopopulate_exclusions as ae
1887 on dl.date = ae.schedule_on
1888 and ct.id = ae.call_type_id
1889 group by
1890 dl.block_id,
1891 dl.calendar_schedule_id,
1892 dl.is_weekend
1893 order by null
1894 ) as cp
1895 on st.block_id = cp.block_id
1896 and st.calendar_schedule_id = cp.calendar_schedule_id
1897 and st.is_weekend = cp.is_weekend
1898 group by
1899 st.block_id,
1900 st.calendar_schedule_id,
1901 st.is_weekend,
1902 cp.points_total
1903 order by null
1904
1905 (135.5ms) insert into buffer_point_targets_1458117728 (
1906 block_id,
1907 calendar_schedule_id,
1908 staff_id,
1909 is_weekend,
1910 raw_target,
1911 target,
1912 initial_target,
1913 scheduled,
1914 other_scheduled,
1915 available_days
1916 )
1917 select
1918 st.block_id,
1919 st.calendar_schedule_id,
1920 st.staff_id,
1921 st.is_weekend,
1922 case
1923 when (ct.weighted_days_total > 0)
1924 then (ct.targets_total * st.weighted_days / ct.weighted_days_total)
1925 else 0
1926 end as raw_target,
1927 case
1928 when (ct.weighted_days_total > 0)
1929 then (ct.targets_total * st.weighted_days / ct.weighted_days_total)
1930 else 0
1931 end as target,
1932 case
1933 when (ct.weighted_days_total > 0)
1934 then (ct.targets_total * st.weighted_days / ct.weighted_days_total)
1935 else 0
1936 end as initial_target,
1937 st.scheduled,
1938 st.other_scheduled,
1939 st.available_days
1940 from
1941 buffer_tmp_targets_staff_totals_1458117728 as st
1942 inner join buffer_tmp_targets_client_totals_1458117728 as ct
1943 on st.block_id = ct.block_id
1944 and st.calendar_schedule_id = ct.calendar_schedule_id
1945 and st.is_weekend = ct.is_weekend
1946 order by null
1947
1948 (132.9ms) update
1949 buffer_point_targets_1458117728 as pt
1950 inner join (
1951 select
1952 block_id,
1953 calendar_schedule_id,
1954 is_weekend,
1955 sum(initial_target) as targets_total,
1956 sum(other_scheduled) as other_scheduled_total
1957 from buffer_point_targets_1458117728
1958 group by
1959 block_id,
1960 calendar_schedule_id,
1961 is_weekend
1962 order by null
1963 ) as t1
1964 on pt.block_id = t1.block_id
1965 and pt.calendar_schedule_id = t1.calendar_schedule_id
1966 and pt.is_weekend = t1.is_weekend
1967 left join adjusted_target_points as apt
1968 on pt.block_id = apt.block_id
1969 and pt.calendar_schedule_id = apt.calendar_schedule_id
1970 and pt.staff_id = apt.staff_id
1971 and pt.is_weekend = apt.is_weekend
1972 set
1973 pt.target =
1974 case
1975 when (apt.id is not null) then apt.target
1976 when (t1.targets_total > 0)
1977 then ((t1.targets_total + t1.other_scheduled_total) * pt.initial_target / t1.targets_total - pt.other_scheduled)
1978 else 0.0
1979 end,
1980 pt.raw_target =
1981 case
1982 when (t1.targets_total > 0)
1983 then ((t1.targets_total + t1.other_scheduled_total) * pt.initial_target / t1.targets_total - pt.other_scheduled)
1984 else 0.0
1985 end
1986
1987 (131.7ms) insert into buffer_point_targets_1458117728 (
1988 block_id,
1989 calendar_schedule_id,
1990 staff_id,
1991 is_weekend,
1992 raw_target,
1993 target,
1994 initial_target,
1995 scheduled,
1996 other_scheduled,
1997 available_days
1998 )
1999 select
2000 sch_t.block_id,
2001 sch_t.calendar_schedule_id,
2002 sch_t.staff_id,
2003 sch_t.is_weekend,
2004 0.0 as raw_target,
2005 0.0 as target,
2006 0.0 as initial_target,
2007 sum(sch_t.scheduled) as scheduled,
2008 sum(sch_t.other_scheduled) as other_scheduled,
2009 0 as available_days
2010 from
2011 buffer_tmp_targets_scheduled_1458117728 as sch_t
2012 left join buffer_point_targets_1458117728 as pt
2013 on sch_t.block_id = pt.block_id
2014 and sch_t.calendar_schedule_id = pt.calendar_schedule_id
2015 and sch_t.staff_id = pt.staff_id
2016 and sch_t.is_weekend = pt.is_weekend
2017 where
2018 sch_t.scheduled != 0
2019 and pt.id is null
2020 group by
2021 sch_t.block_id,
2022 sch_t.calendar_schedule_id,
2023 sch_t.staff_id,
2024 sch_t.is_weekend
2025 order by null
2026
2027Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0401 - 1860.135ms
2028 (131.3ms) delete upt
2029 from
2030 buffer_target_dates as td
2031 inner join unpublished_point_targets as upt
2032 on td.calendar_schedule_id = upt.calendar_schedule_id
2033 and td.block_id = upt.block_id
2034 where
2035 td.session_id = 1458117728
2036 and td.build_point_targets = 1
2037
2038 (260.1ms) insert into unpublished_point_targets (
2039 client_id,
2040 calendar_schedule_id,
2041 block_id,
2042 staff_id,
2043 is_weekend,
2044 raw_target,
2045 target,
2046 initial_target,
2047 scheduled,
2048 other_scheduled,
2049 available_days
2050 )
2051 select
2052 td.client_id,
2053 pt.calendar_schedule_id,
2054 pt.block_id,
2055 pt.staff_id,
2056 pt.is_weekend,
2057 pt.raw_target,
2058 pt.target,
2059 pt.initial_target,
2060 pt.scheduled,
2061 pt.other_scheduled,
2062 pt.available_days
2063 from
2064 buffer_target_dates as td
2065 inner join buffer_point_targets_1458117728 as pt
2066 on td.calendar_schedule_id = pt.calendar_schedule_id
2067 and td.block_id = pt.block_id
2068 where
2069 td.session_id = 1458117728 /* session_id */
2070 and td.build_point_targets = 1
2071 union all
2072 select
2073 td.client_id,
2074 td.calendar_schedule_id,
2075 td.block_id,
2076 0 as staff_id,
2077 0 as is_weekend,
2078 0 as raw_target,
2079 0 as target,
2080 0 as initial_target,
2081 0 as scheduled,
2082 0 as other_scheduled,
2083 0 as available_days
2084 from
2085 buffer_target_dates as td
2086 where
2087 td.session_id = 1458117728 /* session_id */
2088 and td.build_point_targets = 1
2089 order by null
2090
2091Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0701 - 392.262ms
2092 (136.0ms) /* CumulativePointTargetsRule */
2093 insert into buffer_cumulative_point_targets_1458117728 (
2094 staff_id,
2095 is_weekend,
2096 calendar_schedule_id,
2097 raw_target,
2098 adjusted_target,
2099 scheduled,
2100 other_scheduled,
2101 available_days
2102 )
2103 select
2104 t.staff_id,
2105 t.is_weekend,
2106 t.calendar_schedule_id,
2107 sum(t.raw_target) as raw_target,
2108 sum(t.adjusted_target) as adjusted_target,
2109 sum(t.scheduled) as scheduled,
2110 sum(t.other_scheduled) as other_scheduled,
2111 sum(t.available_days) as available_days
2112 from (
2113 select
2114 t.calendar_schedule_id,
2115 t.block_id,
2116 t.staff_id,
2117 t.is_weekend,
2118 t.raw_target,
2119 t.target as adjusted_target,
2120 t.scheduled,
2121 t.other_scheduled,
2122 t.available_days
2123 from buffer_target_dates as td
2124 inner join buffer_point_targets_1458117728 as t
2125 on td.calendar_schedule_id = t.calendar_schedule_id
2126 and td.block_id = t.block_id
2127 where td.session_id = 1458117728
2128 and td.build_point_targets = 1
2129 and td.within_cumulative_period = 1
2130 union
2131 select
2132 pt.calendar_schedule_id,
2133 pt.block_id,
2134 pt.staff_id,
2135 pt.is_weekend,
2136 pt.raw_target,
2137 pt.target,
2138 pt.scheduled,
2139 pt.other_scheduled,
2140 pt.available_days
2141 from buffer_target_dates as td
2142 inner join point_targets as pt
2143 on td.calendar_schedule_id = pt.calendar_schedule_id
2144 and td.block_id = pt.block_id
2145 where td.session_id = 1458117728
2146 and td.build_point_targets = 0
2147 and td.point_targets_source = 'published'
2148 and td.within_cumulative_period = 1
2149 union
2150 select
2151 upt.calendar_schedule_id,
2152 upt.block_id,
2153 upt.staff_id,
2154 upt.is_weekend,
2155 upt.raw_target,
2156 upt.target,
2157 upt.scheduled,
2158 upt.other_scheduled,
2159 upt.available_days
2160 from buffer_target_dates as td
2161 inner join unpublished_point_targets as upt
2162 on td.calendar_schedule_id = upt.calendar_schedule_id
2163 and td.block_id = upt.block_id
2164 where td.session_id = 1458117728
2165 and td.build_point_targets = 0
2166 and td.point_targets_source = 'unpublished'
2167 and td.within_cumulative_period = 1
2168 order by null
2169 ) as t
2170 group by
2171 t.staff_id,
2172 t.is_weekend,
2173 t.calendar_schedule_id
2174 order by null
2175
2176Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0702 - 136.902ms
2177Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets0703 - 0.11699999999999999ms
2178 (132.2ms) /* CurrentPointTargetsRule, CurrentWeeklyPointTargetsRule, CumulativePointTargetsRule, CumulativeWeeklyPointTargetsRule */
2179 insert into buffer_point_targets_1458117728 (
2180 calendar_schedule_id,
2181 block_id,
2182 staff_id,
2183 is_weekend,
2184 raw_target,
2185 target,
2186 scheduled,
2187 other_scheduled,
2188 available_days,
2189 initial_target
2190 )
2191 select
2192 pt.calendar_schedule_id,
2193 pt.block_id,
2194 pt.staff_id,
2195 pt.is_weekend,
2196 pt.raw_target,
2197 pt.target,
2198 pt.scheduled,
2199 pt.other_scheduled,
2200 pt.available_days,
2201 pt.initial_target
2202 from buffer_target_dates as td
2203 inner join point_targets as pt
2204 on td.calendar_schedule_id = pt.calendar_schedule_id
2205 and td.block_id = pt.block_id
2206 where td.session_id = 1458117728
2207 and td.build_point_targets = 0
2208 and td.point_targets_source = 'published'
2209 and td.affected_by_populate = 1
2210 union
2211 select
2212 upt.calendar_schedule_id,
2213 upt.block_id,
2214 upt.staff_id,
2215 upt.is_weekend,
2216 upt.raw_target,
2217 upt.target,
2218 upt.scheduled,
2219 upt.other_scheduled,
2220 upt.available_days,
2221 upt.initial_target
2222 from buffer_target_dates as td
2223 inner join unpublished_point_targets as upt
2224 on td.calendar_schedule_id = upt.calendar_schedule_id
2225 and td.block_id = upt.block_id
2226 where td.session_id = 1458117728
2227 and td.build_point_targets = 0
2228 and td.point_targets_source = 'unpublished'
2229 and td.affected_by_populate = 1
2230 order by null
2231
2232Execution Logger: Scheduler::AutoPopulate::Queries::Targets::Targets07Reports - 132.73ms
2233INFO : (04-06 20:53:36) --> fill: 7 - Scheduler::AutoPopulate::Queries::Query013
2234 (154.1ms) insert into buffer_counter_increments_1458117728 (
2235 schedule_id,
2236 calls,
2237 points,
2238 hours,
2239 affects_cumulative_targets
2240 )
2241 select
2242 sc.id as schedule_id,
2243 case
2244 when (ct.included_in_targets > 0) then 1
2245 else 0
2246 end as calls,
2247 coalesce(
2248 case
2249 when (hl.observed_date is null or dp.point is not null) then dp.point
2250 else dp_2.point
2251 end,
2252 0.0
2253 ) as points,
2254 ct.hours,
2255 case
2256 when (b.display_order between (t1.timeframe_ending - (4 /* cumulative targets period */ - 1)) and t1.timeframe_ending) then 1
2257 else 0
2258 end as affects_cumulative_targets
2259 from
2260 buffer_schedules_1458117728 as sc
2261 inner join (
2262 select
2263 id,
2264 included_in_targets,
2265 coalesce(
2266 timestampdiff(
2267 minute,
2268 concat('1900-01-01 ', maketime(start_time_hour, start_time_minute, 0)),
2269 concat(
2270 '1900-01-0',
2271 case
2272 when ((
2273 start_time_hour | start_time_minute | end_time_hour | end_time_minute > 0
2274 )
2275 and (
2276 timediff(
2277 maketime(end_time_hour, end_time_minute, 0),
2278 maketime(start_time_hour, start_time_minute, 0)
2279 ) <= 0
2280 )
2281 ) then '2'
2282 else '1'
2283 end,
2284 ' ',
2285 maketime(end_time_hour, end_time_minute, 0)
2286 )
2287 ) / 60,
2288 0.0
2289 ) as hours
2290 from call_types
2291 where
2292 client_id = 6
2293 and active = 1
2294 order by null
2295 ) as ct
2296 on sc.call_type_id = ct.id
2297 inner join blocks as b
2298 on sc.block_id = b.id
2299 inner join (
2300 select
2301 calendar_schedule_id,
2302 max(
2303 case
2304 when (should_be_populated = 1) then end_block_display_order
2305 else null
2306 end
2307 ) as timeframe_ending
2308 from buffer_periods_1458117728
2309 group by calendar_schedule_id
2310 order by null
2311 ) as t1
2312 on sc.calendar_schedule_id = t1.calendar_schedule_id
2313 left join (
2314 select
2315 hd.observed_date,
2316 case
2317 when (hd.observed_date > hd.extended_date) then hd.extended_date
2318 else hd.observed_date
2319 end as date_from,
2320 case
2321 when (hd.observed_date < hd.extended_date) then hd.extended_date
2322 else hd.observed_date
2323 end as date_to
2324 from
2325 holidays as h
2326 inner join holiday_dates as hd
2327 on h.id = hd.holiday_id
2328 inner join (
2329 select
2330 year(min(schedule_on)) as year_from,
2331 year(max(schedule_on)) as year_to
2332 from buffer_schedules/* session_id */
2333 where should_be_evaluated = 1
2334 ) as y
2335 on hd.year between y.year_from and y.year_to
2336 where
2337 h.client_id = 6
2338 and (
2339 h.observed = 1
2340 or h.extended = 1
2341 )
2342 order by null
2343 ) as hl
2344 on sc.schedule_on between hl.date_from and hl.date_to
2345 left join assignment_annotations as aa
2346 on ct.id = aa.assignmentable_id
2347 and aa.assignmentable_type = 'CallType'
2348 and aa.annotation_id = 0 /* annotation = "None" */
2349 and aa.applicable = 1
2350 left join assignment_annotation_daily_points as dp
2351 on aa.id = dp.assignment_annotation_id
2352 and case
2353 when (hl.observed_date is null) then (dayofweek(sc.schedule_on) - 1)
2354 when (sc.schedule_on = hl.observed_date) then 7
2355 else 8
2356 end = dp.day
2357 left join assignment_annotation_daily_points as dp_2
2358 on aa.id = dp_2.assignment_annotation_id
2359 and (dayofweek(sc.schedule_on) - 1) = dp_2.day
2360 where sc.should_be_evaluated = 1
2361 order by null
2362
2363INFO : (04-06 20:53:36) --> fill: 8 - Scheduler::AutoPopulate::Queries::Query014
2364 (132.3ms) -- Prepare the information about the blocks we're populating and the linkage patterns which will be used on those blocks
2365 insert into buffer_linkage_patterns_1458117728 (
2366 period_offset,
2367 calendar_schedule_id,
2368 block_id,
2369 block_start_date,
2370 block_start_dow,
2371 block_length,
2372 linkage_pattern_id,
2373 pattern_start_dow,
2374 days_before_start,
2375 pattern_length,
2376 start_offset,
2377 iterations_count
2378 )
2379 select
2380 b1.period_offset,
2381 b1.calendar_schedule_id,
2382 b1.block_id,
2383 b2.start_date as block_start_date,
2384 dayofweek(b2.start_date) as block_start_dow,
2385 (datediff(b2.end_date, b2.start_date) + 1) as block_length,
2386 lp.id as linkage_pattern_id,
2387 (lp.start_on + 1) as pattern_start_dow,
2388 lp.days_before_start,
2389 (lp.length * 7) as pattern_length,
2390 null as start_offset,
2391 null as iterations_count
2392 from (
2393 select
2394 calendar_schedule_id,
2395 block_id,
2396 period_offset
2397 from buffer_schedules_1458117728
2398 group by
2399 calendar_schedule_id,
2400 block_id,
2401 period_offset
2402 order by null
2403 ) as b1
2404 inner join blocks as b2
2405 on b1.block_id = b2.id
2406 inner join linkage_patterns as lp
2407 on lp.client_id = 6
2408 and b1.calendar_schedule_id = lp.calendar_schedule_id
2409 order by null
2410
2411 (134.6ms) -- Calculate the basic offset ("+" or "-") that will be applied to a linkage pattern if a block and a pattern are starting on different day of week
2412 update buffer_linkage_patterns_1458117728
2413 set start_offset = if(
2414 (pattern_start_dow + (case when (pattern_start_dow < block_start_dow) then 7 else 0 end) - block_start_dow) <= days_before_start,
2415 (pattern_start_dow + (case when (pattern_start_dow < block_start_dow) then 7 else 0 end) - block_start_dow),
2416 (block_start_dow + (case when (block_start_dow < pattern_start_dow) then 7 else 0 end) - pattern_start_dow) * (-1)
2417 )
2418
2419 (134.2ms) -- In some cases (when a block and a pattern are starting on different day of week or when a pattern is shorter than a block)
2420 -- a pattern should be repeated couple of times (in order to cover the entire block)
2421 update buffer_linkage_patterns_1458117728
2422 set iterations_count =
2423 ceiling(
2424 (
2425 block_length +
2426 case
2427 when (start_offset < 0) then abs(start_offset)
2428 else 0
2429 end
2430 ) * 1.0 / pattern_length
2431 )
2432
2433 (132.5ms) -- Generate an assignments sequence for every linkage pattern
2434 insert into buffer_schedules_linkage_patterns_1458117728 (
2435 call_type_id,
2436 staff_id,
2437 schedule_on,
2438 period_offset,
2439 day_of_week_mask,
2440 display_order,
2441 week_number,
2442 should_be_evaluated,
2443 should_be_populated,
2444 linkage_instance_id,
2445 block_id,
2446 calendar_schedule_id
2447 )
2448 select
2449 lps.assignment_id as call_type_id,
2450 null as staff_id,
2451 case
2452 when (lp.start_offset < 0)
2453 then date_add(lp.block_start_date, interval (lp.start_offset + ns.item_number * lp.pattern_length + lps.offset) day)
2454 else
2455 date_add(lp.block_start_date, interval ((lp.start_offset + ns.item_number * lp.pattern_length + lps.offset) mod lp.block_length) day)
2456 end as schedule_on,
2457 lp.period_offset,
2458 null as day_of_week_mask,
2459 null as display_order,
2460 null as week_number,
2461 0 as should_be_evaluated,
2462 0 as should_be_populated,
2463 lp.linkage_pattern_id as linkage_instance_id,
2464 lp.block_id,
2465 lp.calendar_schedule_id
2466 from
2467 numeric_sequence as ns
2468 inner join buffer_linkage_patterns_1458117728 as lp
2469 on ns.item_number <= (lp.iterations_count - 1)
2470 inner join linkage_pattern_slots as lps
2471 on lp.linkage_pattern_id = lps.linkage_pattern_id
2472 and lps.assignment_type = 'CallType'
2473 where
2474 case
2475 when (lp.start_offset < 0)
2476 then (lp.start_offset + ns.item_number * lp.pattern_length + lps.offset)
2477 else
2478 (ns.item_number * lp.pattern_length + lps.offset)
2479 end between 0 and (lp.block_length - 1)
2480 order by null
2481
2482 (132.0ms) -- Fill the columns that we left blank in the previous "INSERT"
2483 update
2484 buffer_schedules_linkage_patterns_1458117728 as slp
2485 inner join clients as cl
2486 on cl.id = 6
2487 inner join call_types as ct
2488 on slp.call_type_id = ct.id
2489 left join buffer_schedules_1458117728 as bs
2490 on slp.schedule_on = bs.schedule_on
2491 and slp.call_type_id = bs.call_type_id
2492 set
2493 slp.day_of_week_mask = (1 << (dayofweek(slp.schedule_on) - 1)),
2494 slp.display_order = ct.display_order,
2495 slp.week_number =
2496 yearweek(
2497 slp.schedule_on,
2498 case
2499 when (cl.start_of_week = 0) then 2
2500 else 7
2501 end
2502 ),
2503 slp.should_be_evaluated = coalesce(bs.should_be_evaluated, 0),
2504 slp.should_be_populated = coalesce(bs.should_be_populated, 0);
2505
2506 (136.5ms) -- Delete linkage patterns that don't have intersection with assignments we should auto-populate
2507 delete slp_1
2508 from
2509 buffer_schedules_linkage_patterns_1458117728 as slp_1
2510 inner join (
2511 select linkage_instance_id
2512 from buffer_schedules_linkage_patterns_1458117728
2513 group by linkage_instance_id
2514 having
2515 max(should_be_evaluated) = 0
2516 and max(should_be_populated) = 0
2517 order by null
2518 ) as slp_2
2519 on slp_1.linkage_instance_id = slp_2.linkage_instance_id
2520
2521 (131.5ms) -- Use a linkage pattern ID instead of linkage instance ID for those assignments that intersect with linkage patterns
2522 update
2523 buffer_schedules_linkage_patterns_1458117728 as slp
2524 inner join buffer_schedules_1458117728 as bs_1
2525 on slp.schedule_on = bs_1.schedule_on
2526 and slp.call_type_id = bs_1.call_type_id
2527 inner join buffer_schedules_1458117728 as bs_2
2528 on bs_1.linkage_instance_id = bs_2.linkage_instance_id
2529 set bs_2.linkage_instance_id = slp.linkage_instance_id
2530
2531 (131.8ms) -- Linkage pattern slots that don't have intersection with auto-populate assignments but are a part of a pattern that has such intersection
2532 -- should be copied over to the buffer schedules table (used during the auto-populate process)
2533 insert into buffer_schedules_1458117728 (
2534 call_type_id,
2535 staff_id,
2536 schedule_on,
2537 period_offset,
2538 day_of_week_mask,
2539 is_weekend,
2540 display_order,
2541 week_number,
2542 should_be_evaluated,
2543 should_be_populated,
2544 linkage_instance_id,
2545 block_id,
2546 calendar_schedule_id
2547 )
2548 select
2549 call_type_id,
2550 staff_id,
2551 schedule_on,
2552 period_offset,
2553 day_of_week_mask,
2554 case
2555 when (day_of_week_mask & 62 > 0) then 0
2556 else 1
2557 end as is_weekend,
2558 display_order,
2559 week_number,
2560 should_be_evaluated,
2561 should_be_populated,
2562 linkage_instance_id,
2563 block_id,
2564 calendar_schedule_id
2565 from buffer_schedules_linkage_patterns_1458117728
2566 where
2567 should_be_evaluated = 0
2568 and should_be_populated = 0
2569
2570INFO : (04-06 20:53:37) --> fill: 9 - Scheduler::AutoPopulate::Queries::Query015
2571 (133.4ms) insert into buffer_schedules_1458117728 (
2572 call_type_id,
2573 staff_id,
2574 schedule_on,
2575 day_of_week_mask,
2576 is_weekend,
2577 display_order,
2578 should_be_evaluated,
2579 should_be_populated,
2580 linkage_instance_id
2581 )
2582 select distinct
2583 schedules_call_overlap.call_type_id,
2584 schedules_call_overlap.staff_id,
2585 schedules_call_overlap.schedule_on,
2586 (1 << (dayofweek(schedules_call_overlap.schedule_on) - 1)) as day_of_week_mask,
2587 case
2588 when (dayofweek(schedules_call_overlap.schedule_on) between 2 and 6) then 0
2589 else 1
2590 end as is_weekend,
2591 call_types.display_order,
2592 0 as should_be_evaluated,
2593 0 as should_be_populated,
2594 -1 as linkage_instance_id
2595 from (
2596 select schedule_on
2597 from buffer_schedules_1458117728
2598 where should_be_evaluated = 1
2599 group by schedule_on
2600 order by null
2601 ) as buffer_schedules_1
2602 inner join schedules as schedules_call_overlap
2603 on schedules_call_overlap.client_id = 6
2604 and buffer_schedules_1.schedule_on = schedules_call_overlap.schedule_on
2605 left join buffer_schedules_1458117728 as buffer_schedules_2
2606 on schedules_call_overlap.schedule_on = buffer_schedules_2.schedule_on
2607 and schedules_call_overlap.call_type_id = buffer_schedules_2.call_type_id
2608 inner join call_types
2609 on schedules_call_overlap.call_type_id = call_types.id
2610 where buffer_schedules_2.id is null
2611 order by null
2612
2613INFO : (04-06 20:53:37) --> fill: 10 - Scheduler::AutoPopulate::Queries::Query02
2614INFO : (04-06 20:53:37) --> fill: 11 - Scheduler::AutoPopulate::Queries::Query03
2615INFO : (04-06 20:53:37) --> fill: 12 - Scheduler::AutoPopulate::Queries::Query04
2616INFO : (04-06 20:53:37) --> fill: 13 - Scheduler::AutoPopulate::Queries::Query045
2617INFO : (04-06 20:53:37) --> fill: 14 - Scheduler::AutoPopulate::Queries::QueryA
2618 (140.2ms) insert into buffer_schedules_1458117728 (
2619 call_type_id,
2620 staff_id,
2621 schedule_on,
2622 day_of_week_mask,
2623 is_weekend,
2624 display_order,
2625 should_be_evaluated,
2626 should_be_populated,
2627 linkage_instance_id
2628 )
2629 select distinct straight_join
2630 schedules.call_type_id,
2631 schedules.staff_id,
2632 schedules.schedule_on,
2633 (1 << (dayofweek(schedules.schedule_on) - 1)) as day_of_week_mask,
2634 case
2635 when (dayofweek(schedules.schedule_on) between 2 and 6) then 0
2636 else 1
2637 end as is_weekend,
2638 call_types.display_order,
2639 0 as should_be_evaluated,
2640 0 as should_be_populated,
2641 -1 as linkage_instance_id
2642 from
2643 buffer_schedules_1458117728 as buffer_schedules_1
2644 inner join negative_links_influences use index (ix_unique_links)
2645 on buffer_schedules_1.day_of_week_mask = negative_links_influences.day_of_week_mask
2646 and buffer_schedules_1.call_type_id = negative_links_influences.source_id
2647 and negative_links_influences.source_type = 'CallType'
2648 and negative_links_influences.target_type = 'CallType'
2649 inner join schedules use index (ix_schedules_call_date)
2650 on date_add(
2651 buffer_schedules_1.schedule_on,
2652 interval negative_links_influences.offset day
2653 ) = schedules.schedule_on
2654 and negative_links_influences.target_id = schedules.call_type_id
2655 left join buffer_schedules_1458117728 as buffer_schedules_2 use index (ix_buffer_schedules_composite_1)
2656 on schedules.schedule_on = buffer_schedules_2.schedule_on
2657 and schedules.call_type_id = buffer_schedules_2.call_type_id
2658 inner join call_types
2659 on schedules.call_type_id = call_types.id
2660 where
2661 buffer_schedules_1.linkage_instance_id >= 0
2662 and buffer_schedules_1.should_be_evaluated = 1
2663 and buffer_schedules_2.id is null
2664 order by null
2665
2666INFO : (04-06 20:53:38) --> fill: 15 - Scheduler::AutoPopulate::Queries::QueryB
2667 (136.1ms) insert into buffer_schedules_1458117728 (
2668 call_type_id,
2669 staff_id,
2670 schedule_on,
2671 day_of_week_mask,
2672 is_weekend,
2673 display_order,
2674 should_be_evaluated,
2675 should_be_populated,
2676 linkage_instance_id
2677 )
2678 select distinct straight_join
2679 (-1 * negative_links_influences.target_id) as call_type_id,
2680 vacations.staff_id,
2681 vacations.schedule_on,
2682 (1 << (dayofweek(vacations.schedule_on) - 1)) as day_of_week_mask,
2683 vacations.weekend_on as is_weekend,
2684 -1 as display_order,
2685 0 as should_be_evaluated,
2686 0 as should_be_populated,
2687 -1 as linkage_instance_id
2688 from
2689 buffer_schedules_1458117728 as buffer_schedules_1
2690 inner join negative_links_influences use index (ix_unique_links)
2691 on buffer_schedules_1.day_of_week_mask = negative_links_influences.day_of_week_mask
2692 and buffer_schedules_1.call_type_id = negative_links_influences.source_id
2693 and negative_links_influences.source_type = 'CallType'
2694 and negative_links_influences.target_id > 0
2695 and negative_links_influences.target_type in ('Vacation', 'NonClinicalType')
2696 inner join vacations use index (ix_vacations_on_schedule_and_client)
2697 on vacations.client_id = 6 /* client_id */
2698 and date_add(
2699 buffer_schedules_1.schedule_on,
2700 interval negative_links_influences.offset day
2701 ) = vacations.schedule_on
2702 and negative_links_influences.target_id = vacations.non_clinical_type_id
2703 and vacations.status in (3) /* based on the "non-working requests" settings */
2704 left join buffer_schedules_1458117728 as buffer_schedules_2 use index (ix_buffer_schedules_composite_1)
2705 on vacations.staff_id = buffer_schedules_2.staff_id
2706 and vacations.schedule_on = buffer_schedules_2.schedule_on
2707 and (-1 * negative_links_influences.target_id) = buffer_schedules_2.call_type_id
2708 where
2709 buffer_schedules_1.linkage_instance_id >= 0
2710 and buffer_schedules_1.should_be_evaluated = 1
2711 and buffer_schedules_2.id is null
2712 order by null
2713
2714INFO : (04-06 20:53:38) --> fill: 16 - Scheduler::AutoPopulate::Queries::Query05
2715 (135.7ms) insert into buffer_linkages_1458117728 (
2716 linkage_instance_id,
2717 slots_count_total,
2718 has_conflicts
2719 )
2720 select straight_join
2721 schedules.linkage_instance_id,
2722 count(1) as slots_count_total,
2723 if(linkage_conflicts.linkage_template_id is not null, 1, 0) as has_conflicts
2724 from
2725 buffer_schedules_1458117728 as schedules
2726 left join (
2727 select straight_join
2728 linkage_relations.linkage_template_id
2729 from linkage_relations
2730 inner join negative_links_influences use index (ix_unique_links)
2731 on linkage_relations.day_of_week_mask = negative_links_influences.day_of_week_mask
2732 and linkage_relations.call_type_id = negative_links_influences.source_id
2733 and negative_links_influences.source_type = 'CallType'
2734 and linkage_relations.linked_call_type_id = negative_links_influences.target_id
2735 and negative_links_influences.target_type = 'CallType'
2736 and linkage_relations.distance_in_days = negative_links_influences.offset
2737 where linkage_relations.client_id = 6 /* client_id */
2738 and (
2739 linkage_relations.call_type_id != linkage_relations.linked_call_type_id
2740 or linkage_relations.distance_in_days != 0
2741 )
2742 group by linkage_relations.linkage_template_id
2743 order by null
2744 ) as linkage_conflicts
2745 on (schedules.linkage_instance_id div 1000000) = linkage_conflicts.linkage_template_id
2746 where schedules.linkage_instance_id >= 0
2747 group by
2748 schedules.linkage_instance_id,
2749 has_conflicts
2750 order by null
2751
2752INFO : (04-06 20:53:38) --> fill: 17 - Scheduler::AutoPopulate::Queries::Query06
2753 (135.4ms) insert into buffer_target_assignments_1458117728 (
2754 call_type_id,
2755 target_group_id,
2756 assignment_id,
2757 assignment_type
2758 )
2759 select
2760 t1.call_type_id,
2761 ifnull(tg.id, 0) as target_group_id,
2762 if(tg.id is null, t1.call_type_id, tg.id) as assignment_id,
2763 if(tg.id is null, 'CallType', 'TargetGroup') as assignment_type
2764 from (
2765 select ct.id as call_type_id
2766 from
2767 buffer_schedules_1458117728 as sc
2768 inner join call_types as ct
2769 on sc.call_type_id = ct.id
2770 and ct.active = 1
2771 and ct.included_in_targets > 0
2772 where linkage_instance_id >= 0
2773 group by ct.id
2774 order by null
2775 ) as t1
2776 left join target_group_calls as tgc
2777 on t1.call_type_id = tgc.call_type_id
2778 left join target_groups as tg
2779 on tgc.target_group_id = tg.id
2780 and tg.active = 1
2781 order by null
2782
2783INFO : (04-06 20:53:38) --> fill: 18 - Scheduler::AutoPopulate::Queries::Query07
2784INFO : (04-06 20:53:38) --> fill: 19 - Scheduler::AutoPopulate::Queries::Query0702
2785INFO : (04-06 20:53:38) --> fill: 20 - Scheduler::AutoPopulate::Queries::Query0705
2786 (132.4ms) insert into buffer_linkage_call_type_assignments_1458117728 (
2787 linkage_instance_id,
2788 call_type_id,
2789 is_weekend,
2790 period_offset,
2791 calendar_schedule_id,
2792 max_assignments,
2793 assignments_count
2794 )
2795 select
2796 s.linkage_instance_id,
2797 s.call_type_id,
2798 s.is_weekend,
2799 s.period_offset,
2800 s.calendar_schedule_id,
2801 case
2802 when (s.is_weekend = 0) then ct.max_weekday_assignments
2803 else ct.max_weekend_assignments
2804 end as _max_assignments,
2805 sum(1) as assignments_count
2806 from buffer_schedules_1458117728 as s
2807 inner join call_types as ct
2808 on s.call_type_id = ct.id
2809 and ct.active = 1
2810 and (
2811 ct.max_weekday_assignments is not null
2812 or ct.max_weekend_assignments is not null
2813 )
2814 where s.linkage_instance_id >= 0
2815 and s.staff_id is null
2816 group by
2817 s.linkage_instance_id,
2818 s.call_type_id,
2819 s.is_weekend,
2820 s.period_offset,
2821 s.calendar_schedule_id,
2822 _max_assignments
2823 having _max_assignments >= 0
2824 order by null
2825
2826INFO : (04-06 20:53:38) --> fill: 21 - Scheduler::AutoPopulate::Queries::Query0706
2827 (132.9ms) insert into buffer_call_type_assignments_1458117728 (
2828 staff_id,
2829 call_type_id,
2830 is_weekend,
2831 period_offset,
2832 calendar_schedule_id,
2833 assignments_count
2834 )
2835 select
2836 sc.staff_id,
2837 sc.call_type_id,
2838 sc.weekend_on as is_weekend,
2839 p.period_offset,
2840 p.calendar_schedule_id,
2841 sum(1) as assignments_count
2842 from buffer_periods_1458117728 as p
2843 inner join call_types as ct
2844 on p.calendar_schedule_id = ct.calendar_schedule_id
2845 and ct.active = 1
2846 and (
2847 ct.max_weekday_assignments is not null
2848 or ct.max_weekend_assignments is not null
2849 )
2850 inner join schedules as sc
2851 on ct.id = sc.call_type_id
2852 and sc.schedule_on between p.start_date and p.end_date
2853 and sc.staff_id is not null
2854 where p.should_be_evaluated = 1
2855 group by
2856 sc.staff_id,
2857 sc.call_type_id,
2858 sc.weekend_on,
2859 p.period_offset,
2860 p.calendar_schedule_id
2861 order by null
2862
2863INFO : (04-06 20:53:38) --> fill: 22 - Scheduler::AutoPopulate::Queries::Query0707
2864INFO : (04-06 20:53:38) --> fill: 23 - Scheduler::AutoPopulate::Queries::Query0708
2865 (134.8ms) insert into buffer_linkage_assigned_days_1458117728 (
2866 linkage_instance_id,
2867 period_offset,
2868 week_number,
2869 schedule_on,
2870 is_weekend
2871 )
2872 select distinct
2873 sc.linkage_instance_id,
2874 sc.period_offset,
2875 sc.week_number,
2876 sc.schedule_on,
2877 sc.is_weekend
2878 from
2879 buffer_schedules_1458117728 as sc
2880 inner join call_types as ct
2881 on sc.call_type_id = ct.id
2882 and ct.unassigned_day = 0
2883 where
2884 sc.linkage_instance_id >= 0
2885 and sc.staff_id is null
2886 order by null
2887
2888INFO : (04-06 20:53:38) --> fill: 24 - Scheduler::AutoPopulate::Queries::Query0709
2889INFO : (04-06 20:53:38) --> fill: 25 - Scheduler::AutoPopulate::Queries::Query07_10_AL
2890 (133.6ms) /* AssignmentLimitsPerPeriod, AssignmentLimitsPerWeek, AssignmentLimitsRolling, AssignmentLimitsConsecutive */
2891 insert into buffer_assignment_limit_call_types_1458117728 (
2892 assignment_limit_id, call_type_id
2893 )
2894 select al.id as assignment_limit_id, ct.id as call_type_id
2895 from assignment_limits as al
2896 inner join assignment_limit_call_types as alct
2897 on al.id = alct.assignment_limit_id
2898 inner join call_types as ct
2899 on alct.call_type_id = ct.id
2900 and ct.active = 1
2901 where al.client_id = 6
2902 and al.active = 1
2903 union
2904 select al.id as assignment_limit_id, ct.id as call_type_id
2905 from assignment_limits as al
2906 inner join call_types as ct
2907 on al.client_id = ct.client_id
2908 and al.calendar_schedule_id = ct.calendar_schedule_id
2909 and ct.active = 1
2910 where al.client_id = 6
2911 and al.active = 1
2912 and al.all_current_schedule_assignments = 1
2913 union
2914 select al.id as assignment_limit_id, ct.id as call_type_id
2915 from assignment_limits as al
2916 inner join call_types as ct
2917 on al.client_id = ct.client_id
2918 and al.calendar_schedule_id != ct.calendar_schedule_id
2919 and ct.active = 1
2920 where al.client_id = 6
2921 and al.active = 1
2922 and al.all_other_schedule_assignments = 1
2923 order by null
2924
2925 (133.9ms) /* AssignmentLimitsPerPeriod, AssignmentLimitsPerWeek, AssignmentLimitsRolling, AssignmentLimitsConsecutive */
2926 insert into buffer_assignment_limit_staff_types_1458117728 (
2927 assignment_limit_id, staff_type_id
2928 )
2929 select al.id as assignment_limit_id, st.id as staff_type_id
2930 from assignment_limits as al
2931 inner join assignment_limit_staff_types as alst
2932 on al.id = alst.assignment_limit_id
2933 inner join staff_types as st
2934 on alst.staff_type_id = st.id
2935 and st.active = 1
2936 where al.client_id = 6
2937 and al.active = 1
2938 union
2939 select al.id as assignment_limit_id, st.id as staff_type_id
2940 from assignment_limits as al
2941 inner join staff_types as st
2942 on al.client_id = st.client_id
2943 and st.active = 1
2944 where al.client_id = 6
2945 and al.active = 1
2946 and al.all_staff_types = 1
2947 order by null
2948
2949INFO : (04-06 20:53:39) --> fill: 26 - Scheduler::AutoPopulate::Queries::Query07_10_AL_01
2950 (133.0ms) /* AssignmentLimitsPerPeriod */
2951 insert into buffer_assignment_limit_periods_1458117728 (
2952 assignment_limit_id, period_id, start_date, end_date
2953 )
2954 select
2955 al.id as assignment_limit_id,
2956 if(
2957 bs.blocks_type = 0,
2958 if(
2959 (month(b.start_date) - pt.begin_period) >= 0,
2960 year(b.start_date) * 100 + (month(b.start_date) - pt.begin_period) div pt.timeframe_type + 1,
2961 (year(b.start_date) - 1) * 100 + (month(b.start_date) + 12 - pt.begin_period) div pt.timeframe_type + 1
2962 ),
2963 b.display_order
2964 ) as period_id,
2965 min(b.start_date) as start_date,
2966 max(b.end_date) as end_date
2967 from assignment_limits as al
2968 inner join calendar_schedules as cs
2969 on al.calendar_schedule_id = cs.id
2970 inner join block_schedules as bs
2971 on cs.block_schedule_id = bs.id
2972 inner join blocks as b
2973 on bs.id = b.block_schedule_id
2974 and b.end_date >= date_add(now(), interval -24 month)
2975 inner join population_timeframes as pt
2976 on pt.client_id = 6
2977 and al.timeframe_type = pt.timeframe_type
2978 where al.client_id = 6
2979 and al.active = 1
2980 and al.max_per_period_limit is not null
2981 group by al.id, period_id
2982 order by null
2983
2984 (132.1ms) /* AssignmentLimitsPerPeriod */
2985 insert into buffer_linkage_assignments_count_periods_1458117728 (
2986 linkage_instance_id, assignment_limit_id, schedule_on, start_date, end_date, assignments_count
2987 )
2988 select sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on, alp.start_date, alp.end_date,
2989 count(distinct sc.id) as assignments_count
2990 from buffer_schedules_1458117728 as sc
2991 inner join buffer_assignment_limit_call_types_1458117728 as alct
2992 on sc.call_type_id = alct.call_type_id
2993 inner join assignment_limits as al
2994 on alct.assignment_limit_id = al.id
2995 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
2996 and al.max_per_period_limit is not null
2997 inner join buffer_assignment_limit_periods_1458117728 as alp
2998 on alct.assignment_limit_id = alp.assignment_limit_id
2999 and sc.schedule_on between alp.start_date and alp.end_date
3000 where sc.linkage_instance_id >= 0
3001 and sc.staff_id is null
3002 group by sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on, alp.start_date, alp.end_date
3003 order by null
3004
3005INFO : (04-06 20:53:39) --> fill: 27 - Scheduler::AutoPopulate::Queries::Query07_10_AL_02
3006 (132.3ms) /* AssignmentLimitsPerWeek */
3007 insert into buffer_linkage_assignments_count_weeks_1458117728 (
3008 linkage_instance_id, assignment_limit_id, schedule_on, start_date, end_date, assignments_count
3009 )
3010 select sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on,
3011 if(
3012 cl.start_of_week = 0,
3013 date_add(sc.schedule_on, interval (1 - dayofweek(sc.schedule_on)) day),
3014 date_add(sc.schedule_on, interval (0 - weekday(sc.schedule_on)) day)
3015 ) as start_date,
3016 if(
3017 cl.start_of_week = 0,
3018 date_add(sc.schedule_on, interval (7 - dayofweek(sc.schedule_on)) day),
3019 date_add(sc.schedule_on, interval (6 - weekday(sc.schedule_on)) day)
3020 ) as end_date,
3021 count(distinct sc.id) as assignments_count
3022 from buffer_schedules_1458117728 as sc
3023 inner join buffer_assignment_limit_call_types_1458117728 as alct
3024 on sc.call_type_id = alct.call_type_id
3025 inner join assignment_limits as al
3026 on alct.assignment_limit_id = al.id
3027 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
3028 and al.max_weekly_limit is not null
3029 inner join clients as cl
3030 on cl.id = 6
3031 where sc.linkage_instance_id >= 0
3032 and sc.staff_id is null
3033 group by sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on, start_date, end_date
3034 order by null
3035
3036INFO : (04-06 20:53:39) --> fill: 28 - Scheduler::AutoPopulate::Queries::Query07_10_AL_03
3037 (134.9ms) /* AssignmentLimitsRolling */
3038 insert into buffer_linkage_assignments_count_rolling_1458117728 (
3039 linkage_instance_id, assignment_limit_id, schedule_on, start_date, end_date, assignments_count
3040 )
3041 select sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on,
3042 date_add(sc.schedule_on, interval (1 - ns.item_number) day) as start_date,
3043 date_add(sc.schedule_on, interval (al.max_rolling_period - ns.item_number) day) as end_date,
3044 count(distinct sc.id) as assignments_count
3045 from buffer_schedules_1458117728 as sc
3046 inner join buffer_assignment_limit_call_types_1458117728 as alct
3047 on sc.call_type_id = alct.call_type_id
3048 inner join assignment_limits as al
3049 on alct.assignment_limit_id = al.id
3050 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
3051 and al.max_rolling_period is not null
3052 and al.max_rolling_limit is not null
3053 inner join numeric_sequence as ns
3054 on ns.item_number between 1 and al.max_rolling_period
3055 where sc.linkage_instance_id >= 0
3056 and sc.staff_id is null
3057 group by sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on, start_date, end_date
3058 order by null
3059
3060INFO : (04-06 20:53:39) --> fill: 29 - Scheduler::AutoPopulate::Queries::Query07_10_AL_04
3061 (131.9ms) /* AssignmentLimitsConsecutive */
3062 insert into buffer_linkage_assignments_count_consecutive_1458117728 (
3063 linkage_instance_id, assignment_limit_id, schedule_on, start_date, end_date
3064 )
3065 select sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on,
3066 date_add(sc.schedule_on, interval (1 - ns.item_number) day) as start_date,
3067 date_add(sc.schedule_on, interval ((al.max_consecutive_limit + 1) - ns.item_number) day) as end_date
3068 from buffer_schedules_1458117728 as sc
3069 inner join buffer_assignment_limit_call_types_1458117728 as alct
3070 on sc.call_type_id = alct.call_type_id
3071 inner join assignment_limits as al
3072 on alct.assignment_limit_id = al.id
3073 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
3074 and al.max_consecutive_limit is not null
3075 inner join numeric_sequence as ns
3076 on ns.item_number between 1 and (al.max_consecutive_limit + 1)
3077 where sc.linkage_instance_id >= 0
3078 and sc.staff_id is null
3079 group by sc.linkage_instance_id, alct.assignment_limit_id, sc.schedule_on, start_date, end_date
3080 order by null
3081
3082INFO : (04-06 20:53:39) --> fill: 30 - Scheduler::AutoPopulate::Queries::Query08
3083 (132.2ms) insert into buffer_staff_daily_counts_1458117728 (
3084 staff_id, schedule_on, linkage_instance_id, slots_count
3085 )
3086 select staff_id, schedule_on, null as linkage_instance_id,
3087 count(1) as slots_count
3088 from buffer_schedules_1458117728
3089 where staff_id is not null
3090 and call_type_id > 0 /* VC */
3091 group by staff_id, schedule_on
3092 order by null
3093
3094 (132.1ms) insert into buffer_staff_daily_counts_1458117728 (
3095 staff_id, schedule_on, linkage_instance_id, slots_count
3096 )
3097 select staff_id, schedule_on, linkage_instance_id,
3098 count(1) as slots_count
3099 from buffer_schedules_1458117728
3100 where staff_id is not null
3101 and call_type_id > 0 /* VC */
3102 group by staff_id, schedule_on, linkage_instance_id
3103 order by null
3104
3105INFO : (04-06 20:53:40) --> fill: 31 - Scheduler::AutoPopulate::Queries::Query085
3106 (255.8ms) insert into buffer_staff_specializations_1458117728 (
3107 staff_id, specialization_id
3108 )
3109 select staff_id, specialization_id
3110 from view_staff_specializations
3111 where client_id = 6
3112 order by null
3113
3114 (132.8ms) insert into buffer_specialization_daily_counts_1458117728 (
3115 specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
3116 )
3117 select sp.id as specialization_id,
3118 null as staff_id,
3119 bs_1.schedule_on,
3120 count(distinct st_sp.staff_id) as staffs_scheduled,
3121 sp.max_scheduled,
3122 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
3123 from (
3124 select schedule_on, day_of_week_mask
3125 from buffer_schedules_1458117728
3126 where should_be_evaluated = 1
3127 group by schedule_on, day_of_week_mask
3128 order by null
3129 ) as bs_1
3130 inner join specializations as sp
3131 on sp.client_id = 6
3132 and sp.active = 1
3133 inner join buffer_schedules_1458117728 as bs_2
3134 on bs_1.schedule_on = bs_2.schedule_on
3135 and bs_2.call_type_id > 0 /* is not VC */
3136 inner join max_applicable_call_types as mact
3137 on sp.id = mact.specialization_id
3138 and bs_2.call_type_id = mact.call_type_id
3139 left join buffer_staff_specializations_1458117728 as st_sp
3140 on bs_2.staff_id = st_sp.staff_id
3141 and sp.id = st_sp.specialization_id
3142 group by sp.id, bs_1.schedule_on, sp.max_scheduled
3143 order by null
3144
3145 (132.2ms) insert into buffer_specialization_daily_counts_1458117728 (
3146 specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
3147 )
3148 select sp.id as specialization_id,
3149 st_sp.staff_id,
3150 bs_1.schedule_on,
3151 1 as staffs_scheduled,
3152 sp.max_scheduled,
3153 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
3154 from (
3155 select schedule_on, day_of_week_mask
3156 from buffer_schedules_1458117728
3157 where should_be_evaluated = 1
3158 group by schedule_on, day_of_week_mask
3159 order by null
3160 ) as bs_1
3161 inner join specializations as sp
3162 on sp.client_id = 6
3163 and sp.active = 1
3164 inner join buffer_schedules_1458117728 as bs_2
3165 on bs_1.schedule_on = bs_2.schedule_on
3166 and bs_2.call_type_id > 0 /* is not VC */
3167 inner join max_applicable_call_types as mact
3168 on sp.id = mact.specialization_id
3169 and bs_2.call_type_id = mact.call_type_id
3170 inner join buffer_staff_specializations_1458117728 as st_sp
3171 on bs_2.staff_id = st_sp.staff_id
3172 and sp.id = st_sp.specialization_id
3173 group by sp.id, st_sp.staff_id, bs_1.schedule_on, sp.max_scheduled
3174 order by null
3175
3176INFO : (04-06 20:53:40) --> fill: 32 - Scheduler::AutoPopulate::Queries::Query09
3177 (133.8ms) truncate table buffer_location_privileges_1458117728
3178
3179 (172.0ms) insert into buffer_location_privileges_1458117728 (
3180 staff_id,
3181 location_id,
3182 begin_date,
3183 end_date
3184 )
3185 select
3186 s.id as staff_id,
3187 l.location_id,
3188 '0000-00-00' as begin_date,
3189 '9999-12-31' as end_date
3190 from (
3191 select l.id as location_id
3192 from
3193 buffer_schedules_1458117728 as sc
3194 inner join call_types as ct
3195 on sc.call_type_id = ct.id
3196 and ct.active = 1
3197 inner join locations as l
3198 on ct.location_id = l.id
3199 and l.active = 1
3200 where sc.linkage_instance_id >= 0
3201 and sc.should_be_evaluated = 1
3202 group by l.id
3203 order by null
3204 ) as l
3205 inner join staffs as s
3206 on s.client_id = 6
3207 and s.active = 1
3208 and s.take_call = 1
3209 and s.auto_populatable = 1
3210 left join location_privileges as lp
3211 on s.id = lp.staff_id
3212 where lp.id is null
3213 union
3214 select
3215 lp.staff_id,
3216 lp.location_id,
3217 lp.begin_date,
3218 lp.end_date
3219 from (
3220 select l.id as location_id
3221 from
3222 buffer_schedules_1458117728 as sc
3223 inner join call_types as ct
3224 on sc.call_type_id = ct.id
3225 and ct.active = 1
3226 inner join locations as l
3227 on ct.location_id = l.id
3228 and l.active = 1
3229 where sc.linkage_instance_id >= 0
3230 and sc.should_be_evaluated = 1
3231 group by l.id
3232 order by null
3233 ) as l
3234 inner join location_privileges as lp
3235 on l.location_id = lp.location_id
3236 order by null;
3237
3238 (2930.1ms) insert into buffer_static_availabilities_1458117728 (
3239 schedule_id,
3240 staff_id,
3241 staff_type_id,
3242 is_primary
3243 )
3244 select
3245 schedules.id as schedule_id,
3246 staffs.id as staff_id,
3247 assign_staff_types.staff_type_id,
3248 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
3249 from
3250 buffer_schedules_1458117728 as schedules
3251 /* AvailabilityRule */
3252 inner join call_types
3253 on schedules.call_type_id = call_types.id
3254 and call_types.active = 1
3255 and schedules.day_of_week_mask & call_types.days_of_week_mask > 0
3256 inner join staff_call_types
3257 on call_types.id = staff_call_types.call_type_id
3258 and schedules.day_of_week_mask & (staff_call_types.days_of_week_mask | staff_call_types.secondary_availability_days_of_week_mask) > 0
3259 inner join staffs
3260 on staff_call_types.staff_id = staffs.id
3261 and staffs.active = 1
3262 and staffs.take_call = 1
3263 and staffs.auto_populatable = 1
3264 inner join buffer_location_privileges_1458117728 as location_privileges
3265 on staffs.id = location_privileges.staff_id
3266 and call_types.location_id = location_privileges.location_id
3267 and schedules.schedule_on between location_privileges.begin_date and ifnull(location_privileges.end_date, '9999-12-31')
3268 inner join assign_staff_types
3269 on staffs.id = assign_staff_types.staff_id
3270 and schedules.schedule_on between assign_staff_types.begin_date and ifnull(assign_staff_types.end_date, '9999-12-31')
3271 left join eligible_staff_types
3272 on staff_call_types.call_type_id = eligible_staff_types.call_type_id
3273 and assign_staff_types.staff_type_id = eligible_staff_types.staff_type_id
3274 left join staff_rotations
3275 on staffs.id = staff_rotations.staff_id
3276 and schedules.schedule_on between staff_rotations.start_date and staff_rotations.end_date
3277 left join daily_rotations
3278 on staffs.id = daily_rotations.staff_id
3279 and schedules.schedule_on = daily_rotations.schedule_on
3280 left join rotations
3281 on rotations.id = ifnull(daily_rotations.rotation_id, staff_rotations.rotation_id)
3282 and rotations.active = 1
3283 left join rotation_call_types
3284 on rotations.id = rotation_call_types.rotation_id
3285 and staff_call_types.call_type_id = rotation_call_types.call_type_id
3286 and schedules.day_of_week_mask & (rotation_call_types.days_of_week_mask | rotation_call_types.secondary_availability_days_of_week_mask) > 0
3287 /* RequiredRotationsRule */
3288 left join required_rotations
3289 on staff_call_types.call_type_id = required_rotations.call_type_id
3290 left join staff_rotations as staff_rotations2
3291 on staffs.id = staff_rotations2.staff_id
3292 and required_rotations.rotation_id = staff_rotations2.rotation_id
3293 and schedules.schedule_on >= staff_rotations2.start_date
3294 /* NoCallRequestsHiddenHardRule */
3295 left join request_settings
3296 on assign_staff_types.staff_type_id = request_settings.staff_type_id
3297 left join requests
3298 on schedules.schedule_on = requests.schedule_on
3299 and staffs.id = requests.staff_id
3300 and requests.request_type = 0 /* type = no_call */
3301 and requests.status in (1, 3) /* status = approved or fulfilled */
3302 and call_types.is_no_call_requestable = 1
3303 left join request_call_types
3304 on requests.id = request_call_types.request_id
3305 and schedules.call_type_id = request_call_types.call_type_id
3306 where
3307 schedules.linkage_instance_id >= 0
3308 and schedules.should_be_evaluated = 1
3309 and (
3310 call_types.all_staff_types = 1
3311 or eligible_staff_types.id is not null
3312 )
3313 and (
3314 rotations.id is null
3315 or rotation_call_types.id is not null
3316 )
3317 and (
3318 requests.id is null
3319 or (
3320 requests.all_call_types = 1
3321 and request_settings.call_only_all_call_switch = 1 /* calls only */
3322 and call_types.assignment_type = 1 /* clinical */
3323 )
3324 or (
3325 requests.all_call_types = 0
3326 and request_call_types.id is null
3327 )
3328 )
3329 group by
3330 schedules.id,
3331 staffs.id,
3332 assign_staff_types.staff_type_id,
3333 is_primary
3334 having
3335 sum(if(required_rotations.id is not null and staff_rotations2.id is null, 1, 0)) = 0 /* RequiredRotationsRule */
3336 and is_primary IN (0,1) /* PrimaryAvailabilityRule */
3337 order by null
3338
3339INFO : (04-06 20:53:43) --> fill: 33 - Scheduler::AutoPopulate::Queries::Query092
3340 (137.1ms) /* RotationPostCallRule */
3341 /* Exclude people and slots when a post-call is not allowed on the first day of a rotation */
3342 delete sa
3343 from buffer_static_availabilities_1458117728 as sa
3344 inner join buffer_schedules_1458117728 as sc
3345 on sa.schedule_id = sc.id
3346 inner join call_types as ct
3347 on sc.call_type_id = ct.id
3348 and ct.assignment_type = 0 /* call */
3349 inner join staff_rotations as sr
3350 on sa.staff_id = sr.staff_id
3351 and date_add(sc.schedule_on, interval 1 day) = sr.start_date
3352 inner join rotations as r
3353 on sr.rotation_id = r.id
3354 and r.post_call_allowed = 0
3355
3356INFO : (04-06 20:53:43) --> fill: 34 - Scheduler::AutoPopulate::Queries::Query093
3357INFO : (04-06 20:53:43) --> fill: 35 - Scheduler::AutoPopulate::Queries::Query095
3358 (140.1ms) insert into buffer_negative_relations_1458117728 (
3359 schedule_id,
3360 affected_by_schedule_id,
3361 staff_id
3362 )
3363 select
3364 b_schedules.id as schedule_id,
3365 b_schedules_negative_link.id as affected_by_schedule_id,
3366 b_schedules_negative_link.staff_id
3367 from
3368 buffer_schedules_1458117728 as b_schedules
3369 /* NegativeLinkRule */
3370 inner join negative_links_influences
3371 on b_schedules.day_of_week_mask = negative_links_influences.day_of_week_mask
3372 and b_schedules.call_type_id = negative_links_influences.source_id
3373 and negative_links_influences.source_type = 'CallType'
3374 and negative_links_influences.target_type = 'CallType'
3375 inner join buffer_schedules_1458117728 as b_schedules_negative_link
3376 on date_add(
3377 b_schedules.schedule_on,
3378 interval negative_links_influences.offset day
3379 ) = b_schedules_negative_link.schedule_on
3380 and negative_links_influences.target_id = b_schedules_negative_link.call_type_id
3381 and b_schedules.id != b_schedules_negative_link.id
3382 where
3383 b_schedules.linkage_instance_id >= 0
3384 and b_schedules.should_be_evaluated = 1
3385 order by null
3386
3387 (136.2ms) insert into buffer_negative_relations_1458117728 (
3388 schedule_id,
3389 affected_by_schedule_id,
3390 staff_id
3391 )
3392 select
3393 b_schedules.id as schedule_id,
3394 b_schedules_negative_link.id as affected_by_schedule_id,
3395 b_schedules_negative_link.staff_id
3396 from
3397 buffer_schedules_1458117728 as b_schedules
3398 /* NegativeLinkRule */
3399 inner join negative_links_influences
3400 on b_schedules.day_of_week_mask = negative_links_influences.day_of_week_mask
3401 and b_schedules.call_type_id = negative_links_influences.source_id
3402 and negative_links_influences.source_type = 'CallType'
3403 and negative_links_influences.target_type in ('Vacation', 'NonClinicalType')
3404 inner join buffer_schedules_1458117728 as b_schedules_negative_link
3405 on date_add(
3406 b_schedules.schedule_on,
3407 interval negative_links_influences.offset day
3408 ) = b_schedules_negative_link.schedule_on
3409 and (-1 * negative_links_influences.target_id) = b_schedules_negative_link.call_type_id
3410 and b_schedules.id != b_schedules_negative_link.id
3411 where
3412 b_schedules.linkage_instance_id >= 0
3413 and b_schedules.should_be_evaluated = 1
3414 order by null
3415
3416 (134.1ms) delete from buffer_schedules_1458117728
3417 where call_type_id < 0 /* vacations and non-clinicals */
3418
3419INFO : (04-06 20:53:44) --> fill: 36 - Scheduler::AutoPopulate::Queries::Query097
3420 (165.9ms) insert into buffer_staff_assigned_days_1458117728 (
3421 staff_id, period_offset, week_number, schedule_on, is_weekend, is_assigned
3422 )
3423 select staffs.staff_id,
3424 if(days.within_period = 1, days.period_offset, null) as period_offset,
3425 yearweek(days.schedule_on, if(clients.start_of_week = 0, 2, 7)) as week_number,
3426 days.schedule_on,
3427 if(dayofweek(days.schedule_on) in (7, 1), 1, 0) as is_weekend,
3428 if(schedules.staff_id is not null or vacations.staff_id is not null, 1, 0) as is_assigned
3429 from (
3430 select distinct staff_id
3431 from buffer_static_availabilities_1458117728
3432 order by null
3433 ) as staffs
3434 inner join (
3435 select p.period_offset,
3436 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,
3437 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
3438 from buffer_periods_1458117728 as p
3439 inner join (
3440 select 0 as digit union select 1 union select 2 union select 3 union select 4
3441 union select 5 union select 6 union select 7 union select 8 union select 9
3442 ) as digits_1
3443 inner join (
3444 select 0 as digit union select 1 union select 2 union select 3 union select 4
3445 union select 5 union select 6 union select 7 union select 8 union select 9
3446 ) as digits_2
3447 inner join (
3448 select 0 as digit union select 1 union select 2 union select 3 union select 4
3449 union select 5 union select 6 union select 7 union select 8 union select 9
3450 ) as digits_3
3451 where p.calendar_schedule_id = 6
3452 and p.should_be_evaluated = 1
3453 and (digits_1.digit * 100 + digits_2.digit * 10 + digits_3.digit) <= datediff(p.end_date, p.start_date) + 12
3454 order by null
3455 ) as days
3456 inner join (
3457 select min(start_date) as start_date, max(end_date) as end_date
3458 from buffer_periods_1458117728
3459 where calendar_schedule_id = 6
3460 and should_be_evaluated = 1
3461 order by null
3462 ) as limits
3463 inner join clients
3464 on clients.id = 6
3465 left join (
3466 select sc.staff_id, sc.schedule_on
3467 from buffer_periods_1458117728 as p
3468 inner join schedules as sc
3469 on sc.client_id = 6
3470 and sc.schedule_on between date_add(p.start_date, interval -6 day) and date_add(p.end_date, interval 6 day)
3471 inner join call_types as ct
3472 on sc.call_type_id = ct.id
3473 and ct.unassigned_day = 0
3474 where p.calendar_schedule_id = 6
3475 and p.should_be_evaluated = 1
3476 group by sc.staff_id, sc.schedule_on
3477 order by null
3478 ) as schedules
3479 on staffs.staff_id = schedules.staff_id
3480 and days.schedule_on = schedules.schedule_on
3481 left join (
3482 select v.staff_id, v.schedule_on
3483 from buffer_periods_1458117728 as p
3484 inner join vacations as v
3485 on v.client_id = 6
3486 and v.schedule_on between date_add(p.start_date, interval -6 day) and date_add(p.end_date, interval 6 day)
3487 and v.status IN (3)
3488 inner join non_clinical_types as nct
3489 on v.non_clinical_type_id = nct.id
3490 and nct.active = 1
3491 and nct.unassigned_day = 0
3492 where p.calendar_schedule_id = 6
3493 and p.should_be_evaluated = 1
3494 group by v.staff_id, v.schedule_on
3495 order by null
3496 ) as vacations
3497 on staffs.staff_id = vacations.staff_id
3498 and days.schedule_on = vacations.schedule_on
3499 where days.within_period = 1
3500 or yearweek(days.schedule_on, if(clients.start_of_week = 0, 2, 7)) in (
3501 yearweek(limits.start_date, if(clients.start_of_week = 0, 2, 7)),
3502 yearweek(limits.end_date, if(clients.start_of_week = 0, 2, 7))
3503 )
3504 order by null
3505
3506INFO : (04-06 20:53:44) --> fill: 37 - Scheduler::AutoPopulate::Queries::Query098
3507 (258.5ms) insert into buffer_combined_availabilities_1458117728 (
3508 schedule_id, staff_id, staff_type_id, is_primary, linkage_instance_id, has_violations
3509 )
3510 select sc.id as schedule_id, sa.staff_id, sa.staff_type_id, sa.is_primary,
3511 sc.linkage_instance_id, 0 as has_violations
3512 from buffer_schedules_1458117728 as sc
3513 /* Static availability */
3514 inner join buffer_static_availabilities_1458117728 as sa
3515 on sc.id = sa.schedule_id
3516 inner join buffer_linkages_1458117728 as l
3517 on sc.linkage_instance_id = l.linkage_instance_id
3518 where sc.should_be_evaluated = 1
3519 and l.has_conflicts = 0
3520
3521 (131.9ms) insert into buffer_schedule_linkages_1458117728 (
3522 staff_id, linkage_instance_id, slots_count
3523 )
3524 select staff_id, linkage_instance_id, count(1) as slots_count
3525 from buffer_schedules_1458117728 use index (ix_buffer_schedules_composite_2)
3526 where staff_id is not null
3527 and linkage_instance_id >= 0
3528 group by staff_id, linkage_instance_id
3529 order by null
3530
3531INFO : (04-06 20:53:44) --> fill: 38 - Scheduler::AutoPopulate::Queries::Query09_09_AL_01
3532 (132.6ms) /* AssignmentLimitsPerPeriod */
3533 insert into buffer_staff_assignments_count_periods_1458117728 (
3534 assignment_limit_id, staff_id, start_date, end_date, assignments_count
3535 )
3536 select straight_join lac.assignment_limit_id, ca.staff_id, lac.start_date, lac.end_date,
3537 count(distinct sc.id) as assignments_count
3538 from (
3539 select linkage_instance_id, assignment_limit_id, start_date, end_date
3540 from buffer_linkage_assignments_count_periods_1458117728
3541 group by linkage_instance_id, assignment_limit_id, start_date, end_date
3542 order by null
3543 ) as lac
3544 inner join (
3545 select linkage_instance_id, staff_id
3546 from buffer_combined_availabilities_1458117728
3547 group by linkage_instance_id, staff_id
3548 order by null
3549 ) as ca
3550 on lac.linkage_instance_id = ca.linkage_instance_id
3551 inner join assignment_limits as al
3552 on lac.assignment_limit_id = al.id
3553 inner join schedules as sc
3554 on ca.staff_id = sc.staff_id
3555 and sc.schedule_on between lac.start_date and lac.end_date
3556 and ((1 << (dayofweek(sc.schedule_on) - 1)) & al.considered_days_of_week_mask) > 0
3557 inner join buffer_assignment_limit_call_types_1458117728 as alct
3558 on lac.assignment_limit_id = alct.assignment_limit_id
3559 and sc.call_type_id = alct.call_type_id
3560 inner join assign_staff_types as ast
3561 on sc.staff_id = ast.staff_id
3562 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
3563 inner join buffer_assignment_limit_staff_types_1458117728 as alst
3564 on lac.assignment_limit_id = alst.assignment_limit_id
3565 and ast.staff_type_id = alst.staff_type_id
3566 group by lac.assignment_limit_id, ca.staff_id, lac.start_date, lac.end_date
3567 order by null
3568
3569INFO : (04-06 20:53:45) --> fill: 39 - Scheduler::AutoPopulate::Queries::Query09_09_AL_02
3570 (132.5ms) /* AssignmentLimitsPerWeek */
3571 insert into buffer_staff_assignments_count_weeks_1458117728 (
3572 assignment_limit_id, staff_id, start_date, end_date, assignments_count
3573 )
3574 select straight_join lac.assignment_limit_id, ca.staff_id, lac.start_date, lac.end_date,
3575 count(distinct sc.id) as assignments_count
3576 from (
3577 select linkage_instance_id, assignment_limit_id, start_date, end_date
3578 from buffer_linkage_assignments_count_weeks_1458117728
3579 group by linkage_instance_id, assignment_limit_id, start_date, end_date
3580 order by null
3581 ) as lac
3582 inner join (
3583 select linkage_instance_id, staff_id
3584 from buffer_combined_availabilities_1458117728
3585 group by linkage_instance_id, staff_id
3586 order by null
3587 ) as ca
3588 on lac.linkage_instance_id = ca.linkage_instance_id
3589 inner join assignment_limits as al
3590 on lac.assignment_limit_id = al.id
3591 inner join schedules as sc
3592 on ca.staff_id = sc.staff_id
3593 and sc.schedule_on between lac.start_date and lac.end_date
3594 and ((1 << (dayofweek(sc.schedule_on) - 1)) & al.considered_days_of_week_mask) > 0
3595 inner join buffer_assignment_limit_call_types_1458117728 as alct
3596 on lac.assignment_limit_id = alct.assignment_limit_id
3597 and sc.call_type_id = alct.call_type_id
3598 inner join assign_staff_types as ast
3599 on sc.staff_id = ast.staff_id
3600 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
3601 inner join buffer_assignment_limit_staff_types_1458117728 as alst
3602 on lac.assignment_limit_id = alst.assignment_limit_id
3603 and ast.staff_type_id = alst.staff_type_id
3604 group by lac.assignment_limit_id, ca.staff_id, lac.start_date, lac.end_date
3605 order by null
3606
3607INFO : (04-06 20:53:45) --> fill: 40 - Scheduler::AutoPopulate::Queries::Query09_09_AL_03
3608 (136.2ms) /* AssignmentLimitsRolling */
3609 insert into buffer_staff_assignments_count_rolling_1458117728 (
3610 assignment_limit_id, staff_id, start_date, end_date, assignments_count
3611 )
3612 select straight_join lac.assignment_limit_id, ca.staff_id, lac.start_date, lac.end_date,
3613 count(distinct sc.id) as assignments_count
3614 from (
3615 select linkage_instance_id, assignment_limit_id, start_date, end_date
3616 from buffer_linkage_assignments_count_rolling_1458117728
3617 group by linkage_instance_id, assignment_limit_id, start_date, end_date
3618 order by null
3619 ) as lac
3620 inner join (
3621 select linkage_instance_id, staff_id
3622 from buffer_combined_availabilities_1458117728
3623 group by linkage_instance_id, staff_id
3624 order by null
3625 ) as ca
3626 on lac.linkage_instance_id = ca.linkage_instance_id
3627 inner join assignment_limits as al
3628 on lac.assignment_limit_id = al.id
3629 inner join schedules as sc
3630 on ca.staff_id = sc.staff_id
3631 and sc.schedule_on between lac.start_date and lac.end_date
3632 and ((1 << (dayofweek(sc.schedule_on) - 1)) & al.considered_days_of_week_mask) > 0
3633 inner join buffer_assignment_limit_call_types_1458117728 as alct
3634 on lac.assignment_limit_id = alct.assignment_limit_id
3635 and sc.call_type_id = alct.call_type_id
3636 inner join assign_staff_types as ast
3637 on sc.staff_id = ast.staff_id
3638 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
3639 inner join buffer_assignment_limit_staff_types_1458117728 as alst
3640 on lac.assignment_limit_id = alst.assignment_limit_id
3641 and ast.staff_type_id = alst.staff_type_id
3642 group by lac.assignment_limit_id, ca.staff_id, lac.start_date, lac.end_date
3643 order by null
3644
3645INFO : (04-06 20:53:45) --> fill: 41 - Scheduler::AutoPopulate::Queries::Query09_09_AL_04
3646 (132.6ms) /* AssignmentLimitsConsecutive */
3647 insert into buffer_staff_assignments_count_consecutive_1458117728 (
3648 assignment_limit_id, staff_id, schedule_on, start_date, end_date
3649 )
3650 select straight_join lac.assignment_limit_id, ca.staff_id, sc.schedule_on, lac.start_date, lac.end_date
3651 from (
3652 select linkage_instance_id, assignment_limit_id, start_date, end_date
3653 from buffer_linkage_assignments_count_consecutive_1458117728
3654 group by linkage_instance_id, assignment_limit_id, start_date, end_date
3655 order by null
3656 ) as lac
3657 inner join (
3658 select linkage_instance_id, staff_id
3659 from buffer_combined_availabilities_1458117728
3660 group by linkage_instance_id, staff_id
3661 order by null
3662 ) as ca
3663 on lac.linkage_instance_id = ca.linkage_instance_id
3664 inner join assignment_limits as al
3665 on lac.assignment_limit_id = al.id
3666 inner join schedules as sc
3667 on ca.staff_id = sc.staff_id
3668 and sc.schedule_on between lac.start_date and lac.end_date
3669 and ((1 << (dayofweek(sc.schedule_on) - 1)) & al.considered_days_of_week_mask) > 0
3670 inner join buffer_assignment_limit_call_types_1458117728 as alct
3671 on lac.assignment_limit_id = alct.assignment_limit_id
3672 and sc.call_type_id = alct.call_type_id
3673 inner join assign_staff_types as ast
3674 on sc.staff_id = ast.staff_id
3675 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
3676 inner join buffer_assignment_limit_staff_types_1458117728 as alst
3677 on lac.assignment_limit_id = alst.assignment_limit_id
3678 and ast.staff_type_id = alst.staff_type_id
3679 group by lac.assignment_limit_id, ca.staff_id, sc.schedule_on, lac.start_date, lac.end_date
3680 order by null
3681
3682INFO : (04-06 20:53:45) --> fill: 42 - Scheduler::AutoPopulate::Queries::Query09_12_Points
3683 (158.7ms) insert into buffer_linkage_point_targets_1458117728 (
3684 linkage_instance_id,
3685 staff_id,
3686 is_weekend,
3687 period_offset,
3688 calendar_schedule_id,
3689 scheduled
3690 )
3691 select
3692 sc.linkage_instance_id,
3693 ca.staff_id,
3694 part_of_week.is_weekend,
3695 periods.period_offset,
3696 sc.calendar_schedule_id,
3697 sum(ci.points) as scheduled
3698 from
3699 buffer_combined_availabilities_1458117728 as ca
3700 inner join buffer_schedules_1458117728 as sc
3701 on ca.schedule_id = sc.id
3702 inner join buffer_counter_increments_1458117728 as ci
3703 on sc.id = ci.schedule_id
3704 and ci.points != 0
3705 inner join staff_types as st
3706 on ca.staff_type_id = st.id
3707 and sc.calendar_schedule_id = st.point_hour_schedule_id
3708 inner join (
3709 select 0 as is_weekend
3710 union select 1
3711
3712 ) as part_of_week
3713 on sc.is_weekend = part_of_week.is_weekend
3714 or part_of_week.is_weekend = -1
3715 inner join (
3716 select period_offset
3717 from buffer_periods_1458117728
3718 union select -1 as period_offset
3719 order by null
3720 ) as periods
3721 on sc.period_offset = periods.period_offset
3722 or periods.period_offset = -1
3723 group by
3724 sc.linkage_instance_id,
3725 ca.staff_id,
3726 part_of_week.is_weekend,
3727 periods.period_offset,
3728 sc.calendar_schedule_id
3729 having sum(abs(ci.points)) > 0
3730 order by null
3731
3732INFO : (04-06 20:53:45) --> fill: 43 - Scheduler::AutoPopulate::Queries::Query09_12_Hours
3733INFO : (04-06 20:53:45) --> fill: 44 - Scheduler::AutoPopulate::Queries::Query10
3734 RuleSet Load (132.0ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1530 LIMIT 1
3735 Client Load (134.3ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
3736 (131.8ms) /* SpecializationOverlapRule */
3737 delete ca
3738 from buffer_combined_availabilities_1458117728 as ca use index (ix_buffer_combined_availabilities_composite_1)
3739 inner join buffer_schedules_1458117728 as sc
3740 on ca.schedule_id = sc.id
3741 inner join buffer_staff_specializations_1458117728 as ssp
3742 on ca.staff_id = ssp.staff_id
3743 inner join max_applicable_call_types as mact
3744 on ssp.specialization_id = mact.specialization_id
3745 and sc.call_type_id = mact.call_type_id
3746 inner join buffer_specialization_daily_counts_1458117728 as sdc use index (ix_buffer_specialization_daily_counts_composite_1)
3747 on ssp.specialization_id = sdc.specialization_id
3748 and sc.schedule_on = sdc.schedule_on
3749 and sdc.staff_id is null
3750 left join buffer_specialization_daily_counts_1458117728 as sdc_2 use index (ix_buffer_specialization_daily_counts_composite_1)
3751 on ssp.specialization_id = sdc_2.specialization_id
3752 and sc.schedule_on = sdc_2.schedule_on
3753 and ca.staff_id = sdc_2.staff_id
3754 where sdc.should_be_evaluated = 1
3755 and (sdc.staffs_scheduled + if(sdc_2.id is null, 1, 0)) > sdc.max_scheduled
3756
3757 (133.4ms) delete ca
3758 from buffer_combined_availabilities_1458117728 as ca
3759 inner join (
3760 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
3761 sum(lac.assignments_count) as assignments_count
3762 from (
3763 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
3764 from buffer_combined_availabilities_1458117728 as ca
3765 inner join buffer_schedules_1458117728 as sc
3766 on ca.schedule_id = sc.id
3767 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
3768 order by null
3769 ) as ca_sc
3770 inner join buffer_linkage_assignments_count_weeks_1458117728 as lac
3771 on ca_sc.linkage_instance_id = lac.linkage_instance_id
3772 and ca_sc.schedule_on = lac.schedule_on
3773 inner join buffer_assignment_limit_staff_types_1458117728 as alst
3774 on lac.assignment_limit_id = alst.assignment_limit_id
3775 and ca_sc.staff_type_id = alst.staff_type_id
3776 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
3777 order by null
3778 ) as lac
3779 on ca.linkage_instance_id = lac.linkage_instance_id
3780 and ca.staff_id = lac.staff_id
3781 inner join assignment_limits as al
3782 on lac.assignment_limit_id = al.id
3783 left join buffer_staff_assignments_count_weeks_1458117728 as sac
3784 on lac.assignment_limit_id = sac.assignment_limit_id
3785 and lac.staff_id = sac.staff_id
3786 and lac.start_date = sac.start_date
3787 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_weekly_limit
3788
3789 (131.9ms) delete ca
3790 from buffer_combined_availabilities_1458117728 as ca
3791 inner join (
3792 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
3793 sum(lac.assignments_count) as assignments_count
3794 from (
3795 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
3796 from buffer_combined_availabilities_1458117728 as ca
3797 inner join buffer_schedules_1458117728 as sc
3798 on ca.schedule_id = sc.id
3799 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
3800 order by null
3801 ) as ca_sc
3802 inner join buffer_linkage_assignments_count_periods_1458117728 as lac
3803 on ca_sc.linkage_instance_id = lac.linkage_instance_id
3804 and ca_sc.schedule_on = lac.schedule_on
3805 inner join buffer_assignment_limit_staff_types_1458117728 as alst
3806 on lac.assignment_limit_id = alst.assignment_limit_id
3807 and ca_sc.staff_type_id = alst.staff_type_id
3808 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
3809 order by null
3810 ) as lac
3811 on ca.linkage_instance_id = lac.linkage_instance_id
3812 and ca.staff_id = lac.staff_id
3813 inner join assignment_limits as al
3814 on lac.assignment_limit_id = al.id
3815 left join buffer_staff_assignments_count_periods_1458117728 as sac
3816 on lac.assignment_limit_id = sac.assignment_limit_id
3817 and lac.staff_id = sac.staff_id
3818 and lac.start_date = sac.start_date
3819 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_per_period_limit
3820
3821 (132.1ms) delete ca
3822 from buffer_combined_availabilities_1458117728 as ca
3823 inner join (
3824 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
3825 sum(lac.assignments_count) as assignments_count
3826 from (
3827 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
3828 from buffer_combined_availabilities_1458117728 as ca
3829 inner join buffer_schedules_1458117728 as sc
3830 on ca.schedule_id = sc.id
3831 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
3832 order by null
3833 ) as ca_sc
3834 inner join buffer_linkage_assignments_count_rolling_1458117728 as lac
3835 on ca_sc.linkage_instance_id = lac.linkage_instance_id
3836 and ca_sc.schedule_on = lac.schedule_on
3837 inner join buffer_assignment_limit_staff_types_1458117728 as alst
3838 on lac.assignment_limit_id = alst.assignment_limit_id
3839 and ca_sc.staff_type_id = alst.staff_type_id
3840 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
3841 order by null
3842 ) as lac
3843 on ca.linkage_instance_id = lac.linkage_instance_id
3844 and ca.staff_id = lac.staff_id
3845 inner join assignment_limits as al
3846 on lac.assignment_limit_id = al.id
3847 left join buffer_staff_assignments_count_rolling_1458117728 as sac
3848 on lac.assignment_limit_id = sac.assignment_limit_id
3849 and lac.staff_id = sac.staff_id
3850 and lac.start_date = sac.start_date
3851 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_rolling_limit
3852
3853 (132.9ms) delete ca
3854 from buffer_combined_availabilities_1458117728 as ca
3855 inner join (
3856 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
3857 count(distinct if(sac.id is null, lac.schedule_on, null)) as assignments_count
3858 from (
3859 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
3860 from buffer_combined_availabilities_1458117728 as ca
3861 inner join buffer_schedules_1458117728 as sc
3862 on ca.schedule_id = sc.id
3863 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
3864 order by null
3865 ) as ca_sc
3866 inner join buffer_linkage_assignments_count_consecutive_1458117728 as lac
3867 on ca_sc.linkage_instance_id = lac.linkage_instance_id
3868 and ca_sc.schedule_on = lac.schedule_on
3869 inner join buffer_assignment_limit_staff_types_1458117728 as alst
3870 on lac.assignment_limit_id = alst.assignment_limit_id
3871 and ca_sc.staff_type_id = alst.staff_type_id
3872 left join buffer_staff_assignments_count_consecutive_1458117728 as sac
3873 on lac.assignment_limit_id = sac.assignment_limit_id
3874 and ca_sc.staff_id = sac.staff_id
3875 and lac.schedule_on = sac.schedule_on
3876 and lac.start_date = sac.start_date
3877 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
3878 order by null
3879 ) as lac
3880 on ca.linkage_instance_id = lac.linkage_instance_id
3881 and ca.staff_id = lac.staff_id
3882 inner join assignment_limits as al
3883 on lac.assignment_limit_id = al.id
3884 left join (
3885 select assignment_limit_id, staff_id, start_date,
3886 count(schedule_on) as assignments_count
3887 from buffer_staff_assignments_count_consecutive_1458117728
3888 group by assignment_limit_id, staff_id, start_date
3889 ) as sac
3890 on lac.assignment_limit_id = sac.assignment_limit_id
3891 and lac.staff_id = sac.staff_id
3892 and lac.start_date = sac.start_date
3893 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_consecutive_limit
3894
3895 (141.0ms) delete ca
3896 from
3897 buffer_combined_availabilities_1458117728 as ca
3898 inner join buffer_schedules_1458117728 as sc
3899 on ca.schedule_id = sc.id
3900 inner join buffer_linkage_point_targets_1458117728 as lpt
3901 on sc.linkage_instance_id = lpt.linkage_instance_id
3902 and ca.staff_id = lpt.staff_id
3903 and sc.is_weekend = lpt.is_weekend
3904 and lpt.period_offset = -1
3905 and sc.calendar_schedule_id = lpt.calendar_schedule_id
3906 inner join buffer_cumulative_point_targets_1458117728 as pt
3907 on ca.staff_id = pt.staff_id
3908 and sc.is_weekend = pt.is_weekend
3909 and sc.calendar_schedule_id = pt.calendar_schedule_id
3910 where
3911 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
3912 and (pt.scheduled + lpt.scheduled) > (pt.adjusted_target /* raw_target | adjusted_target */ * (1 + 0 /* hours threshold */ / 100.0));
3913
3914 (131.8ms) select
3915 coalesce(max(
3916 case
3917 when (ct.max_weekday_assignments > 0) then 1
3918 else 0
3919 end
3920 ), 0) as weekday_flag,
3921 coalesce(max(
3922 case
3923 when (ct.max_weekend_assignments > 0) then 1
3924 else 0
3925 end
3926 ), 0) as weekend_flag
3927 from
3928 buffer_auto_populate_slots_1458117728 as aps
3929 inner join call_types as ct
3930 on aps.call_type_id = ct.id
3931
3932 (131.8ms) /* MaxAssignmentsRule */
3933 delete ca
3934 from buffer_combined_availabilities_1458117728 as ca
3935 inner join buffer_schedules_1458117728 as sc
3936 on ca.schedule_id = sc.id
3937 inner join buffer_linkage_call_type_assignments_1458117728 as lcta
3938 on sc.linkage_instance_id = lcta.linkage_instance_id
3939 and sc.call_type_id = lcta.call_type_id
3940 and sc.is_weekend = lcta.is_weekend
3941 and sc.period_offset = lcta.period_offset
3942 and sc.calendar_schedule_id = lcta.calendar_schedule_id
3943 left join buffer_call_type_assignments_1458117728 as cta
3944 on ca.staff_id = cta.staff_id
3945 and sc.call_type_id = cta.call_type_id
3946 and sc.is_weekend = cta.is_weekend
3947 and sc.period_offset = cta.period_offset
3948 and sc.calendar_schedule_id = cta.calendar_schedule_id
3949 where
3950 sc.is_weekend in (NULL) /* "weekday (0), weekend (1)" checkboxes */
3951 and (coalesce(cta.assignments_count, 0) + lcta.assignments_count) > lcta.max_assignments;
3952
3953 (131.1ms) /* NegativeLinkRule */
3954 delete ca
3955 from buffer_combined_availabilities_1458117728 as ca use index (ix_buffer_combined_availabilities_composite_1)
3956 inner join buffer_negative_relations_1458117728 as nr use index (ix_buffer_negative_relations_composite_1)
3957 on ca.schedule_id = nr.schedule_id
3958 and ca.staff_id = nr.staff_id
3959
3960 (133.7ms) /* BrokenLinkageRule */
3961 truncate table buffer_combined_availability_linkages_1458117728
3962
3963 (139.4ms) insert into buffer_combined_availability_linkages_1458117728 (
3964 staff_id,
3965 linkage_instance_id,
3966 slots_count,
3967 is_primary,
3968 has_violations
3969 )
3970 select
3971 staff_id,
3972 linkage_instance_id,
3973 count(1) as slots_count,
3974 min(is_primary) as is_primary,
3975 max(has_violations) as has_violations
3976 from buffer_combined_availabilities_1458117728 use index (ix_buffer_combined_availabilities_composite_2)
3977 group by
3978 staff_id,
3979 linkage_instance_id
3980 order by null
3981
3982 (132.6ms) delete ca
3983 from
3984 buffer_combined_availabilities_1458117728 as ca use index (ix_buffer_combined_availabilities_composite_1)
3985 inner join buffer_schedules_1458117728 as sc
3986 on ca.schedule_id = sc.id
3987 inner join buffer_linkages_1458117728 as l
3988 on sc.linkage_instance_id = l.linkage_instance_id
3989 inner join buffer_combined_availability_linkages_1458117728 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
3990 on ca.staff_id = ls_1.staff_id
3991 and sc.linkage_instance_id = ls_1.linkage_instance_id
3992 left join buffer_schedule_linkages_1458117728 as ls_2 use index (ix_buffer_schedule_linkages_composite_1)
3993 on ca.staff_id = ls_2.staff_id
3994 and sc.linkage_instance_id = ls_2.linkage_instance_id
3995 where (ls_1.slots_count + coalesce(ls_2.slots_count, 0)) < l.slots_count_total /* not covering the whole chain */;
3996
3997INFO : (04-06 20:53:47) --> fill: 45 - Scheduler::AutoPopulate::Queries::QueryScore02
3998INFO : (04-06 20:53:47) --> fill: 46 - Scheduler::AutoPopulate::Queries::QueryScore03
3999INFO : (04-06 20:53:47) --> fill: 47 - Scheduler::AutoPopulate::Queries::QueryScore04
4000INFO : (04-06 20:53:47) --> fill: 48 - Scheduler::AutoPopulate::Queries::Query11
4001 (135.5ms) update buffer_schedules_1458117728 as sc
4002 left join buffer_combined_availabilities_1458117728 as ca
4003 on sc.id = ca.schedule_id
4004 set sc.should_be_evaluated = 0,
4005 sc.should_be_populated = 0
4006 where sc.should_be_evaluated = 1
4007 and ca.id is null
4008
4009INFO : (04-06 20:53:47) --> fill: 49 - Scheduler::AutoPopulate::Queries::DropTables
4010INFO : (04-06 20:53:47) Setting up lists...
4011 (133.7ms) select b_schedules.schedule_on, b_schedules.call_type_id, b_schedules.linkage_instance_id, schedules.id as schedule_id
4012 from buffer_schedules_1458117728 as b_schedules
4013 left join schedules
4014 on schedules.client_id = 6
4015 and schedules.call_type_id = b_schedules.call_type_id
4016 and schedules.schedule_on = b_schedules.schedule_on
4017 where b_schedules.linkage_instance_id != -1
4018 order by b_schedules.linkage_instance_id, b_schedules.schedule_on
4019
4020INFO : (04-06 20:53:47) Begin to populate. Pre-set: 0. Unscheduled: 125.
4021INFO : (04-06 20:53:47) plan unit: [id:201749] [2017-12-03 - OR]
4022INFO : (04-06 20:53:47) plan unit: [id:201750] [2017-12-10 - OR]
4023INFO : (04-06 20:53:47) plan unit: [id:201751] [2017-12-17 - OR]
4024INFO : (04-06 20:53:47) plan unit: [id:201752] [2017-12-24 - OR]
4025INFO : (04-06 20:53:47) plan unit: [id:201753] [2017-12-31 - OR]
4026INFO : (04-06 20:53:47) plan unit: [id:1201749] [2017-12-03 - OB]
4027INFO : (04-06 20:53:47) plan unit: [id:1201750] [2017-12-10 - OB]
4028INFO : (04-06 20:53:47) plan unit: [id:1201751] [2017-12-17 - OB]
4029INFO : (04-06 20:53:47) plan unit: [id:1201752] [2017-12-24 - OB]
4030INFO : (04-06 20:53:47) plan unit: [id:1201753] [2017-12-31 - OB]
4031INFO : (04-06 20:53:47) plan unit: [id:2201749] [2017-12-04 - OR]
4032INFO : (04-06 20:53:47) plan unit: [id:2201750] [2017-12-11 - OR]
4033INFO : (04-06 20:53:47) plan unit: [id:2201751] [2017-12-18 - OR]
4034INFO : (04-06 20:53:47) plan unit: [id:2201752] [2017-12-25 - OR]
4035INFO : (04-06 20:53:47) plan unit: [id:3201749] [2017-12-04 - BU]
4036INFO : (04-06 20:53:47) plan unit: [id:3201750] [2017-12-11 - BU]
4037INFO : (04-06 20:53:47) plan unit: [id:3201751] [2017-12-18 - BU]
4038INFO : (04-06 20:53:47) plan unit: [id:3201752] [2017-12-25 - BU]
4039INFO : (04-06 20:53:47) plan unit: [id:4201749] [2017-12-04 - OB]
4040INFO : (04-06 20:53:47) plan unit: [id:4201750] [2017-12-11 - OB]
4041INFO : (04-06 20:53:47) plan unit: [id:4201751] [2017-12-18 - OB]
4042INFO : (04-06 20:53:47) plan unit: [id:4201752] [2017-12-25 - OB]
4043INFO : (04-06 20:53:47) plan unit: [id:5201749] [2017-12-04 - GI1]
4044INFO : (04-06 20:53:47) plan unit: [id:5201750] [2017-12-11 - GI1]
4045INFO : (04-06 20:53:47) plan unit: [id:5201751] [2017-12-18 - GI1]
4046INFO : (04-06 20:53:47) plan unit: [id:5201752] [2017-12-25 - GI1]
4047INFO : (04-06 20:53:47) plan unit: [id:6201749] [2017-12-04 - PR]
4048INFO : (04-06 20:53:47) plan unit: [id:6201750] [2017-12-11 - PR]
4049INFO : (04-06 20:53:47) plan unit: [id:6201751] [2017-12-18 - PR]
4050INFO : (04-06 20:53:47) plan unit: [id:6201752] [2017-12-25 - PR]
4051INFO : (04-06 20:53:47) plan unit: [id:11201749] [2017-12-05 - OR]
4052INFO : (04-06 20:53:47) plan unit: [id:11201750] [2017-12-12 - OR]
4053INFO : (04-06 20:53:47) plan unit: [id:11201751] [2017-12-19 - OR]
4054INFO : (04-06 20:53:47) plan unit: [id:11201752] [2017-12-26 - OR]
4055INFO : (04-06 20:53:47) plan unit: [id:12201749] [2017-12-05 - BU]
4056INFO : (04-06 20:53:47) plan unit: [id:12201750] [2017-12-12 - BU]
4057INFO : (04-06 20:53:47) plan unit: [id:12201751] [2017-12-19 - BU]
4058INFO : (04-06 20:53:47) plan unit: [id:12201752] [2017-12-26 - BU]
4059INFO : (04-06 20:53:47) plan unit: [id:13201749] [2017-12-05 - OB]
4060INFO : (04-06 20:53:47) plan unit: [id:13201750] [2017-12-12 - OB]
4061INFO : (04-06 20:53:47) plan unit: [id:13201751] [2017-12-19 - OB]
4062INFO : (04-06 20:53:47) plan unit: [id:13201752] [2017-12-26 - OB]
4063INFO : (04-06 20:53:47) plan unit: [id:14201749] [2017-12-05 - GI1]
4064INFO : (04-06 20:53:47) plan unit: [id:14201750] [2017-12-12 - GI1]
4065INFO : (04-06 20:53:47) plan unit: [id:14201751] [2017-12-19 - GI1]
4066INFO : (04-06 20:53:47) plan unit: [id:14201752] [2017-12-26 - GI1]
4067INFO : (04-06 20:53:47) plan unit: [id:15201749] [2017-12-05 - PR]
4068INFO : (04-06 20:53:47) plan unit: [id:15201750] [2017-12-12 - PR]
4069INFO : (04-06 20:53:47) plan unit: [id:15201751] [2017-12-19 - PR]
4070INFO : (04-06 20:53:47) plan unit: [id:15201752] [2017-12-26 - PR]
4071INFO : (04-06 20:53:47) plan unit: [id:20201749] [2017-12-06 - OR]
4072INFO : (04-06 20:53:47) plan unit: [id:20201750] [2017-12-13 - OR]
4073INFO : (04-06 20:53:47) plan unit: [id:20201751] [2017-12-20 - OR]
4074INFO : (04-06 20:53:47) plan unit: [id:20201752] [2017-12-27 - OR]
4075INFO : (04-06 20:53:47) plan unit: [id:21201749] [2017-12-06 - BU]
4076INFO : (04-06 20:53:47) plan unit: [id:21201750] [2017-12-13 - BU]
4077INFO : (04-06 20:53:47) plan unit: [id:21201751] [2017-12-20 - BU]
4078INFO : (04-06 20:53:47) plan unit: [id:21201752] [2017-12-27 - BU]
4079INFO : (04-06 20:53:47) plan unit: [id:22201749] [2017-12-06 - OB]
4080INFO : (04-06 20:53:47) plan unit: [id:22201750] [2017-12-13 - OB]
4081INFO : (04-06 20:53:47) plan unit: [id:22201751] [2017-12-20 - OB]
4082INFO : (04-06 20:53:47) plan unit: [id:22201752] [2017-12-27 - OB]
4083INFO : (04-06 20:53:47) plan unit: [id:23201749] [2017-12-06 - GI1]
4084INFO : (04-06 20:53:47) plan unit: [id:23201750] [2017-12-13 - GI1]
4085INFO : (04-06 20:53:47) plan unit: [id:23201751] [2017-12-20 - GI1]
4086INFO : (04-06 20:53:47) plan unit: [id:23201752] [2017-12-27 - GI1]
4087INFO : (04-06 20:53:47) plan unit: [id:24201749] [2017-12-06 - PR]
4088INFO : (04-06 20:53:47) plan unit: [id:24201750] [2017-12-13 - PR]
4089INFO : (04-06 20:53:47) plan unit: [id:24201751] [2017-12-20 - PR]
4090INFO : (04-06 20:53:47) plan unit: [id:24201752] [2017-12-27 - PR]
4091INFO : (04-06 20:53:47) plan unit: [id:29201749] [2017-12-07 - OR]
4092INFO : (04-06 20:53:47) plan unit: [id:29201750] [2017-12-14 - OR]
4093INFO : (04-06 20:53:47) plan unit: [id:29201751] [2017-12-21 - OR]
4094INFO : (04-06 20:53:47) plan unit: [id:29201752] [2017-12-28 - OR]
4095INFO : (04-06 20:53:47) plan unit: [id:30201749] [2017-12-07 - BU]
4096INFO : (04-06 20:53:47) plan unit: [id:30201750] [2017-12-14 - BU]
4097INFO : (04-06 20:53:47) plan unit: [id:30201751] [2017-12-21 - BU]
4098INFO : (04-06 20:53:47) plan unit: [id:30201752] [2017-12-28 - BU]
4099INFO : (04-06 20:53:47) plan unit: [id:31201749] [2017-12-07 - OB]
4100INFO : (04-06 20:53:47) plan unit: [id:31201750] [2017-12-14 - OB]
4101INFO : (04-06 20:53:47) plan unit: [id:31201751] [2017-12-21 - OB]
4102INFO : (04-06 20:53:47) plan unit: [id:31201752] [2017-12-28 - OB]
4103INFO : (04-06 20:53:47) plan unit: [id:32201749] [2017-12-07 - GI1]
4104INFO : (04-06 20:53:47) plan unit: [id:32201750] [2017-12-14 - GI1]
4105INFO : (04-06 20:53:47) plan unit: [id:32201751] [2017-12-21 - GI1]
4106INFO : (04-06 20:53:47) plan unit: [id:32201752] [2017-12-28 - GI1]
4107INFO : (04-06 20:53:47) plan unit: [id:33201749] [2017-12-07 - PR]
4108INFO : (04-06 20:53:47) plan unit: [id:33201750] [2017-12-14 - PR]
4109INFO : (04-06 20:53:47) plan unit: [id:33201751] [2017-12-21 - PR]
4110INFO : (04-06 20:53:47) plan unit: [id:33201752] [2017-12-28 - PR]
4111INFO : (04-06 20:53:47) plan unit: [id:38201748] [2017-12-01 - OR]
4112INFO : (04-06 20:53:47) plan unit: [id:38201749] [2017-12-08 - OR]
4113INFO : (04-06 20:53:47) plan unit: [id:38201750] [2017-12-15 - OR]
4114INFO : (04-06 20:53:47) plan unit: [id:38201751] [2017-12-22 - OR]
4115INFO : (04-06 20:53:47) plan unit: [id:38201752] [2017-12-29 - OR]
4116INFO : (04-06 20:53:47) plan unit: [id:39201748] [2017-12-01 - BU]
4117INFO : (04-06 20:53:47) plan unit: [id:39201749] [2017-12-08 - BU]
4118INFO : (04-06 20:53:47) plan unit: [id:39201750] [2017-12-15 - BU]
4119INFO : (04-06 20:53:47) plan unit: [id:39201751] [2017-12-22 - BU]
4120INFO : (04-06 20:53:47) plan unit: [id:39201752] [2017-12-29 - BU]
4121INFO : (04-06 20:53:47) plan unit: [id:40201748] [2017-12-01 - OB]
4122INFO : (04-06 20:53:47) plan unit: [id:40201749] [2017-12-08 - OB]
4123INFO : (04-06 20:53:47) plan unit: [id:40201750] [2017-12-15 - OB]
4124INFO : (04-06 20:53:47) plan unit: [id:40201751] [2017-12-22 - OB]
4125INFO : (04-06 20:53:47) plan unit: [id:40201752] [2017-12-29 - OB]
4126INFO : (04-06 20:53:47) plan unit: [id:41201748] [2017-12-01 - GI1]
4127INFO : (04-06 20:53:47) plan unit: [id:41201749] [2017-12-08 - GI1]
4128INFO : (04-06 20:53:47) plan unit: [id:41201750] [2017-12-15 - GI1]
4129INFO : (04-06 20:53:47) plan unit: [id:41201751] [2017-12-22 - GI1]
4130INFO : (04-06 20:53:47) plan unit: [id:41201752] [2017-12-29 - GI1]
4131INFO : (04-06 20:53:47) plan unit: [id:42201748] [2017-12-01 - PR]
4132INFO : (04-06 20:53:47) plan unit: [id:42201749] [2017-12-08 - PR]
4133INFO : (04-06 20:53:47) plan unit: [id:42201750] [2017-12-15 - PR]
4134INFO : (04-06 20:53:47) plan unit: [id:42201751] [2017-12-22 - PR]
4135INFO : (04-06 20:53:47) plan unit: [id:42201752] [2017-12-29 - PR]
4136INFO : (04-06 20:53:47) plan unit: [id:47201748] [2017-12-02 - OR]
4137INFO : (04-06 20:53:47) plan unit: [id:47201749] [2017-12-09 - OR]
4138INFO : (04-06 20:53:47) plan unit: [id:47201750] [2017-12-16 - OR]
4139INFO : (04-06 20:53:47) plan unit: [id:47201751] [2017-12-23 - OR]
4140INFO : (04-06 20:53:47) plan unit: [id:47201752] [2017-12-30 - OR]
4141INFO : (04-06 20:53:47) plan unit: [id:48201748] [2017-12-02 - OB]
4142INFO : (04-06 20:53:47) plan unit: [id:48201749] [2017-12-09 - OB]
4143INFO : (04-06 20:53:47) plan unit: [id:48201750] [2017-12-16 - OB]
4144INFO : (04-06 20:53:47) plan unit: [id:48201751] [2017-12-23 - OB]
4145INFO : (04-06 20:53:47) plan unit: [id:48201752] [2017-12-30 - OB]
4146 NegativeLink Load (132.5ms) SELECT `negative_links`.* FROM `negative_links` WHERE `negative_links`.`client_id` = 6
4147 (132.0ms) /* SpecializationOverlapRule */
4148 delete ca
4149 from buffer_combined_availabilities_1458117728 as ca use index (ix_buffer_combined_availabilities_composite_1)
4150 inner join buffer_schedules_1458117728 as sc
4151 on ca.schedule_id = sc.id
4152 inner join buffer_staff_specializations_1458117728 as ssp
4153 on ca.staff_id = ssp.staff_id
4154 inner join max_applicable_call_types as mact
4155 on ssp.specialization_id = mact.specialization_id
4156 and sc.call_type_id = mact.call_type_id
4157 inner join buffer_specialization_daily_counts_1458117728 as sdc use index (ix_buffer_specialization_daily_counts_composite_1)
4158 on ssp.specialization_id = sdc.specialization_id
4159 and sc.schedule_on = sdc.schedule_on
4160 and sdc.staff_id is null
4161 left join buffer_specialization_daily_counts_1458117728 as sdc_2 use index (ix_buffer_specialization_daily_counts_composite_1)
4162 on ssp.specialization_id = sdc_2.specialization_id
4163 and sc.schedule_on = sdc_2.schedule_on
4164 and ca.staff_id = sdc_2.staff_id
4165 where sdc.should_be_evaluated = 1
4166 and (sdc.staffs_scheduled + if(sdc_2.id is null, 1, 0)) > sdc.max_scheduled
4167
4168 (132.9ms) delete ca
4169 from buffer_combined_availabilities_1458117728 as ca
4170 inner join (
4171 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
4172 sum(lac.assignments_count) as assignments_count
4173 from (
4174 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4175 from buffer_combined_availabilities_1458117728 as ca
4176 inner join buffer_schedules_1458117728 as sc
4177 on ca.schedule_id = sc.id
4178 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4179 order by null
4180 ) as ca_sc
4181 inner join buffer_linkage_assignments_count_weeks_1458117728 as lac
4182 on ca_sc.linkage_instance_id = lac.linkage_instance_id
4183 and ca_sc.schedule_on = lac.schedule_on
4184 inner join buffer_assignment_limit_staff_types_1458117728 as alst
4185 on lac.assignment_limit_id = alst.assignment_limit_id
4186 and ca_sc.staff_type_id = alst.staff_type_id
4187 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
4188 order by null
4189 ) as lac
4190 on ca.linkage_instance_id = lac.linkage_instance_id
4191 and ca.staff_id = lac.staff_id
4192 inner join assignment_limits as al
4193 on lac.assignment_limit_id = al.id
4194 left join buffer_staff_assignments_count_weeks_1458117728 as sac
4195 on lac.assignment_limit_id = sac.assignment_limit_id
4196 and lac.staff_id = sac.staff_id
4197 and lac.start_date = sac.start_date
4198 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_weekly_limit
4199
4200 (132.5ms) delete ca
4201 from buffer_combined_availabilities_1458117728 as ca
4202 inner join (
4203 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
4204 sum(lac.assignments_count) as assignments_count
4205 from (
4206 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4207 from buffer_combined_availabilities_1458117728 as ca
4208 inner join buffer_schedules_1458117728 as sc
4209 on ca.schedule_id = sc.id
4210 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4211 order by null
4212 ) as ca_sc
4213 inner join buffer_linkage_assignments_count_periods_1458117728 as lac
4214 on ca_sc.linkage_instance_id = lac.linkage_instance_id
4215 and ca_sc.schedule_on = lac.schedule_on
4216 inner join buffer_assignment_limit_staff_types_1458117728 as alst
4217 on lac.assignment_limit_id = alst.assignment_limit_id
4218 and ca_sc.staff_type_id = alst.staff_type_id
4219 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
4220 order by null
4221 ) as lac
4222 on ca.linkage_instance_id = lac.linkage_instance_id
4223 and ca.staff_id = lac.staff_id
4224 inner join assignment_limits as al
4225 on lac.assignment_limit_id = al.id
4226 left join buffer_staff_assignments_count_periods_1458117728 as sac
4227 on lac.assignment_limit_id = sac.assignment_limit_id
4228 and lac.staff_id = sac.staff_id
4229 and lac.start_date = sac.start_date
4230 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_per_period_limit
4231
4232 (132.0ms) delete ca
4233 from buffer_combined_availabilities_1458117728 as ca
4234 inner join (
4235 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
4236 sum(lac.assignments_count) as assignments_count
4237 from (
4238 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4239 from buffer_combined_availabilities_1458117728 as ca
4240 inner join buffer_schedules_1458117728 as sc
4241 on ca.schedule_id = sc.id
4242 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4243 order by null
4244 ) as ca_sc
4245 inner join buffer_linkage_assignments_count_rolling_1458117728 as lac
4246 on ca_sc.linkage_instance_id = lac.linkage_instance_id
4247 and ca_sc.schedule_on = lac.schedule_on
4248 inner join buffer_assignment_limit_staff_types_1458117728 as alst
4249 on lac.assignment_limit_id = alst.assignment_limit_id
4250 and ca_sc.staff_type_id = alst.staff_type_id
4251 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
4252 order by null
4253 ) as lac
4254 on ca.linkage_instance_id = lac.linkage_instance_id
4255 and ca.staff_id = lac.staff_id
4256 inner join assignment_limits as al
4257 on lac.assignment_limit_id = al.id
4258 left join buffer_staff_assignments_count_rolling_1458117728 as sac
4259 on lac.assignment_limit_id = sac.assignment_limit_id
4260 and lac.staff_id = sac.staff_id
4261 and lac.start_date = sac.start_date
4262 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_rolling_limit
4263
4264 (132.8ms) delete ca
4265 from buffer_combined_availabilities_1458117728 as ca
4266 inner join (
4267 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
4268 count(distinct if(sac.id is null, lac.schedule_on, null)) as assignments_count
4269 from (
4270 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4271 from buffer_combined_availabilities_1458117728 as ca
4272 inner join buffer_schedules_1458117728 as sc
4273 on ca.schedule_id = sc.id
4274 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4275 order by null
4276 ) as ca_sc
4277 inner join buffer_linkage_assignments_count_consecutive_1458117728 as lac
4278 on ca_sc.linkage_instance_id = lac.linkage_instance_id
4279 and ca_sc.schedule_on = lac.schedule_on
4280 inner join buffer_assignment_limit_staff_types_1458117728 as alst
4281 on lac.assignment_limit_id = alst.assignment_limit_id
4282 and ca_sc.staff_type_id = alst.staff_type_id
4283 left join buffer_staff_assignments_count_consecutive_1458117728 as sac
4284 on lac.assignment_limit_id = sac.assignment_limit_id
4285 and ca_sc.staff_id = sac.staff_id
4286 and lac.schedule_on = sac.schedule_on
4287 and lac.start_date = sac.start_date
4288 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
4289 order by null
4290 ) as lac
4291 on ca.linkage_instance_id = lac.linkage_instance_id
4292 and ca.staff_id = lac.staff_id
4293 inner join assignment_limits as al
4294 on lac.assignment_limit_id = al.id
4295 left join (
4296 select assignment_limit_id, staff_id, start_date,
4297 count(schedule_on) as assignments_count
4298 from buffer_staff_assignments_count_consecutive_1458117728
4299 group by assignment_limit_id, staff_id, start_date
4300 ) as sac
4301 on lac.assignment_limit_id = sac.assignment_limit_id
4302 and lac.staff_id = sac.staff_id
4303 and lac.start_date = sac.start_date
4304 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_consecutive_limit
4305
4306 (140.9ms) delete ca
4307 from
4308 buffer_combined_availabilities_1458117728 as ca
4309 inner join buffer_schedules_1458117728 as sc
4310 on ca.schedule_id = sc.id
4311 inner join buffer_linkage_point_targets_1458117728 as lpt
4312 on sc.linkage_instance_id = lpt.linkage_instance_id
4313 and ca.staff_id = lpt.staff_id
4314 and sc.is_weekend = lpt.is_weekend
4315 and lpt.period_offset = -1
4316 and sc.calendar_schedule_id = lpt.calendar_schedule_id
4317 inner join buffer_cumulative_point_targets_1458117728 as pt
4318 on ca.staff_id = pt.staff_id
4319 and sc.is_weekend = pt.is_weekend
4320 and sc.calendar_schedule_id = pt.calendar_schedule_id
4321 where
4322 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
4323 and (pt.scheduled + lpt.scheduled) > (pt.adjusted_target /* raw_target | adjusted_target */ * (1 + 0 /* hours threshold */ / 100.0));
4324
4325 (132.5ms) select
4326 coalesce(max(
4327 case
4328 when (ct.max_weekday_assignments > 0) then 1
4329 else 0
4330 end
4331 ), 0) as weekday_flag,
4332 coalesce(max(
4333 case
4334 when (ct.max_weekend_assignments > 0) then 1
4335 else 0
4336 end
4337 ), 0) as weekend_flag
4338 from
4339 buffer_auto_populate_slots_1458117728 as aps
4340 inner join call_types as ct
4341 on aps.call_type_id = ct.id
4342
4343 (132.1ms) /* MaxAssignmentsRule */
4344 delete ca
4345 from buffer_combined_availabilities_1458117728 as ca
4346 inner join buffer_schedules_1458117728 as sc
4347 on ca.schedule_id = sc.id
4348 inner join buffer_linkage_call_type_assignments_1458117728 as lcta
4349 on sc.linkage_instance_id = lcta.linkage_instance_id
4350 and sc.call_type_id = lcta.call_type_id
4351 and sc.is_weekend = lcta.is_weekend
4352 and sc.period_offset = lcta.period_offset
4353 and sc.calendar_schedule_id = lcta.calendar_schedule_id
4354 left join buffer_call_type_assignments_1458117728 as cta
4355 on ca.staff_id = cta.staff_id
4356 and sc.call_type_id = cta.call_type_id
4357 and sc.is_weekend = cta.is_weekend
4358 and sc.period_offset = cta.period_offset
4359 and sc.calendar_schedule_id = cta.calendar_schedule_id
4360 where
4361 sc.is_weekend in (NULL) /* "weekday (0), weekend (1)" checkboxes */
4362 and (coalesce(cta.assignments_count, 0) + lcta.assignments_count) > lcta.max_assignments;
4363
4364 (137.2ms) /* NegativeLinkRule */
4365 delete ca
4366 from buffer_combined_availabilities_1458117728 as ca use index (ix_buffer_combined_availabilities_composite_1)
4367 inner join buffer_negative_relations_1458117728 as nr use index (ix_buffer_negative_relations_composite_1)
4368 on ca.schedule_id = nr.schedule_id
4369 and ca.staff_id = nr.staff_id
4370
4371 (133.7ms) /* BrokenLinkageRule */
4372 truncate table buffer_combined_availability_linkages_1458117728
4373
4374 (145.4ms) insert into buffer_combined_availability_linkages_1458117728 (
4375 staff_id,
4376 linkage_instance_id,
4377 slots_count,
4378 is_primary,
4379 has_violations
4380 )
4381 select
4382 staff_id,
4383 linkage_instance_id,
4384 count(1) as slots_count,
4385 min(is_primary) as is_primary,
4386 max(has_violations) as has_violations
4387 from buffer_combined_availabilities_1458117728 use index (ix_buffer_combined_availabilities_composite_2)
4388 group by
4389 staff_id,
4390 linkage_instance_id
4391 order by null
4392
4393 (132.8ms) delete ca
4394 from
4395 buffer_combined_availabilities_1458117728 as ca use index (ix_buffer_combined_availabilities_composite_1)
4396 inner join buffer_schedules_1458117728 as sc
4397 on ca.schedule_id = sc.id
4398 inner join buffer_linkages_1458117728 as l
4399 on sc.linkage_instance_id = l.linkage_instance_id
4400 inner join buffer_combined_availability_linkages_1458117728 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
4401 on ca.staff_id = ls_1.staff_id
4402 and sc.linkage_instance_id = ls_1.linkage_instance_id
4403 left join buffer_schedule_linkages_1458117728 as ls_2 use index (ix_buffer_schedule_linkages_composite_1)
4404 on ca.staff_id = ls_2.staff_id
4405 and sc.linkage_instance_id = ls_2.linkage_instance_id
4406 where (ls_1.slots_count + coalesce(ls_2.slots_count, 0)) < l.slots_count_total /* not covering the whole chain */;
4407
4408 (153.6ms) select straight_join
4409 sc.schedule_on,
4410 sc.call_type_id,
4411 count(distinct ca.staff_id) as available_members_count,
4412 group_concat(
4413 distinct concat(if(ls_1.is_primary = 1, 'p', 's'), ca.staff_id)
4414 order by ls_1.is_primary desc, ca.staff_id
4415 separator ', '
4416 ) as available_members_ids,
4417 sc.linkage_instance_id,
4418 l.slots_count_total as linkage_slots_count
4419 from buffer_combined_availabilities_1458117728 as ca
4420 inner join buffer_schedules_1458117728 as sc
4421 on ca.schedule_id = sc.id
4422 inner join buffer_linkages_1458117728 as l
4423 on sc.linkage_instance_id = l.linkage_instance_id
4424 inner join buffer_combined_availability_linkages_1458117728 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
4425 on ca.staff_id = ls_1.staff_id
4426 and sc.linkage_instance_id = ls_1.linkage_instance_id
4427 and ls_1.has_violations = 0
4428 where sc.should_be_evaluated = 1
4429 and sc.should_be_populated = 1
4430 group by sc.schedule_on, sc.call_type_id, sc.linkage_instance_id, l.slots_count_total
4431 order by available_members_count, sc.schedule_on, sc.display_order
4432 limit 1
4433
4434 (133.4ms) truncate table buffer_rule_scores_1458117728
4435
4436 (133.1ms) truncate table buffer_rule_calc_filters_1458117728
4437
4438 (259.3ms) insert into buffer_rule_calc_filters_1458117728 (
4439 linkage_instance_id,
4440 staff_id
4441 ) values (41201748, 65),(41201748, 66),(41201748, 68),(41201748, 70),(41201748, 71),(41201748, 72),(41201748, 73),(41201748, 75),(41201748, 78),(41201748, 79),(41201748, 80),(41201748, 81),(41201748, 6960)
4442
4443 (135.8ms) /* CumulativePointTargetsRule */
4444 insert into buffer_rule_scores_1458117728 (
4445 linkage_instance_id,
4446 schedule_id,
4447 staff_id,
4448 rule_name,
4449 value
4450 )
4451 select
4452 b_schedules.linkage_instance_id,
4453 b_schedules.id as schedule_id,
4454 availabilities.staff_id,
4455 'CumulativePointTargetsRule' as rule_name,
4456 ((b_targets.adjusted_target - b_targets.scheduled) /
4457 b_targets.adjusted_target) as value
4458 from
4459 buffer_rule_calc_filters_1458117728 as filters
4460 inner join buffer_schedules_1458117728 as b_schedules
4461 on filters.linkage_instance_id = b_schedules.linkage_instance_id
4462 inner join buffer_combined_availabilities_1458117728 as availabilities
4463 on b_schedules.id = availabilities.schedule_id
4464 and filters.staff_id = availabilities.staff_id
4465 inner join buffer_cumulative_point_targets_1458117728 as b_targets
4466 on availabilities.staff_id = b_targets.staff_id
4467 and b_schedules.is_weekend = b_targets.is_weekend
4468 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
4469 order by null;
4470
4471 (133.6ms) truncate table buffer_rule_scores_with_corrections_1458117728
4472
4473 (134.2ms) insert into buffer_rule_scores_with_corrections_1458117728 (
4474 linkage_instance_id, schedule_id, staff_id, rule_name, value
4475 )
4476 select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id, rule_scores.rule_name,
4477 ifnull(rule_scores.value, max_values.max_value + 1) as value
4478 from buffer_rule_scores_1458117728 as rule_scores
4479 inner join (
4480 select rule_name, max(value) as max_value
4481 from buffer_rule_scores_1458117728
4482 group by rule_name
4483 order by null
4484 ) as max_values
4485 on rule_scores.rule_name = max_values.rule_name
4486 order by null
4487
4488 (133.0ms) select linkage_instance_id, staff_id, avg(slot_scores) as scores
4489 from (
4490 select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id,
4491 sum(
4492 if((total_values.total_value > 0), (rule_scores.value / total_values.total_value), 0) *
4493 rules.weight *
4494 total_values.slots_count
4495 ) as slot_scores
4496 from buffer_rule_scores_with_corrections_1458117728 as rule_scores
4497 inner join (
4498 select rule_name, sum(abs(value)) as total_value,
4499 count(distinct schedule_id) as slots_count
4500 from buffer_rule_scores_with_corrections_1458117728
4501 group by rule_name
4502 order by null
4503 ) as total_values
4504 on rule_scores.rule_name = total_values.rule_name
4505 inner join rules
4506 on rule_scores.rule_name = rules.type
4507 where rules.rule_set_id = 1530
4508 and rules.applied = 1
4509 group by rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id
4510 order by null
4511 ) as staff_scores
4512 group by linkage_instance_id, staff_id
4513 order by round(avg(slot_scores), 5) desc, rand()
4514 limit 1
4515
4516 PublishedBlock Load (135.0ms) SELECT `published_blocks`.* FROM `published_blocks` INNER JOIN `blocks` ON `blocks`.`id` = `published_blocks`.`block_id` WHERE `published_blocks`.`client_id` = 6 AND ('2017-12-01' BETWEEN blocks.start_date AND blocks.end_date) AND `published_blocks`.`calendar_schedule_id` = 6 ORDER BY `published_blocks`.`id` ASC LIMIT 1
4517 (131.0ms) BEGIN
4518 (133.3ms) SELECT COALESCE(pb.updated_at, pbct.updated_at)
4519 FROM call_types AS ct
4520 INNER JOIN calendar_schedules AS cs
4521 ON ct.calendar_schedule_id = cs.id
4522 INNER JOIN blocks AS b
4523 ON b.client_id = ct.client_id
4524 AND b.block_schedule_id = cs.block_schedule_id
4525 AND '2017-12-01' BETWEEN b.start_date AND b.end_date
4526 INNER JOIN published_blocks AS pb
4527 ON pb.client_id = ct.client_id
4528 AND pb.block_id = b.id
4529 AND pb.calendar_schedule_id = cs.id
4530 LEFT JOIN published_block_call_types AS pbct
4531 ON pbct.client_id = ct.client_id
4532 AND pbct.assignment_id = ct.id
4533 AND pbct.assignment_type = 'CallType'
4534 AND pbct.block_id = b.id
4535 AND (
4536 (1 << (DAYOFWEEK('2017-12-01') - 1) & pbct.days_of_week_mask) > 0
4537 )
4538 WHERE ct.id = 49
4539 AND (
4540 (
4541 pb.assignment_ids IS NULL
4542 AND (1 << (DAYOFWEEK('2017-12-01') - 1) & pb.days_of_week_mask) > 0
4543 )
4544 OR pbct.id IS NOT NULL
4545 )
4546
4547 CallType Load (132.7ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 49 LIMIT 1
4548 Client Load (133.5ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
4549 Staff Load (132.5ms) SELECT `staffs`.* FROM `staffs` WHERE `staffs`.`id` = 66 LIMIT 1
4550 Schedule Exists (131.2ms) SELECT 1 AS one FROM `schedules` WHERE `schedules`.`call_type_id` = 49 AND `schedules`.`client_id` = 6 AND `schedules`.`schedule_on` = '2017-12-01' LIMIT 1
4551 SQL (153.7ms) INSERT INTO `schedules` (`client_id`, `call_type_id`, `staff_id`, `schedule_on`, `created_at`, `updated_at`, `weekend_on`, `dayofweek_on`, `populate_method`, `creator_id`) VALUES (6, 49, 66, '2017-12-01', '2018-04-06 20:53:51', '2018-04-06 20:53:51', 0, 6, 'auto_populate_step', 166)
4552 VisibleAssignment Load (131.9ms) SELECT `visible_assignments`.* FROM `visible_assignments` WHERE `visible_assignments`.`client_id` = 6 AND `visible_assignments`.`date` = '2017-12-01' AND `visible_assignments`.`assignment_type` = 'CallType' AND `visible_assignments`.`assignment_id` = 49 ORDER BY `visible_assignments`.`id` ASC LIMIT 1
4553 DailyListSlot Load (132.6ms) SELECT `daily_list_slots`.* FROM `daily_list_slots` WHERE `daily_list_slots`.`schedule_on` = '2017-12-01' AND `daily_list_slots`.`staff_id` = 66 AND `daily_list_slots`.`call_type_id` = 49 ORDER BY daily_list_slots.position asc LIMIT 1
4554 (133.5ms) COMMIT
4555FLUSHED: nil:nil
4556 (144.4ms) UPDATE buffer_schedules_1458117728
4557 SET staff_id = 66,
4558 should_be_populated = 0,
4559 should_be_evaluated = 0
4560 WHERE
4561 call_type_id = 49
4562 AND schedule_on = '2017-12-01'
4563
4564 (137.8ms) delete from buffer_combined_availabilities_1458117728
4565 where linkage_instance_id = 41201748
4566
4567 (131.4ms) UPDATE buffer_rule_calc_schedules_1458117728
4568 SET staff_id = 66
4569 WHERE call_type_id = 49
4570 AND schedule_on = '2017-12-01'
4571
4572 (133.3ms) INSERT INTO buffer_rule_calc_schedules_1458117728
4573 SET staff_id = 66,
4574 call_type_id = 49,
4575 schedule_on = '2017-12-01',
4576 day_of_week_mask = 32
4577
4578 (131.6ms) /* NegativeLinkRule */
4579 UPDATE buffer_negative_relations_1458117728
4580 SET staff_id = 66
4581 WHERE affected_by_schedule_id = (
4582 SELECT id
4583 FROM buffer_schedules_1458117728
4584 WHERE schedule_on = '2017-12-01'
4585 AND call_type_id = 49
4586 )
4587
4588 (132.3ms) /* SpecializationOverlapRule */
4589 update buffer_staff_specializations_1458117728 as st_sp
4590 inner join max_applicable_call_types as mact
4591 on st_sp.specialization_id = mact.specialization_id
4592 and mact.call_type_id = 49
4593 inner join buffer_specialization_daily_counts_1458117728 as sp_dc
4594 on st_sp.specialization_id = sp_dc.specialization_id
4595 and sp_dc.staff_id is null
4596 and sp_dc.schedule_on = '2017-12-01'
4597 left join buffer_specialization_daily_counts_1458117728 as sp_dc_2
4598 on st_sp.specialization_id = sp_dc_2.specialization_id
4599 and st_sp.staff_id = sp_dc_2.staff_id
4600 and sp_dc_2.schedule_on = '2017-12-01'
4601 set sp_dc.staffs_scheduled = sp_dc.staffs_scheduled + 1
4602 where st_sp.staff_id = 66
4603 and sp_dc_2.id is null
4604
4605 (132.8ms) insert into buffer_specialization_daily_counts_1458117728 (
4606 specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
4607 )
4608 select sp.id as specialization_id,
4609 66 as staff_id,
4610 '2017-12-01' as schedule_on,
4611 1 as staffs_scheduled,
4612 sp.max_scheduled,
4613 sp_dc.should_be_evaluated
4614 from buffer_staff_specializations_1458117728 as st_sp
4615 inner join specializations as sp
4616 on st_sp.specialization_id = sp.id
4617 inner join max_applicable_call_types as mact
4618 on st_sp.specialization_id = mact.specialization_id
4619 and mact.call_type_id = 49
4620 inner join buffer_specialization_daily_counts_1458117728 as sp_dc
4621 on st_sp.specialization_id = sp_dc.specialization_id
4622 and sp_dc.staff_id is null
4623 and sp_dc.schedule_on = '2017-12-01'
4624 left join buffer_specialization_daily_counts_1458117728 as sp_dc_2
4625 on st_sp.specialization_id = sp_dc_2.specialization_id
4626 and st_sp.staff_id = sp_dc_2.staff_id
4627 and sp_dc_2.schedule_on = '2017-12-01'
4628 where st_sp.staff_id = 66
4629 and sp_dc_2.id is null
4630
4631 (133.9ms) /* MaxAssignmentsRule */
4632 delete from buffer_linkage_call_type_assignments_1458117728
4633 where linkage_instance_id = 41201748;
4634
4635 (132.0ms) /* MaxAssignmentsRule */
4636 update
4637 buffer_schedules_1458117728 as sc
4638 inner join call_types as ct
4639 on sc.call_type_id = ct.id
4640 and ct.active = 1
4641 inner join buffer_call_type_assignments_1458117728 as cta
4642 on sc.staff_id = cta.staff_id
4643 and sc.call_type_id = cta.call_type_id
4644 and sc.is_weekend = cta.is_weekend
4645 and sc.period_offset = cta.period_offset
4646 and sc.calendar_schedule_id = cta.calendar_schedule_id
4647 set cta.assignments_count = cta.assignments_count + 1
4648 where
4649 sc.schedule_on = '2017-12-01'
4650 and sc.call_type_id = 49
4651 and sc.staff_id = 66
4652
4653 (134.4ms) insert into buffer_call_type_assignments_1458117728 (
4654 staff_id,
4655 call_type_id,
4656 is_weekend,
4657 period_offset,
4658 calendar_schedule_id,
4659 assignments_count
4660 )
4661 select
4662 sc.staff_id,
4663 sc.call_type_id,
4664 sc.is_weekend,
4665 sc.period_offset,
4666 sc.calendar_schedule_id,
4667 1 as assignments_count
4668 from buffer_schedules_1458117728 as sc
4669 where
4670 sc.staff_id = 66
4671 and sc.schedule_on = '2017-12-01'
4672 and sc.call_type_id = 49
4673
4674 (133.3ms) /* UnassignedDaysRule */
4675 delete from buffer_linkage_assigned_days_1458117728
4676 where linkage_instance_id = 41201748
4677
4678 (134.4ms) /* UnassignedDaysRule */
4679 UPDATE buffer_staff_assigned_days_1458117728 as sad
4680 inner join call_types as ct
4681 on ct.id = 49
4682 and ct.unassigned_day = 0
4683 SET sad.is_assigned = 1
4684 WHERE sad.staff_id = 66
4685 AND sad.schedule_on = '2017-12-01'
4686
4687 (134.1ms) delete
4688 from buffer_linkage_point_targets_1458117728
4689 where linkage_instance_id = 41201748
4690
4691 (133.2ms) truncate table buffer_tmp_targets_scheduled_1458117728
4692
4693 (137.2ms) insert into buffer_tmp_targets_scheduled_1458117728 (
4694 block_id,
4695 calendar_schedule_id,
4696 staff_id,
4697 assignment_id,
4698 assignment_type,
4699 day_of_week_mask,
4700 is_weekend,
4701 scheduled,
4702 other_scheduled
4703 )
4704 select
4705 pt.block_id,
4706 pt.calendar_schedule_id,
4707 pt.staff_id,
4708 0 as assignment_id,
4709 '' as assignment_type,
4710 0 as day_of_week_mask,
4711 pt.is_weekend,
4712 case
4713 when (sc.calendar_schedule_id = pt.calendar_schedule_id) then ci.points
4714 else 0.0
4715 end as scheduled,
4716 case
4717 when (sc.calendar_schedule_id != pt.calendar_schedule_id) then ci.points
4718 else 0.0
4719 end as other_scheduled
4720 from
4721 buffer_schedules_1458117728 as sc
4722 inner join buffer_counter_increments_1458117728 as ci
4723 on sc.id = ci.schedule_id
4724 and ci.points != 0
4725 inner join assign_staff_types as ast
4726 on sc.staff_id = ast.staff_id
4727 and sc.schedule_on between ast.begin_date and coalesce(ast.end_date, '9999-12-31')
4728 inner join staff_types as st
4729 on ast.staff_type_id = st.id
4730 inner join buffer_point_targets_1458117728 as pt
4731 on sc.block_id = pt.block_id
4732 and st.point_hour_schedule_id = pt.calendar_schedule_id
4733 and sc.staff_id = pt.staff_id
4734 and sc.is_weekend = pt.is_weekend
4735 where
4736 sc.schedule_on = '2017-12-01'
4737 and sc.call_type_id = 49
4738 and sc.staff_id = 66
4739 order by null
4740
4741 (131.1ms) select 1 from buffer_tmp_targets_scheduled_1458117728
4742
4743 (134.5ms) update
4744 buffer_tmp_targets_scheduled_1458117728 as sch_t
4745 inner join buffer_point_targets_1458117728 as pt
4746 on sch_t.block_id = pt.block_id
4747 and sch_t.calendar_schedule_id = pt.calendar_schedule_id
4748 and sch_t.staff_id = pt.staff_id
4749 and sch_t.is_weekend = pt.is_weekend
4750 set
4751 pt.scheduled = pt.scheduled + sch_t.scheduled,
4752 pt.scheduled_delta = sch_t.scheduled,
4753 pt.other_scheduled = pt.other_scheduled + sch_t.other_scheduled,
4754 pt.other_scheduled_delta = sch_t.other_scheduled
4755
4756 (131.2ms) select 1 from buffer_tmp_targets_scheduled_1458117728
4757 where other_scheduled != 0
4758
4759 (133.7ms) update
4760 buffer_tmp_targets_scheduled_1458117728 as sch_t
4761 inner join buffer_point_targets_1458117728 as pt
4762 on sch_t.block_id = pt.block_id
4763 and sch_t.calendar_schedule_id = pt.calendar_schedule_id
4764 and (
4765 sch_t.staff_id = pt.staff_id
4766 or sch_t.other_scheduled != 0
4767 )
4768 and sch_t.is_weekend = pt.is_weekend
4769 set
4770 pt.raw_target_delta = 0,
4771 pt.target_delta = 0,
4772 pt.scheduled_delta = 0,
4773 pt.other_scheduled_delta = 0
4774
4775 (157.6ms) delete
4776 from buffer_linkage_hour_targets_1458117728
4777 where linkage_instance_id = 41201748
4778
4779 (133.0ms) truncate table buffer_tmp_targets_scheduled_1458117728
4780
4781 (132.1ms) insert into buffer_tmp_targets_scheduled_1458117728 (
4782 block_id,
4783 calendar_schedule_id,
4784 staff_id,
4785 assignment_id,
4786 assignment_type,
4787 day_of_week_mask,
4788 is_weekend,
4789 scheduled,
4790 other_scheduled
4791 )
4792 select
4793 ht.block_id,
4794 ht.calendar_schedule_id,
4795 ht.staff_id,
4796 0 as assignment_id,
4797 '' as assignment_type,
4798 0 as day_of_week_mask,
4799 ht.is_weekend,
4800 case
4801 when (sc.calendar_schedule_id = ht.calendar_schedule_id) then ci.hours
4802 else 0.0
4803 end as scheduled,
4804 case
4805 when (sc.calendar_schedule_id != ht.calendar_schedule_id) then ci.hours
4806 else 0.0
4807 end as other_scheduled
4808 from
4809 buffer_schedules_1458117728 as sc
4810 inner join buffer_counter_increments_1458117728 as ci
4811 on sc.id = ci.schedule_id
4812 and ci.hours > 0
4813 inner join assign_staff_types as ast
4814 on sc.staff_id = ast.staff_id
4815 and sc.schedule_on between ast.begin_date and coalesce(ast.end_date, '9999-12-31')
4816 inner join staff_types as st
4817 on ast.staff_type_id = st.id
4818 inner join buffer_hour_targets_1458117728 as ht
4819 on sc.block_id = ht.block_id
4820 and st.point_hour_schedule_id = ht.calendar_schedule_id
4821 and sc.staff_id = ht.staff_id
4822 and sc.is_weekend = ht.is_weekend
4823 where
4824 sc.schedule_on = '2017-12-01'
4825 and sc.call_type_id = 49
4826 and sc.staff_id = 66
4827 order by null
4828
4829 (131.2ms) select 1 from buffer_tmp_targets_scheduled_1458117728
4830
4831 (132.6ms) /* AssignmentLimitsPerPeriod */
4832 /* Unique Key: assignment_limit_id, staff_id, start_date */
4833 insert into buffer_staff_assignments_count_periods_1458117728 (
4834 assignment_limit_id, staff_id, start_date, end_date, assignments_count
4835 )
4836 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
4837 1 as assignments_count
4838 from buffer_schedules_1458117728 as sc
4839 inner join buffer_assignment_limit_call_types_1458117728 as alct
4840 on sc.call_type_id = alct.call_type_id
4841 inner join assignment_limits as al
4842 on alct.assignment_limit_id = al.id
4843 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
4844 and al.max_per_period_limit is not null
4845 inner join assign_staff_types as ast
4846 on sc.staff_id = ast.staff_id
4847 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
4848 inner join buffer_assignment_limit_staff_types_1458117728 as alst
4849 on alct.assignment_limit_id = alst.assignment_limit_id
4850 and ast.staff_type_id = alst.staff_type_id
4851 inner join (
4852 select assignment_limit_id, start_date, end_date
4853 from buffer_linkage_assignments_count_periods_1458117728
4854 group by assignment_limit_id, start_date, end_date
4855 order by null
4856 ) as lac
4857 on alct.assignment_limit_id = lac.assignment_limit_id
4858 and sc.schedule_on between lac.start_date and lac.end_date
4859 where sc.schedule_on = '2017-12-01'
4860 and sc.call_type_id = 49
4861 and sc.staff_id = 66
4862 on duplicate key update
4863 assignments_count = assignments_count + 1
4864
4865 (132.1ms) /* AssignmentLimitsPerWeek */
4866 /* Unique Key: assignment_limit_id, staff_id, start_date */
4867 insert into buffer_staff_assignments_count_weeks_1458117728 (
4868 assignment_limit_id, staff_id, start_date, end_date, assignments_count
4869 )
4870 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
4871 1 as assignments_count
4872 from buffer_schedules_1458117728 as sc
4873 inner join buffer_assignment_limit_call_types_1458117728 as alct
4874 on sc.call_type_id = alct.call_type_id
4875 inner join assignment_limits as al
4876 on alct.assignment_limit_id = al.id
4877 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
4878 and al.max_weekly_limit is not null
4879 inner join assign_staff_types as ast
4880 on sc.staff_id = ast.staff_id
4881 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
4882 inner join buffer_assignment_limit_staff_types_1458117728 as alst
4883 on alct.assignment_limit_id = alst.assignment_limit_id
4884 and ast.staff_type_id = alst.staff_type_id
4885 inner join (
4886 select assignment_limit_id, start_date, end_date
4887 from buffer_linkage_assignments_count_weeks_1458117728
4888 group by assignment_limit_id, start_date, end_date
4889 order by null
4890 ) as lac
4891 on alct.assignment_limit_id = lac.assignment_limit_id
4892 and sc.schedule_on between lac.start_date and lac.end_date
4893 where sc.schedule_on = '2017-12-01'
4894 and sc.call_type_id = 49
4895 and sc.staff_id = 66
4896 on duplicate key update
4897 assignments_count = assignments_count + 1
4898
4899 (134.4ms) /* AssignmentLimitsRolling */
4900 /* Unique Key: assignment_limit_id, staff_id, start_date */
4901 insert into buffer_staff_assignments_count_rolling_1458117728 (
4902 assignment_limit_id, staff_id, start_date, end_date, assignments_count
4903 )
4904 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
4905 1 as assignments_count
4906 from buffer_schedules_1458117728 as sc
4907 inner join buffer_assignment_limit_call_types_1458117728 as alct
4908 on sc.call_type_id = alct.call_type_id
4909 inner join assignment_limits as al
4910 on alct.assignment_limit_id = al.id
4911 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
4912 and al.max_rolling_period is not null
4913 and al.max_rolling_limit is not null
4914 inner join assign_staff_types as ast
4915 on sc.staff_id = ast.staff_id
4916 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
4917 inner join buffer_assignment_limit_staff_types_1458117728 as alst
4918 on alct.assignment_limit_id = alst.assignment_limit_id
4919 and ast.staff_type_id = alst.staff_type_id
4920 inner join (
4921 select assignment_limit_id, start_date, end_date
4922 from buffer_linkage_assignments_count_rolling_1458117728
4923 group by assignment_limit_id, start_date, end_date
4924 order by null
4925 ) as lac
4926 on alct.assignment_limit_id = lac.assignment_limit_id
4927 and sc.schedule_on between lac.start_date and lac.end_date
4928 where sc.schedule_on = '2017-12-01'
4929 and sc.call_type_id = 49
4930 and sc.staff_id = 66
4931 on duplicate key update
4932 assignments_count = assignments_count + 1
4933
4934 (132.2ms) /* AssignmentLimitsConsecutive */
4935 /* Unique Key: assignment_limit_id, staff_id, schedule_on, start_date */
4936 insert ignore into buffer_staff_assignments_count_consecutive_1458117728 (
4937 assignment_limit_id, staff_id, schedule_on, start_date, end_date
4938 )
4939 select lac.assignment_limit_id, sc.staff_id, sc.schedule_on, lac.start_date, lac.end_date
4940 from buffer_schedules_1458117728 as sc
4941 inner join buffer_assignment_limit_call_types_1458117728 as alct
4942 on sc.call_type_id = alct.call_type_id
4943 inner join assignment_limits as al
4944 on alct.assignment_limit_id = al.id
4945 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
4946 and al.max_consecutive_limit is not null
4947 inner join assign_staff_types as ast
4948 on sc.staff_id = ast.staff_id
4949 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
4950 inner join buffer_assignment_limit_staff_types_1458117728 as alst
4951 on alct.assignment_limit_id = alst.assignment_limit_id
4952 and ast.staff_type_id = alst.staff_type_id
4953 inner join (
4954 select assignment_limit_id, start_date, end_date
4955 from buffer_linkage_assignments_count_consecutive_1458117728
4956 group by assignment_limit_id, start_date, end_date
4957 order by null
4958 ) as lac
4959 on alct.assignment_limit_id = lac.assignment_limit_id
4960 and sc.schedule_on between lac.start_date and lac.end_date
4961 where sc.schedule_on = '2017-12-01'
4962 and sc.call_type_id = 49
4963 and sc.staff_id = 66
4964
4965INFO : (04-06 20:53:56) scheduled for: plan unit: [id:41201748] [2017-12-01 - GI1], Gary Allen. DEPTH(1)
4966 NegativeLink Load (133.1ms) SELECT `negative_links`.* FROM `negative_links` WHERE `negative_links`.`client_id` = 6
4967 (132.0ms) /* SpecializationOverlapRule */
4968 delete ca
4969 from buffer_combined_availabilities_1458117728 as ca use index (ix_buffer_combined_availabilities_composite_1)
4970 inner join buffer_schedules_1458117728 as sc
4971 on ca.schedule_id = sc.id
4972 inner join buffer_staff_specializations_1458117728 as ssp
4973 on ca.staff_id = ssp.staff_id
4974 inner join max_applicable_call_types as mact
4975 on ssp.specialization_id = mact.specialization_id
4976 and sc.call_type_id = mact.call_type_id
4977 inner join buffer_specialization_daily_counts_1458117728 as sdc use index (ix_buffer_specialization_daily_counts_composite_1)
4978 on ssp.specialization_id = sdc.specialization_id
4979 and sc.schedule_on = sdc.schedule_on
4980 and sdc.staff_id is null
4981 left join buffer_specialization_daily_counts_1458117728 as sdc_2 use index (ix_buffer_specialization_daily_counts_composite_1)
4982 on ssp.specialization_id = sdc_2.specialization_id
4983 and sc.schedule_on = sdc_2.schedule_on
4984 and ca.staff_id = sdc_2.staff_id
4985 where sdc.should_be_evaluated = 1
4986 and (sdc.staffs_scheduled + if(sdc_2.id is null, 1, 0)) > sdc.max_scheduled
4987
4988 (133.5ms) delete ca
4989 from buffer_combined_availabilities_1458117728 as ca
4990 inner join (
4991 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
4992 sum(lac.assignments_count) as assignments_count
4993 from (
4994 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4995 from buffer_combined_availabilities_1458117728 as ca
4996 inner join buffer_schedules_1458117728 as sc
4997 on ca.schedule_id = sc.id
4998 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
4999 order by null
5000 ) as ca_sc
5001 inner join buffer_linkage_assignments_count_weeks_1458117728 as lac
5002 on ca_sc.linkage_instance_id = lac.linkage_instance_id
5003 and ca_sc.schedule_on = lac.schedule_on
5004 inner join buffer_assignment_limit_staff_types_1458117728 as alst
5005 on lac.assignment_limit_id = alst.assignment_limit_id
5006 and ca_sc.staff_type_id = alst.staff_type_id
5007 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
5008 order by null
5009 ) as lac
5010 on ca.linkage_instance_id = lac.linkage_instance_id
5011 and ca.staff_id = lac.staff_id
5012 inner join assignment_limits as al
5013 on lac.assignment_limit_id = al.id
5014 left join buffer_staff_assignments_count_weeks_1458117728 as sac
5015 on lac.assignment_limit_id = sac.assignment_limit_id
5016 and lac.staff_id = sac.staff_id
5017 and lac.start_date = sac.start_date
5018 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_weekly_limit
5019
5020 (132.4ms) delete ca
5021 from buffer_combined_availabilities_1458117728 as ca
5022 inner join (
5023 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
5024 sum(lac.assignments_count) as assignments_count
5025 from (
5026 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
5027 from buffer_combined_availabilities_1458117728 as ca
5028 inner join buffer_schedules_1458117728 as sc
5029 on ca.schedule_id = sc.id
5030 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
5031 order by null
5032 ) as ca_sc
5033 inner join buffer_linkage_assignments_count_periods_1458117728 as lac
5034 on ca_sc.linkage_instance_id = lac.linkage_instance_id
5035 and ca_sc.schedule_on = lac.schedule_on
5036 inner join buffer_assignment_limit_staff_types_1458117728 as alst
5037 on lac.assignment_limit_id = alst.assignment_limit_id
5038 and ca_sc.staff_type_id = alst.staff_type_id
5039 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
5040 order by null
5041 ) as lac
5042 on ca.linkage_instance_id = lac.linkage_instance_id
5043 and ca.staff_id = lac.staff_id
5044 inner join assignment_limits as al
5045 on lac.assignment_limit_id = al.id
5046 left join buffer_staff_assignments_count_periods_1458117728 as sac
5047 on lac.assignment_limit_id = sac.assignment_limit_id
5048 and lac.staff_id = sac.staff_id
5049 and lac.start_date = sac.start_date
5050 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_per_period_limit
5051
5052 (132.8ms) delete ca
5053 from buffer_combined_availabilities_1458117728 as ca
5054 inner join (
5055 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
5056 sum(lac.assignments_count) as assignments_count
5057 from (
5058 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
5059 from buffer_combined_availabilities_1458117728 as ca
5060 inner join buffer_schedules_1458117728 as sc
5061 on ca.schedule_id = sc.id
5062 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
5063 order by null
5064 ) as ca_sc
5065 inner join buffer_linkage_assignments_count_rolling_1458117728 as lac
5066 on ca_sc.linkage_instance_id = lac.linkage_instance_id
5067 and ca_sc.schedule_on = lac.schedule_on
5068 inner join buffer_assignment_limit_staff_types_1458117728 as alst
5069 on lac.assignment_limit_id = alst.assignment_limit_id
5070 and ca_sc.staff_type_id = alst.staff_type_id
5071 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
5072 order by null
5073 ) as lac
5074 on ca.linkage_instance_id = lac.linkage_instance_id
5075 and ca.staff_id = lac.staff_id
5076 inner join assignment_limits as al
5077 on lac.assignment_limit_id = al.id
5078 left join buffer_staff_assignments_count_rolling_1458117728 as sac
5079 on lac.assignment_limit_id = sac.assignment_limit_id
5080 and lac.staff_id = sac.staff_id
5081 and lac.start_date = sac.start_date
5082 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_rolling_limit
5083
5084 (132.6ms) delete ca
5085 from buffer_combined_availabilities_1458117728 as ca
5086 inner join (
5087 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
5088 count(distinct if(sac.id is null, lac.schedule_on, null)) as assignments_count
5089 from (
5090 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
5091 from buffer_combined_availabilities_1458117728 as ca
5092 inner join buffer_schedules_1458117728 as sc
5093 on ca.schedule_id = sc.id
5094 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
5095 order by null
5096 ) as ca_sc
5097 inner join buffer_linkage_assignments_count_consecutive_1458117728 as lac
5098 on ca_sc.linkage_instance_id = lac.linkage_instance_id
5099 and ca_sc.schedule_on = lac.schedule_on
5100 inner join buffer_assignment_limit_staff_types_1458117728 as alst
5101 on lac.assignment_limit_id = alst.assignment_limit_id
5102 and ca_sc.staff_type_id = alst.staff_type_id
5103 left join buffer_staff_assignments_count_consecutive_1458117728 as sac
5104 on lac.assignment_limit_id = sac.assignment_limit_id
5105 and ca_sc.staff_id = sac.staff_id
5106 and lac.schedule_on = sac.schedule_on
5107 and lac.start_date = sac.start_date
5108 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
5109 order by null
5110 ) as lac
5111 on ca.linkage_instance_id = lac.linkage_instance_id
5112 and ca.staff_id = lac.staff_id
5113 inner join assignment_limits as al
5114 on lac.assignment_limit_id = al.id
5115 left join (
5116 select assignment_limit_id, staff_id, start_date,
5117 count(schedule_on) as assignments_count
5118 from buffer_staff_assignments_count_consecutive_1458117728
5119 group by assignment_limit_id, staff_id, start_date
5120 ) as sac
5121 on lac.assignment_limit_id = sac.assignment_limit_id
5122 and lac.staff_id = sac.staff_id
5123 and lac.start_date = sac.start_date
5124 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_consecutive_limit
5125
5126 (140.8ms) delete ca
5127 from
5128 buffer_combined_availabilities_1458117728 as ca
5129 inner join buffer_schedules_1458117728 as sc
5130 on ca.schedule_id = sc.id
5131 inner join buffer_linkage_point_targets_1458117728 as lpt
5132 on sc.linkage_instance_id = lpt.linkage_instance_id
5133 and ca.staff_id = lpt.staff_id
5134 and sc.is_weekend = lpt.is_weekend
5135 and lpt.period_offset = -1
5136 and sc.calendar_schedule_id = lpt.calendar_schedule_id
5137 inner join buffer_cumulative_point_targets_1458117728 as pt
5138 on ca.staff_id = pt.staff_id
5139 and sc.is_weekend = pt.is_weekend
5140 and sc.calendar_schedule_id = pt.calendar_schedule_id
5141 where
5142 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
5143 and (pt.scheduled + lpt.scheduled) > (pt.adjusted_target /* raw_target | adjusted_target */ * (1 + 0 /* hours threshold */ / 100.0));
5144
5145 (131.8ms) select
5146 coalesce(max(
5147 case
5148 when (ct.max_weekday_assignments > 0) then 1
5149 else 0
5150 end
5151 ), 0) as weekday_flag,
5152 coalesce(max(
5153 case
5154 when (ct.max_weekend_assignments > 0) then 1
5155 else 0
5156 end
5157 ), 0) as weekend_flag
5158 from
5159 buffer_auto_populate_slots_1458117728 as aps
5160 inner join call_types as ct
5161 on aps.call_type_id = ct.id
5162
5163 (132.7ms) /* MaxAssignmentsRule */
5164 delete ca
5165 from buffer_combined_availabilities_1458117728 as ca
5166 inner join buffer_schedules_1458117728 as sc
5167 on ca.schedule_id = sc.id
5168 inner join buffer_linkage_call_type_assignments_1458117728 as lcta
5169 on sc.linkage_instance_id = lcta.linkage_instance_id
5170 and sc.call_type_id = lcta.call_type_id
5171 and sc.is_weekend = lcta.is_weekend
5172 and sc.period_offset = lcta.period_offset
5173 and sc.calendar_schedule_id = lcta.calendar_schedule_id
5174 left join buffer_call_type_assignments_1458117728 as cta
5175 on ca.staff_id = cta.staff_id
5176 and sc.call_type_id = cta.call_type_id
5177 and sc.is_weekend = cta.is_weekend
5178 and sc.period_offset = cta.period_offset
5179 and sc.calendar_schedule_id = cta.calendar_schedule_id
5180 where
5181 sc.is_weekend in (NULL) /* "weekday (0), weekend (1)" checkboxes */
5182 and (coalesce(cta.assignments_count, 0) + lcta.assignments_count) > lcta.max_assignments;
5183
5184 (131.6ms) /* NegativeLinkRule */
5185 delete ca
5186 from buffer_combined_availabilities_1458117728 as ca use index (ix_buffer_combined_availabilities_composite_1)
5187 inner join buffer_negative_relations_1458117728 as nr use index (ix_buffer_negative_relations_composite_1)
5188 on ca.schedule_id = nr.schedule_id
5189 and ca.staff_id = nr.staff_id
5190
5191 (134.3ms) /* BrokenLinkageRule */
5192 truncate table buffer_combined_availability_linkages_1458117728
5193
5194 (139.7ms) insert into buffer_combined_availability_linkages_1458117728 (
5195 staff_id,
5196 linkage_instance_id,
5197 slots_count,
5198 is_primary,
5199 has_violations
5200 )
5201 select
5202 staff_id,
5203 linkage_instance_id,
5204 count(1) as slots_count,
5205 min(is_primary) as is_primary,
5206 max(has_violations) as has_violations
5207 from buffer_combined_availabilities_1458117728 use index (ix_buffer_combined_availabilities_composite_2)
5208 group by
5209 staff_id,
5210 linkage_instance_id
5211 order by null
5212
5213 (133.8ms) delete ca
5214 from
5215 buffer_combined_availabilities_1458117728 as ca use index (ix_buffer_combined_availabilities_composite_1)
5216 inner join buffer_schedules_1458117728 as sc
5217 on ca.schedule_id = sc.id
5218 inner join buffer_linkages_1458117728 as l
5219 on sc.linkage_instance_id = l.linkage_instance_id
5220 inner join buffer_combined_availability_linkages_1458117728 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
5221 on ca.staff_id = ls_1.staff_id
5222 and sc.linkage_instance_id = ls_1.linkage_instance_id
5223 left join buffer_schedule_linkages_1458117728 as ls_2 use index (ix_buffer_schedule_linkages_composite_1)
5224 on ca.staff_id = ls_2.staff_id
5225 and sc.linkage_instance_id = ls_2.linkage_instance_id
5226 where (ls_1.slots_count + coalesce(ls_2.slots_count, 0)) < l.slots_count_total /* not covering the whole chain */;
5227
5228 (154.5ms) select straight_join
5229 sc.schedule_on,
5230 sc.call_type_id,
5231 count(distinct ca.staff_id) as available_members_count,
5232 group_concat(
5233 distinct concat(if(ls_1.is_primary = 1, 'p', 's'), ca.staff_id)
5234 order by ls_1.is_primary desc, ca.staff_id
5235 separator ', '
5236 ) as available_members_ids,
5237 sc.linkage_instance_id,
5238 l.slots_count_total as linkage_slots_count
5239 from buffer_combined_availabilities_1458117728 as ca
5240 inner join buffer_schedules_1458117728 as sc
5241 on ca.schedule_id = sc.id
5242 inner join buffer_linkages_1458117728 as l
5243 on sc.linkage_instance_id = l.linkage_instance_id
5244 inner join buffer_combined_availability_linkages_1458117728 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
5245 on ca.staff_id = ls_1.staff_id
5246 and sc.linkage_instance_id = ls_1.linkage_instance_id
5247 and ls_1.has_violations = 0
5248 where sc.should_be_evaluated = 1
5249 and sc.should_be_populated = 1
5250 group by sc.schedule_on, sc.call_type_id, sc.linkage_instance_id, l.slots_count_total
5251 order by available_members_count, sc.schedule_on, sc.display_order
5252 limit 1
5253
5254 (133.8ms) truncate table buffer_rule_scores_1458117728
5255
5256 (133.5ms) truncate table buffer_rule_calc_filters_1458117728
5257
5258 (134.2ms) insert into buffer_rule_calc_filters_1458117728 (
5259 linkage_instance_id,
5260 staff_id
5261 ) values (5201749, 65),(5201749, 66),(5201749, 68),(5201749, 70),(5201749, 71),(5201749, 72),(5201749, 73),(5201749, 75),(5201749, 78),(5201749, 79),(5201749, 80),(5201749, 81),(5201749, 6960)
5262
5263 (135.2ms) /* CumulativePointTargetsRule */
5264 insert into buffer_rule_scores_1458117728 (
5265 linkage_instance_id,
5266 schedule_id,
5267 staff_id,
5268 rule_name,
5269 value
5270 )
5271 select
5272 b_schedules.linkage_instance_id,
5273 b_schedules.id as schedule_id,
5274 availabilities.staff_id,
5275 'CumulativePointTargetsRule' as rule_name,
5276 ((b_targets.adjusted_target - b_targets.scheduled) /
5277 b_targets.adjusted_target) as value
5278 from
5279 buffer_rule_calc_filters_1458117728 as filters
5280 inner join buffer_schedules_1458117728 as b_schedules
5281 on filters.linkage_instance_id = b_schedules.linkage_instance_id
5282 inner join buffer_combined_availabilities_1458117728 as availabilities
5283 on b_schedules.id = availabilities.schedule_id
5284 and filters.staff_id = availabilities.staff_id
5285 inner join buffer_cumulative_point_targets_1458117728 as b_targets
5286 on availabilities.staff_id = b_targets.staff_id
5287 and b_schedules.is_weekend = b_targets.is_weekend
5288 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
5289 order by null;
5290
5291 (133.6ms) truncate table buffer_rule_scores_with_corrections_1458117728
5292
5293 (134.2ms) insert into buffer_rule_scores_with_corrections_1458117728 (
5294 linkage_instance_id, schedule_id, staff_id, rule_name, value
5295 )
5296 select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id, rule_scores.rule_name,
5297 ifnull(rule_scores.value, max_values.max_value + 1) as value
5298 from buffer_rule_scores_1458117728 as rule_scores
5299 inner join (
5300 select rule_name, max(value) as max_value
5301 from buffer_rule_scores_1458117728
5302 group by rule_name
5303 order by null
5304 ) as max_values
5305 on rule_scores.rule_name = max_values.rule_name
5306 order by null
5307
5308 (133.4ms) select linkage_instance_id, staff_id, avg(slot_scores) as scores
5309 from (
5310 select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id,
5311 sum(
5312 if((total_values.total_value > 0), (rule_scores.value / total_values.total_value), 0) *
5313 rules.weight *
5314 total_values.slots_count
5315 ) as slot_scores
5316 from buffer_rule_scores_with_corrections_1458117728 as rule_scores
5317 inner join (
5318 select rule_name, sum(abs(value)) as total_value,
5319 count(distinct schedule_id) as slots_count
5320 from buffer_rule_scores_with_corrections_1458117728
5321 group by rule_name
5322 order by null
5323 ) as total_values
5324 on rule_scores.rule_name = total_values.rule_name
5325 inner join rules
5326 on rule_scores.rule_name = rules.type
5327 where rules.rule_set_id = 1530
5328 and rules.applied = 1
5329 group by rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id
5330 order by null
5331 ) as staff_scores
5332 group by linkage_instance_id, staff_id
5333 order by round(avg(slot_scores), 5) desc, rand()
5334 limit 1
5335
5336 PublishedBlock Load (133.2ms) SELECT `published_blocks`.* FROM `published_blocks` INNER JOIN `blocks` ON `blocks`.`id` = `published_blocks`.`block_id` WHERE `published_blocks`.`client_id` = 6 AND ('2017-12-04' BETWEEN blocks.start_date AND blocks.end_date) AND `published_blocks`.`calendar_schedule_id` = 6 ORDER BY `published_blocks`.`id` ASC LIMIT 1
5337 (140.3ms) BEGIN
5338 (143.2ms) SELECT COALESCE(pb.updated_at, pbct.updated_at)
5339 FROM call_types AS ct
5340 INNER JOIN calendar_schedules AS cs
5341 ON ct.calendar_schedule_id = cs.id
5342 INNER JOIN blocks AS b
5343 ON b.client_id = ct.client_id
5344 AND b.block_schedule_id = cs.block_schedule_id
5345 AND '2017-12-04' BETWEEN b.start_date AND b.end_date
5346 INNER JOIN published_blocks AS pb
5347 ON pb.client_id = ct.client_id
5348 AND pb.block_id = b.id
5349 AND pb.calendar_schedule_id = cs.id
5350 LEFT JOIN published_block_call_types AS pbct
5351 ON pbct.client_id = ct.client_id
5352 AND pbct.assignment_id = ct.id
5353 AND pbct.assignment_type = 'CallType'
5354 AND pbct.block_id = b.id
5355 AND (
5356 (1 << (DAYOFWEEK('2017-12-04') - 1) & pbct.days_of_week_mask) > 0
5357 )
5358 WHERE ct.id = 49
5359 AND (
5360 (
5361 pb.assignment_ids IS NULL
5362 AND (1 << (DAYOFWEEK('2017-12-04') - 1) & pb.days_of_week_mask) > 0
5363 )
5364 OR pbct.id IS NOT NULL
5365 )
5366
5367 CallType Load (133.5ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 49 LIMIT 1
5368 Client Load (136.1ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
5369 Staff Load (133.2ms) SELECT `staffs`.* FROM `staffs` WHERE `staffs`.`id` = 66 LIMIT 1
5370 Schedule Exists (136.9ms) SELECT 1 AS one FROM `schedules` WHERE `schedules`.`call_type_id` = 49 AND `schedules`.`client_id` = 6 AND `schedules`.`schedule_on` = '2017-12-04' LIMIT 1
5371 SQL (151.5ms) 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, 66, '2017-12-04', '2018-04-06 20:54:13', '2018-04-06 20:54:13', 0, 2, 'auto_populate_step', 166)
5372 VisibleAssignment Load (132.1ms) SELECT `visible_assignments`.* FROM `visible_assignments` WHERE `visible_assignments`.`client_id` = 6 AND `visible_assignments`.`date` = '2017-12-04' AND `visible_assignments`.`assignment_type` = 'CallType' AND `visible_assignments`.`assignment_id` = 49 ORDER BY `visible_assignments`.`id` ASC LIMIT 1
5373 DailyListSlot Load (132.5ms) SELECT `daily_list_slots`.* FROM `daily_list_slots` WHERE `daily_list_slots`.`schedule_on` = '2017-12-04' AND `daily_list_slots`.`staff_id` = 66 AND `daily_list_slots`.`call_type_id` = 49 ORDER BY daily_list_slots.position asc LIMIT 1
5374 (134.1ms) COMMIT
5375FLUSHED: nil:nil
5376 (133.6ms) UPDATE buffer_schedules_1458117728
5377 SET staff_id = 66,
5378 should_be_populated = 0,
5379 should_be_evaluated = 0
5380 WHERE
5381 call_type_id = 49
5382 AND schedule_on = '2017-12-04'
5383
5384 (134.2ms) delete from buffer_combined_availabilities_1458117728
5385 where linkage_instance_id = 5201749
5386
5387 (133.4ms) UPDATE buffer_rule_calc_schedules_1458117728
5388 SET staff_id = 66
5389 WHERE call_type_id = 49
5390 AND schedule_on = '2017-12-04'
5391
5392 (133.1ms) INSERT INTO buffer_rule_calc_schedules_1458117728
5393 SET staff_id = 66,
5394 call_type_id = 49,
5395 schedule_on = '2017-12-04',
5396 day_of_week_mask = 2
5397
5398 (133.4ms) /* NegativeLinkRule */
5399 UPDATE buffer_negative_relations_1458117728
5400 SET staff_id = 66
5401 WHERE affected_by_schedule_id = (
5402 SELECT id
5403 FROM buffer_schedules_1458117728
5404 WHERE schedule_on = '2017-12-04'
5405 AND call_type_id = 49
5406 )
5407
5408 (131.6ms) /* SpecializationOverlapRule */
5409 update buffer_staff_specializations_1458117728 as st_sp
5410 inner join max_applicable_call_types as mact
5411 on st_sp.specialization_id = mact.specialization_id
5412 and mact.call_type_id = 49
5413 inner join buffer_specialization_daily_counts_1458117728 as sp_dc
5414 on st_sp.specialization_id = sp_dc.specialization_id
5415 and sp_dc.staff_id is null
5416 and sp_dc.schedule_on = '2017-12-04'
5417 left join buffer_specialization_daily_counts_1458117728 as sp_dc_2
5418 on st_sp.specialization_id = sp_dc_2.specialization_id
5419 and st_sp.staff_id = sp_dc_2.staff_id
5420 and sp_dc_2.schedule_on = '2017-12-04'
5421 set sp_dc.staffs_scheduled = sp_dc.staffs_scheduled + 1
5422 where st_sp.staff_id = 66
5423 and sp_dc_2.id is null
5424
5425 (131.7ms) insert into buffer_specialization_daily_counts_1458117728 (
5426 specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
5427 )
5428 select sp.id as specialization_id,
5429 66 as staff_id,
5430 '2017-12-04' as schedule_on,
5431 1 as staffs_scheduled,
5432 sp.max_scheduled,
5433 sp_dc.should_be_evaluated
5434 from buffer_staff_specializations_1458117728 as st_sp
5435 inner join specializations as sp
5436 on st_sp.specialization_id = sp.id
5437 inner join max_applicable_call_types as mact
5438 on st_sp.specialization_id = mact.specialization_id
5439 and mact.call_type_id = 49
5440 inner join buffer_specialization_daily_counts_1458117728 as sp_dc
5441 on st_sp.specialization_id = sp_dc.specialization_id
5442 and sp_dc.staff_id is null
5443 and sp_dc.schedule_on = '2017-12-04'
5444 left join buffer_specialization_daily_counts_1458117728 as sp_dc_2
5445 on st_sp.specialization_id = sp_dc_2.specialization_id
5446 and st_sp.staff_id = sp_dc_2.staff_id
5447 and sp_dc_2.schedule_on = '2017-12-04'
5448 where st_sp.staff_id = 66
5449 and sp_dc_2.id is null
5450
5451 (133.7ms) /* MaxAssignmentsRule */
5452 delete from buffer_linkage_call_type_assignments_1458117728
5453 where linkage_instance_id = 5201749;
5454
5455 (134.5ms) /* MaxAssignmentsRule */
5456 update
5457 buffer_schedules_1458117728 as sc
5458 inner join call_types as ct
5459 on sc.call_type_id = ct.id
5460 and ct.active = 1
5461 inner join buffer_call_type_assignments_1458117728 as cta
5462 on sc.staff_id = cta.staff_id
5463 and sc.call_type_id = cta.call_type_id
5464 and sc.is_weekend = cta.is_weekend
5465 and sc.period_offset = cta.period_offset
5466 and sc.calendar_schedule_id = cta.calendar_schedule_id
5467 set cta.assignments_count = cta.assignments_count + 1
5468 where
5469 sc.schedule_on = '2017-12-04'
5470 and sc.call_type_id = 49
5471 and sc.staff_id = 66
5472
5473 (133.5ms) /* UnassignedDaysRule */
5474 delete from buffer_linkage_assigned_days_1458117728
5475 where linkage_instance_id = 5201749
5476
5477 (133.6ms) /* UnassignedDaysRule */
5478 UPDATE buffer_staff_assigned_days_1458117728 as sad
5479 inner join call_types as ct
5480 on ct.id = 49
5481 and ct.unassigned_day = 0
5482 SET sad.is_assigned = 1
5483 WHERE sad.staff_id = 66
5484 AND sad.schedule_on = '2017-12-04'
5485
5486 (134.2ms) delete
5487 from buffer_linkage_point_targets_1458117728
5488 where linkage_instance_id = 5201749
5489
5490 (133.3ms) truncate table buffer_tmp_targets_scheduled_1458117728
5491
5492 (136.4ms) insert into buffer_tmp_targets_scheduled_1458117728 (
5493 block_id,
5494 calendar_schedule_id,
5495 staff_id,
5496 assignment_id,
5497 assignment_type,
5498 day_of_week_mask,
5499 is_weekend,
5500 scheduled,
5501 other_scheduled
5502 )
5503 select
5504 pt.block_id,
5505 pt.calendar_schedule_id,
5506 pt.staff_id,
5507 0 as assignment_id,
5508 '' as assignment_type,
5509 0 as day_of_week_mask,
5510 pt.is_weekend,
5511 case
5512 when (sc.calendar_schedule_id = pt.calendar_schedule_id) then ci.points
5513 else 0.0
5514 end as scheduled,
5515 case
5516 when (sc.calendar_schedule_id != pt.calendar_schedule_id) then ci.points
5517 else 0.0
5518 end as other_scheduled
5519 from
5520 buffer_schedules_1458117728 as sc
5521 inner join buffer_counter_increments_1458117728 as ci
5522 on sc.id = ci.schedule_id
5523 and ci.points != 0
5524 inner join assign_staff_types as ast
5525 on sc.staff_id = ast.staff_id
5526 and sc.schedule_on between ast.begin_date and coalesce(ast.end_date, '9999-12-31')
5527 inner join staff_types as st
5528 on ast.staff_type_id = st.id
5529 inner join buffer_point_targets_1458117728 as pt
5530 on sc.block_id = pt.block_id
5531 and st.point_hour_schedule_id = pt.calendar_schedule_id
5532 and sc.staff_id = pt.staff_id
5533 and sc.is_weekend = pt.is_weekend
5534 where
5535 sc.schedule_on = '2017-12-04'
5536 and sc.call_type_id = 49
5537 and sc.staff_id = 66
5538 order by null
5539
5540 (130.8ms) select 1 from buffer_tmp_targets_scheduled_1458117728
5541
5542 (259.1ms) update
5543 buffer_tmp_targets_scheduled_1458117728 as sch_t
5544 inner join buffer_point_targets_1458117728 as pt
5545 on sch_t.block_id = pt.block_id
5546 and sch_t.calendar_schedule_id = pt.calendar_schedule_id
5547 and sch_t.staff_id = pt.staff_id
5548 and sch_t.is_weekend = pt.is_weekend
5549 set
5550 pt.scheduled = pt.scheduled + sch_t.scheduled,
5551 pt.scheduled_delta = sch_t.scheduled,
5552 pt.other_scheduled = pt.other_scheduled + sch_t.other_scheduled,
5553 pt.other_scheduled_delta = sch_t.other_scheduled
5554
5555 (131.2ms) select 1 from buffer_tmp_targets_scheduled_1458117728
5556 where other_scheduled != 0
5557
5558 (133.7ms) update
5559 buffer_tmp_targets_scheduled_1458117728 as sch_t
5560 inner join buffer_point_targets_1458117728 as pt
5561 on sch_t.block_id = pt.block_id
5562 and sch_t.calendar_schedule_id = pt.calendar_schedule_id
5563 and (
5564 sch_t.staff_id = pt.staff_id
5565 or sch_t.other_scheduled != 0
5566 )
5567 and sch_t.is_weekend = pt.is_weekend
5568 set
5569 pt.raw_target_delta = 0,
5570 pt.target_delta = 0,
5571 pt.scheduled_delta = 0,
5572 pt.other_scheduled_delta = 0
5573
5574 (133.3ms) delete
5575 from buffer_linkage_hour_targets_1458117728
5576 where linkage_instance_id = 5201749
5577
5578 (133.4ms) truncate table buffer_tmp_targets_scheduled_1458117728
5579
5580 (132.0ms) insert into buffer_tmp_targets_scheduled_1458117728 (
5581 block_id,
5582 calendar_schedule_id,
5583 staff_id,
5584 assignment_id,
5585 assignment_type,
5586 day_of_week_mask,
5587 is_weekend,
5588 scheduled,
5589 other_scheduled
5590 )
5591 select
5592 ht.block_id,
5593 ht.calendar_schedule_id,
5594 ht.staff_id,
5595 0 as assignment_id,
5596 '' as assignment_type,
5597 0 as day_of_week_mask,
5598 ht.is_weekend,
5599 case
5600 when (sc.calendar_schedule_id = ht.calendar_schedule_id) then ci.hours
5601 else 0.0
5602 end as scheduled,
5603 case
5604 when (sc.calendar_schedule_id != ht.calendar_schedule_id) then ci.hours
5605 else 0.0
5606 end as other_scheduled
5607 from
5608 buffer_schedules_1458117728 as sc
5609 inner join buffer_counter_increments_1458117728 as ci
5610 on sc.id = ci.schedule_id
5611 and ci.hours > 0
5612 inner join assign_staff_types as ast
5613 on sc.staff_id = ast.staff_id
5614 and sc.schedule_on between ast.begin_date and coalesce(ast.end_date, '9999-12-31')
5615 inner join staff_types as st
5616 on ast.staff_type_id = st.id
5617 inner join buffer_hour_targets_1458117728 as ht
5618 on sc.block_id = ht.block_id
5619 and st.point_hour_schedule_id = ht.calendar_schedule_id
5620 and sc.staff_id = ht.staff_id
5621 and sc.is_weekend = ht.is_weekend
5622 where
5623 sc.schedule_on = '2017-12-04'
5624 and sc.call_type_id = 49
5625 and sc.staff_id = 66
5626 order by null
5627
5628 (131.2ms) select 1 from buffer_tmp_targets_scheduled_1458117728
5629
5630 (133.0ms) /* AssignmentLimitsPerPeriod */
5631 /* Unique Key: assignment_limit_id, staff_id, start_date */
5632 insert into buffer_staff_assignments_count_periods_1458117728 (
5633 assignment_limit_id, staff_id, start_date, end_date, assignments_count
5634 )
5635 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
5636 1 as assignments_count
5637 from buffer_schedules_1458117728 as sc
5638 inner join buffer_assignment_limit_call_types_1458117728 as alct
5639 on sc.call_type_id = alct.call_type_id
5640 inner join assignment_limits as al
5641 on alct.assignment_limit_id = al.id
5642 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
5643 and al.max_per_period_limit is not null
5644 inner join assign_staff_types as ast
5645 on sc.staff_id = ast.staff_id
5646 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
5647 inner join buffer_assignment_limit_staff_types_1458117728 as alst
5648 on alct.assignment_limit_id = alst.assignment_limit_id
5649 and ast.staff_type_id = alst.staff_type_id
5650 inner join (
5651 select assignment_limit_id, start_date, end_date
5652 from buffer_linkage_assignments_count_periods_1458117728
5653 group by assignment_limit_id, start_date, end_date
5654 order by null
5655 ) as lac
5656 on alct.assignment_limit_id = lac.assignment_limit_id
5657 and sc.schedule_on between lac.start_date and lac.end_date
5658 where sc.schedule_on = '2017-12-04'
5659 and sc.call_type_id = 49
5660 and sc.staff_id = 66
5661 on duplicate key update
5662 assignments_count = assignments_count + 1
5663
5664 (132.2ms) /* AssignmentLimitsPerWeek */
5665 /* Unique Key: assignment_limit_id, staff_id, start_date */
5666 insert into buffer_staff_assignments_count_weeks_1458117728 (
5667 assignment_limit_id, staff_id, start_date, end_date, assignments_count
5668 )
5669 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
5670 1 as assignments_count
5671 from buffer_schedules_1458117728 as sc
5672 inner join buffer_assignment_limit_call_types_1458117728 as alct
5673 on sc.call_type_id = alct.call_type_id
5674 inner join assignment_limits as al
5675 on alct.assignment_limit_id = al.id
5676 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
5677 and al.max_weekly_limit is not null
5678 inner join assign_staff_types as ast
5679 on sc.staff_id = ast.staff_id
5680 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
5681 inner join buffer_assignment_limit_staff_types_1458117728 as alst
5682 on alct.assignment_limit_id = alst.assignment_limit_id
5683 and ast.staff_type_id = alst.staff_type_id
5684 inner join (
5685 select assignment_limit_id, start_date, end_date
5686 from buffer_linkage_assignments_count_weeks_1458117728
5687 group by assignment_limit_id, start_date, end_date
5688 order by null
5689 ) as lac
5690 on alct.assignment_limit_id = lac.assignment_limit_id
5691 and sc.schedule_on between lac.start_date and lac.end_date
5692 where sc.schedule_on = '2017-12-04'
5693 and sc.call_type_id = 49
5694 and sc.staff_id = 66
5695 on duplicate key update
5696 assignments_count = assignments_count + 1
5697
5698 (132.7ms) /* AssignmentLimitsRolling */
5699 /* Unique Key: assignment_limit_id, staff_id, start_date */
5700 insert into buffer_staff_assignments_count_rolling_1458117728 (
5701 assignment_limit_id, staff_id, start_date, end_date, assignments_count
5702 )
5703 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
5704 1 as assignments_count
5705 from buffer_schedules_1458117728 as sc
5706 inner join buffer_assignment_limit_call_types_1458117728 as alct
5707 on sc.call_type_id = alct.call_type_id
5708 inner join assignment_limits as al
5709 on alct.assignment_limit_id = al.id
5710 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
5711 and al.max_rolling_period is not null
5712 and al.max_rolling_limit is not null
5713 inner join assign_staff_types as ast
5714 on sc.staff_id = ast.staff_id
5715 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
5716 inner join buffer_assignment_limit_staff_types_1458117728 as alst
5717 on alct.assignment_limit_id = alst.assignment_limit_id
5718 and ast.staff_type_id = alst.staff_type_id
5719 inner join (
5720 select assignment_limit_id, start_date, end_date
5721 from buffer_linkage_assignments_count_rolling_1458117728
5722 group by assignment_limit_id, start_date, end_date
5723 order by null
5724 ) as lac
5725 on alct.assignment_limit_id = lac.assignment_limit_id
5726 and sc.schedule_on between lac.start_date and lac.end_date
5727 where sc.schedule_on = '2017-12-04'
5728 and sc.call_type_id = 49
5729 and sc.staff_id = 66
5730 on duplicate key update
5731 assignments_count = assignments_count + 1
5732
5733 (132.4ms) /* AssignmentLimitsConsecutive */
5734 /* Unique Key: assignment_limit_id, staff_id, schedule_on, start_date */
5735 insert ignore into buffer_staff_assignments_count_consecutive_1458117728 (
5736 assignment_limit_id, staff_id, schedule_on, start_date, end_date
5737 )
5738 select lac.assignment_limit_id, sc.staff_id, sc.schedule_on, lac.start_date, lac.end_date
5739 from buffer_schedules_1458117728 as sc
5740 inner join buffer_assignment_limit_call_types_1458117728 as alct
5741 on sc.call_type_id = alct.call_type_id
5742 inner join assignment_limits as al
5743 on alct.assignment_limit_id = al.id
5744 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
5745 and al.max_consecutive_limit is not null
5746 inner join assign_staff_types as ast
5747 on sc.staff_id = ast.staff_id
5748 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
5749 inner join buffer_assignment_limit_staff_types_1458117728 as alst
5750 on alct.assignment_limit_id = alst.assignment_limit_id
5751 and ast.staff_type_id = alst.staff_type_id
5752 inner join (
5753 select assignment_limit_id, start_date, end_date
5754 from buffer_linkage_assignments_count_consecutive_1458117728
5755 group by assignment_limit_id, start_date, end_date
5756 order by null
5757 ) as lac
5758 on alct.assignment_limit_id = lac.assignment_limit_id
5759 and sc.schedule_on between lac.start_date and lac.end_date
5760 where sc.schedule_on = '2017-12-04'
5761 and sc.call_type_id = 49
5762 and sc.staff_id = 66
5763
5764INFO : (04-06 20:54:17) scheduled for: plan unit: [id:5201749] [2017-12-04 - GI1], Gary Allen. DEPTH(2)
5765 NegativeLink Load (138.6ms) SELECT `negative_links`.* FROM `negative_links` WHERE `negative_links`.`client_id` = 6
5766 (133.4ms) /* SpecializationOverlapRule */
5767 delete ca
5768 from buffer_combined_availabilities_1458117728 as ca use index (ix_buffer_combined_availabilities_composite_1)
5769 inner join buffer_schedules_1458117728 as sc
5770 on ca.schedule_id = sc.id
5771 inner join buffer_staff_specializations_1458117728 as ssp
5772 on ca.staff_id = ssp.staff_id
5773 inner join max_applicable_call_types as mact
5774 on ssp.specialization_id = mact.specialization_id
5775 and sc.call_type_id = mact.call_type_id
5776 inner join buffer_specialization_daily_counts_1458117728 as sdc use index (ix_buffer_specialization_daily_counts_composite_1)
5777 on ssp.specialization_id = sdc.specialization_id
5778 and sc.schedule_on = sdc.schedule_on
5779 and sdc.staff_id is null
5780 left join buffer_specialization_daily_counts_1458117728 as sdc_2 use index (ix_buffer_specialization_daily_counts_composite_1)
5781 on ssp.specialization_id = sdc_2.specialization_id
5782 and sc.schedule_on = sdc_2.schedule_on
5783 and ca.staff_id = sdc_2.staff_id
5784 where sdc.should_be_evaluated = 1
5785 and (sdc.staffs_scheduled + if(sdc_2.id is null, 1, 0)) > sdc.max_scheduled
5786
5787 (132.0ms) delete ca
5788 from buffer_combined_availabilities_1458117728 as ca
5789 inner join (
5790 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
5791 sum(lac.assignments_count) as assignments_count
5792 from (
5793 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
5794 from buffer_combined_availabilities_1458117728 as ca
5795 inner join buffer_schedules_1458117728 as sc
5796 on ca.schedule_id = sc.id
5797 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
5798 order by null
5799 ) as ca_sc
5800 inner join buffer_linkage_assignments_count_weeks_1458117728 as lac
5801 on ca_sc.linkage_instance_id = lac.linkage_instance_id
5802 and ca_sc.schedule_on = lac.schedule_on
5803 inner join buffer_assignment_limit_staff_types_1458117728 as alst
5804 on lac.assignment_limit_id = alst.assignment_limit_id
5805 and ca_sc.staff_type_id = alst.staff_type_id
5806 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
5807 order by null
5808 ) as lac
5809 on ca.linkage_instance_id = lac.linkage_instance_id
5810 and ca.staff_id = lac.staff_id
5811 inner join assignment_limits as al
5812 on lac.assignment_limit_id = al.id
5813 left join buffer_staff_assignments_count_weeks_1458117728 as sac
5814 on lac.assignment_limit_id = sac.assignment_limit_id
5815 and lac.staff_id = sac.staff_id
5816 and lac.start_date = sac.start_date
5817 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_weekly_limit
5818
5819 (132.0ms) delete ca
5820 from buffer_combined_availabilities_1458117728 as ca
5821 inner join (
5822 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
5823 sum(lac.assignments_count) as assignments_count
5824 from (
5825 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
5826 from buffer_combined_availabilities_1458117728 as ca
5827 inner join buffer_schedules_1458117728 as sc
5828 on ca.schedule_id = sc.id
5829 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
5830 order by null
5831 ) as ca_sc
5832 inner join buffer_linkage_assignments_count_periods_1458117728 as lac
5833 on ca_sc.linkage_instance_id = lac.linkage_instance_id
5834 and ca_sc.schedule_on = lac.schedule_on
5835 inner join buffer_assignment_limit_staff_types_1458117728 as alst
5836 on lac.assignment_limit_id = alst.assignment_limit_id
5837 and ca_sc.staff_type_id = alst.staff_type_id
5838 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
5839 order by null
5840 ) as lac
5841 on ca.linkage_instance_id = lac.linkage_instance_id
5842 and ca.staff_id = lac.staff_id
5843 inner join assignment_limits as al
5844 on lac.assignment_limit_id = al.id
5845 left join buffer_staff_assignments_count_periods_1458117728 as sac
5846 on lac.assignment_limit_id = sac.assignment_limit_id
5847 and lac.staff_id = sac.staff_id
5848 and lac.start_date = sac.start_date
5849 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_per_period_limit
5850
5851 (132.0ms) delete ca
5852 from buffer_combined_availabilities_1458117728 as ca
5853 inner join (
5854 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
5855 sum(lac.assignments_count) as assignments_count
5856 from (
5857 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
5858 from buffer_combined_availabilities_1458117728 as ca
5859 inner join buffer_schedules_1458117728 as sc
5860 on ca.schedule_id = sc.id
5861 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
5862 order by null
5863 ) as ca_sc
5864 inner join buffer_linkage_assignments_count_rolling_1458117728 as lac
5865 on ca_sc.linkage_instance_id = lac.linkage_instance_id
5866 and ca_sc.schedule_on = lac.schedule_on
5867 inner join buffer_assignment_limit_staff_types_1458117728 as alst
5868 on lac.assignment_limit_id = alst.assignment_limit_id
5869 and ca_sc.staff_type_id = alst.staff_type_id
5870 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
5871 order by null
5872 ) as lac
5873 on ca.linkage_instance_id = lac.linkage_instance_id
5874 and ca.staff_id = lac.staff_id
5875 inner join assignment_limits as al
5876 on lac.assignment_limit_id = al.id
5877 left join buffer_staff_assignments_count_rolling_1458117728 as sac
5878 on lac.assignment_limit_id = sac.assignment_limit_id
5879 and lac.staff_id = sac.staff_id
5880 and lac.start_date = sac.start_date
5881 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_rolling_limit
5882
5883 (132.1ms) delete ca
5884 from buffer_combined_availabilities_1458117728 as ca
5885 inner join (
5886 select ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date,
5887 count(distinct if(sac.id is null, lac.schedule_on, null)) as assignments_count
5888 from (
5889 select ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
5890 from buffer_combined_availabilities_1458117728 as ca
5891 inner join buffer_schedules_1458117728 as sc
5892 on ca.schedule_id = sc.id
5893 group by ca.staff_id, ca.staff_type_id, sc.linkage_instance_id, sc.schedule_on
5894 order by null
5895 ) as ca_sc
5896 inner join buffer_linkage_assignments_count_consecutive_1458117728 as lac
5897 on ca_sc.linkage_instance_id = lac.linkage_instance_id
5898 and ca_sc.schedule_on = lac.schedule_on
5899 inner join buffer_assignment_limit_staff_types_1458117728 as alst
5900 on lac.assignment_limit_id = alst.assignment_limit_id
5901 and ca_sc.staff_type_id = alst.staff_type_id
5902 left join buffer_staff_assignments_count_consecutive_1458117728 as sac
5903 on lac.assignment_limit_id = sac.assignment_limit_id
5904 and ca_sc.staff_id = sac.staff_id
5905 and lac.schedule_on = sac.schedule_on
5906 and lac.start_date = sac.start_date
5907 group by ca_sc.linkage_instance_id, lac.assignment_limit_id, ca_sc.staff_id, lac.start_date
5908 order by null
5909 ) as lac
5910 on ca.linkage_instance_id = lac.linkage_instance_id
5911 and ca.staff_id = lac.staff_id
5912 inner join assignment_limits as al
5913 on lac.assignment_limit_id = al.id
5914 left join (
5915 select assignment_limit_id, staff_id, start_date,
5916 count(schedule_on) as assignments_count
5917 from buffer_staff_assignments_count_consecutive_1458117728
5918 group by assignment_limit_id, staff_id, start_date
5919 ) as sac
5920 on lac.assignment_limit_id = sac.assignment_limit_id
5921 and lac.staff_id = sac.staff_id
5922 and lac.start_date = sac.start_date
5923 where (lac.assignments_count + ifnull(sac.assignments_count, 0)) > al.max_consecutive_limit
5924
5925 (140.8ms) delete ca
5926 from
5927 buffer_combined_availabilities_1458117728 as ca
5928 inner join buffer_schedules_1458117728 as sc
5929 on ca.schedule_id = sc.id
5930 inner join buffer_linkage_point_targets_1458117728 as lpt
5931 on sc.linkage_instance_id = lpt.linkage_instance_id
5932 and ca.staff_id = lpt.staff_id
5933 and sc.is_weekend = lpt.is_weekend
5934 and lpt.period_offset = -1
5935 and sc.calendar_schedule_id = lpt.calendar_schedule_id
5936 inner join buffer_cumulative_point_targets_1458117728 as pt
5937 on ca.staff_id = pt.staff_id
5938 and sc.is_weekend = pt.is_weekend
5939 and sc.calendar_schedule_id = pt.calendar_schedule_id
5940 where
5941 sc.is_weekend in (1,0) /* "weekday (0), weekend (1)" checkboxes */
5942 and (pt.scheduled + lpt.scheduled) > (pt.adjusted_target /* raw_target | adjusted_target */ * (1 + 0 /* hours threshold */ / 100.0));
5943
5944 (132.2ms) select
5945 coalesce(max(
5946 case
5947 when (ct.max_weekday_assignments > 0) then 1
5948 else 0
5949 end
5950 ), 0) as weekday_flag,
5951 coalesce(max(
5952 case
5953 when (ct.max_weekend_assignments > 0) then 1
5954 else 0
5955 end
5956 ), 0) as weekend_flag
5957 from
5958 buffer_auto_populate_slots_1458117728 as aps
5959 inner join call_types as ct
5960 on aps.call_type_id = ct.id
5961
5962 (132.0ms) /* MaxAssignmentsRule */
5963 delete ca
5964 from buffer_combined_availabilities_1458117728 as ca
5965 inner join buffer_schedules_1458117728 as sc
5966 on ca.schedule_id = sc.id
5967 inner join buffer_linkage_call_type_assignments_1458117728 as lcta
5968 on sc.linkage_instance_id = lcta.linkage_instance_id
5969 and sc.call_type_id = lcta.call_type_id
5970 and sc.is_weekend = lcta.is_weekend
5971 and sc.period_offset = lcta.period_offset
5972 and sc.calendar_schedule_id = lcta.calendar_schedule_id
5973 left join buffer_call_type_assignments_1458117728 as cta
5974 on ca.staff_id = cta.staff_id
5975 and sc.call_type_id = cta.call_type_id
5976 and sc.is_weekend = cta.is_weekend
5977 and sc.period_offset = cta.period_offset
5978 and sc.calendar_schedule_id = cta.calendar_schedule_id
5979 where
5980 sc.is_weekend in (NULL) /* "weekday (0), weekend (1)" checkboxes */
5981 and (coalesce(cta.assignments_count, 0) + lcta.assignments_count) > lcta.max_assignments;
5982
5983 (135.6ms) /* NegativeLinkRule */
5984 delete ca
5985 from buffer_combined_availabilities_1458117728 as ca use index (ix_buffer_combined_availabilities_composite_1)
5986 inner join buffer_negative_relations_1458117728 as nr use index (ix_buffer_negative_relations_composite_1)
5987 on ca.schedule_id = nr.schedule_id
5988 and ca.staff_id = nr.staff_id
5989
5990 (134.5ms) /* BrokenLinkageRule */
5991 truncate table buffer_combined_availability_linkages_1458117728
5992
5993 (149.3ms) insert into buffer_combined_availability_linkages_1458117728 (
5994 staff_id,
5995 linkage_instance_id,
5996 slots_count,
5997 is_primary,
5998 has_violations
5999 )
6000 select
6001 staff_id,
6002 linkage_instance_id,
6003 count(1) as slots_count,
6004 min(is_primary) as is_primary,
6005 max(has_violations) as has_violations
6006 from buffer_combined_availabilities_1458117728 use index (ix_buffer_combined_availabilities_composite_2)
6007 group by
6008 staff_id,
6009 linkage_instance_id
6010 order by null
6011
6012 (133.0ms) delete ca
6013 from
6014 buffer_combined_availabilities_1458117728 as ca use index (ix_buffer_combined_availabilities_composite_1)
6015 inner join buffer_schedules_1458117728 as sc
6016 on ca.schedule_id = sc.id
6017 inner join buffer_linkages_1458117728 as l
6018 on sc.linkage_instance_id = l.linkage_instance_id
6019 inner join buffer_combined_availability_linkages_1458117728 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
6020 on ca.staff_id = ls_1.staff_id
6021 and sc.linkage_instance_id = ls_1.linkage_instance_id
6022 left join buffer_schedule_linkages_1458117728 as ls_2 use index (ix_buffer_schedule_linkages_composite_1)
6023 on ca.staff_id = ls_2.staff_id
6024 and sc.linkage_instance_id = ls_2.linkage_instance_id
6025 where (ls_1.slots_count + coalesce(ls_2.slots_count, 0)) < l.slots_count_total /* not covering the whole chain */;
6026
6027 (152.5ms) select straight_join
6028 sc.schedule_on,
6029 sc.call_type_id,
6030 count(distinct ca.staff_id) as available_members_count,
6031 group_concat(
6032 distinct concat(if(ls_1.is_primary = 1, 'p', 's'), ca.staff_id)
6033 order by ls_1.is_primary desc, ca.staff_id
6034 separator ', '
6035 ) as available_members_ids,
6036 sc.linkage_instance_id,
6037 l.slots_count_total as linkage_slots_count
6038 from buffer_combined_availabilities_1458117728 as ca
6039 inner join buffer_schedules_1458117728 as sc
6040 on ca.schedule_id = sc.id
6041 inner join buffer_linkages_1458117728 as l
6042 on sc.linkage_instance_id = l.linkage_instance_id
6043 inner join buffer_combined_availability_linkages_1458117728 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
6044 on ca.staff_id = ls_1.staff_id
6045 and sc.linkage_instance_id = ls_1.linkage_instance_id
6046 and ls_1.has_violations = 0
6047 where sc.should_be_evaluated = 1
6048 and sc.should_be_populated = 1
6049 group by sc.schedule_on, sc.call_type_id, sc.linkage_instance_id, l.slots_count_total
6050 order by available_members_count, sc.schedule_on, sc.display_order
6051 limit 1
6052
6053 (133.6ms) truncate table buffer_rule_scores_1458117728
6054
6055 (133.1ms) truncate table buffer_rule_calc_filters_1458117728
6056
6057 (133.4ms) insert into buffer_rule_calc_filters_1458117728 (
6058 linkage_instance_id,
6059 staff_id
6060 ) values (14201749, 65),(14201749, 68),(14201749, 70),(14201749, 71),(14201749, 72),(14201749, 73),(14201749, 75),(14201749, 78),(14201749, 79),(14201749, 80),(14201749, 81),(14201749, 6960)
6061
6062 (135.3ms) /* CumulativePointTargetsRule */
6063 insert into buffer_rule_scores_1458117728 (
6064 linkage_instance_id,
6065 schedule_id,
6066 staff_id,
6067 rule_name,
6068 value
6069 )
6070 select
6071 b_schedules.linkage_instance_id,
6072 b_schedules.id as schedule_id,
6073 availabilities.staff_id,
6074 'CumulativePointTargetsRule' as rule_name,
6075 ((b_targets.adjusted_target - b_targets.scheduled) /
6076 b_targets.adjusted_target) as value
6077 from
6078 buffer_rule_calc_filters_1458117728 as filters
6079 inner join buffer_schedules_1458117728 as b_schedules
6080 on filters.linkage_instance_id = b_schedules.linkage_instance_id
6081 inner join buffer_combined_availabilities_1458117728 as availabilities
6082 on b_schedules.id = availabilities.schedule_id
6083 and filters.staff_id = availabilities.staff_id
6084 inner join buffer_cumulative_point_targets_1458117728 as b_targets
6085 on availabilities.staff_id = b_targets.staff_id
6086 and b_schedules.is_weekend = b_targets.is_weekend
6087 and b_schedules.calendar_schedule_id = b_targets.calendar_schedule_id
6088 order by null;
6089
6090 (133.8ms) truncate table buffer_rule_scores_with_corrections_1458117728
6091
6092 (134.4ms) insert into buffer_rule_scores_with_corrections_1458117728 (
6093 linkage_instance_id, schedule_id, staff_id, rule_name, value
6094 )
6095 select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id, rule_scores.rule_name,
6096 ifnull(rule_scores.value, max_values.max_value + 1) as value
6097 from buffer_rule_scores_1458117728 as rule_scores
6098 inner join (
6099 select rule_name, max(value) as max_value
6100 from buffer_rule_scores_1458117728
6101 group by rule_name
6102 order by null
6103 ) as max_values
6104 on rule_scores.rule_name = max_values.rule_name
6105 order by null
6106
6107 (132.8ms) select linkage_instance_id, staff_id, avg(slot_scores) as scores
6108 from (
6109 select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id,
6110 sum(
6111 if((total_values.total_value > 0), (rule_scores.value / total_values.total_value), 0) *
6112 rules.weight *
6113 total_values.slots_count
6114 ) as slot_scores
6115 from buffer_rule_scores_with_corrections_1458117728 as rule_scores
6116 inner join (
6117 select rule_name, sum(abs(value)) as total_value,
6118 count(distinct schedule_id) as slots_count
6119 from buffer_rule_scores_with_corrections_1458117728
6120 group by rule_name
6121 order by null
6122 ) as total_values
6123 on rule_scores.rule_name = total_values.rule_name
6124 inner join rules
6125 on rule_scores.rule_name = rules.type
6126 where rules.rule_set_id = 1530
6127 and rules.applied = 1
6128 group by rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id
6129 order by null
6130 ) as staff_scores
6131 group by linkage_instance_id, staff_id
6132 order by round(avg(slot_scores), 5) desc, rand()
6133 limit 1
6134
6135 PublishedBlock Load (133.4ms) SELECT `published_blocks`.* FROM `published_blocks` INNER JOIN `blocks` ON `blocks`.`id` = `published_blocks`.`block_id` WHERE `published_blocks`.`client_id` = 6 AND ('2017-12-05' BETWEEN blocks.start_date AND blocks.end_date) AND `published_blocks`.`calendar_schedule_id` = 6 ORDER BY `published_blocks`.`id` ASC LIMIT 1
6136 (131.1ms) BEGIN
6137 (134.2ms) SELECT COALESCE(pb.updated_at, pbct.updated_at)
6138 FROM call_types AS ct
6139 INNER JOIN calendar_schedules AS cs
6140 ON ct.calendar_schedule_id = cs.id
6141 INNER JOIN blocks AS b
6142 ON b.client_id = ct.client_id
6143 AND b.block_schedule_id = cs.block_schedule_id
6144 AND '2017-12-05' BETWEEN b.start_date AND b.end_date
6145 INNER JOIN published_blocks AS pb
6146 ON pb.client_id = ct.client_id
6147 AND pb.block_id = b.id
6148 AND pb.calendar_schedule_id = cs.id
6149 LEFT JOIN published_block_call_types AS pbct
6150 ON pbct.client_id = ct.client_id
6151 AND pbct.assignment_id = ct.id
6152 AND pbct.assignment_type = 'CallType'
6153 AND pbct.block_id = b.id
6154 AND (
6155 (1 << (DAYOFWEEK('2017-12-05') - 1) & pbct.days_of_week_mask) > 0
6156 )
6157 WHERE ct.id = 49
6158 AND (
6159 (
6160 pb.assignment_ids IS NULL
6161 AND (1 << (DAYOFWEEK('2017-12-05') - 1) & pb.days_of_week_mask) > 0
6162 )
6163 OR pbct.id IS NOT NULL
6164 )
6165
6166 CallType Load (133.2ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 49 LIMIT 1
6167 Client Load (138.2ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 6 LIMIT 1
6168 Staff Load (133.0ms) SELECT `staffs`.* FROM `staffs` WHERE `staffs`.`id` = 81 LIMIT 1
6169 Schedule Exists (137.1ms) SELECT 1 AS one FROM `schedules` WHERE `schedules`.`call_type_id` = 49 AND `schedules`.`client_id` = 6 AND `schedules`.`schedule_on` = '2017-12-05' LIMIT 1
6170 SQL (151.0ms) INSERT INTO `schedules` (`client_id`, `call_type_id`, `staff_id`, `schedule_on`, `created_at`, `updated_at`, `weekend_on`, `dayofweek_on`, `populate_method`, `creator_id`) VALUES (6, 49, 81, '2017-12-05', '2018-04-06 20:54:26', '2018-04-06 20:54:26', 0, 3, 'auto_populate_step', 166)
6171 VisibleAssignment Load (131.7ms) SELECT `visible_assignments`.* FROM `visible_assignments` WHERE `visible_assignments`.`client_id` = 6 AND `visible_assignments`.`date` = '2017-12-05' AND `visible_assignments`.`assignment_type` = 'CallType' AND `visible_assignments`.`assignment_id` = 49 ORDER BY `visible_assignments`.`id` ASC LIMIT 1
6172 DailyListSlot Load (132.6ms) SELECT `daily_list_slots`.* FROM `daily_list_slots` WHERE `daily_list_slots`.`schedule_on` = '2017-12-05' AND `daily_list_slots`.`staff_id` = 81 AND `daily_list_slots`.`call_type_id` = 49 ORDER BY daily_list_slots.position asc LIMIT 1
6173 (133.4ms) COMMIT
6174FLUSHED: nil:nil
6175 (139.7ms) UPDATE buffer_schedules_1458117728
6176 SET staff_id = 81,
6177 should_be_populated = 0,
6178 should_be_evaluated = 0
6179 WHERE
6180 call_type_id = 49
6181 AND schedule_on = '2017-12-05'
6182
6183 (137.0ms) delete from buffer_combined_availabilities_1458117728
6184 where linkage_instance_id = 14201749
6185
6186 (131.0ms) UPDATE buffer_rule_calc_schedules_1458117728
6187 SET staff_id = 81
6188 WHERE call_type_id = 49
6189 AND schedule_on = '2017-12-05'
6190
6191 (133.3ms) INSERT INTO buffer_rule_calc_schedules_1458117728
6192 SET staff_id = 81,
6193 call_type_id = 49,
6194 schedule_on = '2017-12-05',
6195 day_of_week_mask = 4
6196
6197 (133.5ms) /* NegativeLinkRule */
6198 UPDATE buffer_negative_relations_1458117728
6199 SET staff_id = 81
6200 WHERE affected_by_schedule_id = (
6201 SELECT id
6202 FROM buffer_schedules_1458117728
6203 WHERE schedule_on = '2017-12-05'
6204 AND call_type_id = 49
6205 )
6206
6207 (131.3ms) /* SpecializationOverlapRule */
6208 update buffer_staff_specializations_1458117728 as st_sp
6209 inner join max_applicable_call_types as mact
6210 on st_sp.specialization_id = mact.specialization_id
6211 and mact.call_type_id = 49
6212 inner join buffer_specialization_daily_counts_1458117728 as sp_dc
6213 on st_sp.specialization_id = sp_dc.specialization_id
6214 and sp_dc.staff_id is null
6215 and sp_dc.schedule_on = '2017-12-05'
6216 left join buffer_specialization_daily_counts_1458117728 as sp_dc_2
6217 on st_sp.specialization_id = sp_dc_2.specialization_id
6218 and st_sp.staff_id = sp_dc_2.staff_id
6219 and sp_dc_2.schedule_on = '2017-12-05'
6220 set sp_dc.staffs_scheduled = sp_dc.staffs_scheduled + 1
6221 where st_sp.staff_id = 81
6222 and sp_dc_2.id is null
6223
6224 (131.9ms) insert into buffer_specialization_daily_counts_1458117728 (
6225 specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
6226 )
6227 select sp.id as specialization_id,
6228 81 as staff_id,
6229 '2017-12-05' as schedule_on,
6230 1 as staffs_scheduled,
6231 sp.max_scheduled,
6232 sp_dc.should_be_evaluated
6233 from buffer_staff_specializations_1458117728 as st_sp
6234 inner join specializations as sp
6235 on st_sp.specialization_id = sp.id
6236 inner join max_applicable_call_types as mact
6237 on st_sp.specialization_id = mact.specialization_id
6238 and mact.call_type_id = 49
6239 inner join buffer_specialization_daily_counts_1458117728 as sp_dc
6240 on st_sp.specialization_id = sp_dc.specialization_id
6241 and sp_dc.staff_id is null
6242 and sp_dc.schedule_on = '2017-12-05'
6243 left join buffer_specialization_daily_counts_1458117728 as sp_dc_2
6244 on st_sp.specialization_id = sp_dc_2.specialization_id
6245 and st_sp.staff_id = sp_dc_2.staff_id
6246 and sp_dc_2.schedule_on = '2017-12-05'
6247 where st_sp.staff_id = 81
6248 and sp_dc_2.id is null
6249
6250 (141.9ms) /* MaxAssignmentsRule */
6251 delete from buffer_linkage_call_type_assignments_1458117728
6252 where linkage_instance_id = 14201749;
6253
6254 (131.7ms) /* MaxAssignmentsRule */
6255 update
6256 buffer_schedules_1458117728 as sc
6257 inner join call_types as ct
6258 on sc.call_type_id = ct.id
6259 and ct.active = 1
6260 inner join buffer_call_type_assignments_1458117728 as cta
6261 on sc.staff_id = cta.staff_id
6262 and sc.call_type_id = cta.call_type_id
6263 and sc.is_weekend = cta.is_weekend
6264 and sc.period_offset = cta.period_offset
6265 and sc.calendar_schedule_id = cta.calendar_schedule_id
6266 set cta.assignments_count = cta.assignments_count + 1
6267 where
6268 sc.schedule_on = '2017-12-05'
6269 and sc.call_type_id = 49
6270 and sc.staff_id = 81
6271
6272 (133.3ms) insert into buffer_call_type_assignments_1458117728 (
6273 staff_id,
6274 call_type_id,
6275 is_weekend,
6276 period_offset,
6277 calendar_schedule_id,
6278 assignments_count
6279 )
6280 select
6281 sc.staff_id,
6282 sc.call_type_id,
6283 sc.is_weekend,
6284 sc.period_offset,
6285 sc.calendar_schedule_id,
6286 1 as assignments_count
6287 from buffer_schedules_1458117728 as sc
6288 where
6289 sc.staff_id = 81
6290 and sc.schedule_on = '2017-12-05'
6291 and sc.call_type_id = 49
6292
6293 (135.5ms) /* UnassignedDaysRule */
6294 delete from buffer_linkage_assigned_days_1458117728
6295 where linkage_instance_id = 14201749
6296
6297 (133.6ms) /* UnassignedDaysRule */
6298 UPDATE buffer_staff_assigned_days_1458117728 as sad
6299 inner join call_types as ct
6300 on ct.id = 49
6301 and ct.unassigned_day = 0
6302 SET sad.is_assigned = 1
6303 WHERE sad.staff_id = 81
6304 AND sad.schedule_on = '2017-12-05'
6305
6306 (133.9ms) delete
6307 from buffer_linkage_point_targets_1458117728
6308 where linkage_instance_id = 14201749
6309
6310 (132.7ms) truncate table buffer_tmp_targets_scheduled_1458117728
6311
6312 (135.6ms) insert into buffer_tmp_targets_scheduled_1458117728 (
6313 block_id,
6314 calendar_schedule_id,
6315 staff_id,
6316 assignment_id,
6317 assignment_type,
6318 day_of_week_mask,
6319 is_weekend,
6320 scheduled,
6321 other_scheduled
6322 )
6323 select
6324 pt.block_id,
6325 pt.calendar_schedule_id,
6326 pt.staff_id,
6327 0 as assignment_id,
6328 '' as assignment_type,
6329 0 as day_of_week_mask,
6330 pt.is_weekend,
6331 case
6332 when (sc.calendar_schedule_id = pt.calendar_schedule_id) then ci.points
6333 else 0.0
6334 end as scheduled,
6335 case
6336 when (sc.calendar_schedule_id != pt.calendar_schedule_id) then ci.points
6337 else 0.0
6338 end as other_scheduled
6339 from
6340 buffer_schedules_1458117728 as sc
6341 inner join buffer_counter_increments_1458117728 as ci
6342 on sc.id = ci.schedule_id
6343 and ci.points != 0
6344 inner join assign_staff_types as ast
6345 on sc.staff_id = ast.staff_id
6346 and sc.schedule_on between ast.begin_date and coalesce(ast.end_date, '9999-12-31')
6347 inner join staff_types as st
6348 on ast.staff_type_id = st.id
6349 inner join buffer_point_targets_1458117728 as pt
6350 on sc.block_id = pt.block_id
6351 and st.point_hour_schedule_id = pt.calendar_schedule_id
6352 and sc.staff_id = pt.staff_id
6353 and sc.is_weekend = pt.is_weekend
6354 where
6355 sc.schedule_on = '2017-12-05'
6356 and sc.call_type_id = 49
6357 and sc.staff_id = 81
6358 order by null
6359
6360 (130.6ms) select 1 from buffer_tmp_targets_scheduled_1458117728
6361
6362 (133.4ms) update
6363 buffer_tmp_targets_scheduled_1458117728 as sch_t
6364 inner join buffer_point_targets_1458117728 as pt
6365 on sch_t.block_id = pt.block_id
6366 and sch_t.calendar_schedule_id = pt.calendar_schedule_id
6367 and sch_t.staff_id = pt.staff_id
6368 and sch_t.is_weekend = pt.is_weekend
6369 set
6370 pt.scheduled = pt.scheduled + sch_t.scheduled,
6371 pt.scheduled_delta = sch_t.scheduled,
6372 pt.other_scheduled = pt.other_scheduled + sch_t.other_scheduled,
6373 pt.other_scheduled_delta = sch_t.other_scheduled
6374
6375 (130.5ms) select 1 from buffer_tmp_targets_scheduled_1458117728
6376 where other_scheduled != 0
6377
6378 (133.6ms) update
6379 buffer_tmp_targets_scheduled_1458117728 as sch_t
6380 inner join buffer_point_targets_1458117728 as pt
6381 on sch_t.block_id = pt.block_id
6382 and sch_t.calendar_schedule_id = pt.calendar_schedule_id
6383 and (
6384 sch_t.staff_id = pt.staff_id
6385 or sch_t.other_scheduled != 0
6386 )
6387 and sch_t.is_weekend = pt.is_weekend
6388 set
6389 pt.raw_target_delta = 0,
6390 pt.target_delta = 0,
6391 pt.scheduled_delta = 0,
6392 pt.other_scheduled_delta = 0
6393
6394 (133.0ms) delete
6395 from buffer_linkage_hour_targets_1458117728
6396 where linkage_instance_id = 14201749
6397
6398 (133.6ms) truncate table buffer_tmp_targets_scheduled_1458117728
6399
6400 (132.3ms) insert into buffer_tmp_targets_scheduled_1458117728 (
6401 block_id,
6402 calendar_schedule_id,
6403 staff_id,
6404 assignment_id,
6405 assignment_type,
6406 day_of_week_mask,
6407 is_weekend,
6408 scheduled,
6409 other_scheduled
6410 )
6411 select
6412 ht.block_id,
6413 ht.calendar_schedule_id,
6414 ht.staff_id,
6415 0 as assignment_id,
6416 '' as assignment_type,
6417 0 as day_of_week_mask,
6418 ht.is_weekend,
6419 case
6420 when (sc.calendar_schedule_id = ht.calendar_schedule_id) then ci.hours
6421 else 0.0
6422 end as scheduled,
6423 case
6424 when (sc.calendar_schedule_id != ht.calendar_schedule_id) then ci.hours
6425 else 0.0
6426 end as other_scheduled
6427 from
6428 buffer_schedules_1458117728 as sc
6429 inner join buffer_counter_increments_1458117728 as ci
6430 on sc.id = ci.schedule_id
6431 and ci.hours > 0
6432 inner join assign_staff_types as ast
6433 on sc.staff_id = ast.staff_id
6434 and sc.schedule_on between ast.begin_date and coalesce(ast.end_date, '9999-12-31')
6435 inner join staff_types as st
6436 on ast.staff_type_id = st.id
6437 inner join buffer_hour_targets_1458117728 as ht
6438 on sc.block_id = ht.block_id
6439 and st.point_hour_schedule_id = ht.calendar_schedule_id
6440 and sc.staff_id = ht.staff_id
6441 and sc.is_weekend = ht.is_weekend
6442 where
6443 sc.schedule_on = '2017-12-05'
6444 and sc.call_type_id = 49
6445 and sc.staff_id = 81
6446 order by null
6447
6448 (131.4ms) select 1 from buffer_tmp_targets_scheduled_1458117728
6449
6450 (132.7ms) /* AssignmentLimitsPerPeriod */
6451 /* Unique Key: assignment_limit_id, staff_id, start_date */
6452 insert into buffer_staff_assignments_count_periods_1458117728 (
6453 assignment_limit_id, staff_id, start_date, end_date, assignments_count
6454 )
6455 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
6456 1 as assignments_count
6457 from buffer_schedules_1458117728 as sc
6458 inner join buffer_assignment_limit_call_types_1458117728 as alct
6459 on sc.call_type_id = alct.call_type_id
6460 inner join assignment_limits as al
6461 on alct.assignment_limit_id = al.id
6462 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
6463 and al.max_per_period_limit is not null
6464 inner join assign_staff_types as ast
6465 on sc.staff_id = ast.staff_id
6466 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
6467 inner join buffer_assignment_limit_staff_types_1458117728 as alst
6468 on alct.assignment_limit_id = alst.assignment_limit_id
6469 and ast.staff_type_id = alst.staff_type_id
6470 inner join (
6471 select assignment_limit_id, start_date, end_date
6472 from buffer_linkage_assignments_count_periods_1458117728
6473 group by assignment_limit_id, start_date, end_date
6474 order by null
6475 ) as lac
6476 on alct.assignment_limit_id = lac.assignment_limit_id
6477 and sc.schedule_on between lac.start_date and lac.end_date
6478 where sc.schedule_on = '2017-12-05'
6479 and sc.call_type_id = 49
6480 and sc.staff_id = 81
6481 on duplicate key update
6482 assignments_count = assignments_count + 1
6483
6484 (260.1ms) /* AssignmentLimitsPerWeek */
6485 /* Unique Key: assignment_limit_id, staff_id, start_date */
6486 insert into buffer_staff_assignments_count_weeks_1458117728 (
6487 assignment_limit_id, staff_id, start_date, end_date, assignments_count
6488 )
6489 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
6490 1 as assignments_count
6491 from buffer_schedules_1458117728 as sc
6492 inner join buffer_assignment_limit_call_types_1458117728 as alct
6493 on sc.call_type_id = alct.call_type_id
6494 inner join assignment_limits as al
6495 on alct.assignment_limit_id = al.id
6496 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
6497 and al.max_weekly_limit is not null
6498 inner join assign_staff_types as ast
6499 on sc.staff_id = ast.staff_id
6500 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
6501 inner join buffer_assignment_limit_staff_types_1458117728 as alst
6502 on alct.assignment_limit_id = alst.assignment_limit_id
6503 and ast.staff_type_id = alst.staff_type_id
6504 inner join (
6505 select assignment_limit_id, start_date, end_date
6506 from buffer_linkage_assignments_count_weeks_1458117728
6507 group by assignment_limit_id, start_date, end_date
6508 order by null
6509 ) as lac
6510 on alct.assignment_limit_id = lac.assignment_limit_id
6511 and sc.schedule_on between lac.start_date and lac.end_date
6512 where sc.schedule_on = '2017-12-05'
6513 and sc.call_type_id = 49
6514 and sc.staff_id = 81
6515 on duplicate key update
6516 assignments_count = assignments_count + 1
6517
6518 (132.6ms) /* AssignmentLimitsRolling */
6519 /* Unique Key: assignment_limit_id, staff_id, start_date */
6520 insert into buffer_staff_assignments_count_rolling_1458117728 (
6521 assignment_limit_id, staff_id, start_date, end_date, assignments_count
6522 )
6523 select lac.assignment_limit_id, sc.staff_id, lac.start_date, lac.end_date,
6524 1 as assignments_count
6525 from buffer_schedules_1458117728 as sc
6526 inner join buffer_assignment_limit_call_types_1458117728 as alct
6527 on sc.call_type_id = alct.call_type_id
6528 inner join assignment_limits as al
6529 on alct.assignment_limit_id = al.id
6530 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
6531 and al.max_rolling_period is not null
6532 and al.max_rolling_limit is not null
6533 inner join assign_staff_types as ast
6534 on sc.staff_id = ast.staff_id
6535 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
6536 inner join buffer_assignment_limit_staff_types_1458117728 as alst
6537 on alct.assignment_limit_id = alst.assignment_limit_id
6538 and ast.staff_type_id = alst.staff_type_id
6539 inner join (
6540 select assignment_limit_id, start_date, end_date
6541 from buffer_linkage_assignments_count_rolling_1458117728
6542 group by assignment_limit_id, start_date, end_date
6543 order by null
6544 ) as lac
6545 on alct.assignment_limit_id = lac.assignment_limit_id
6546 and sc.schedule_on between lac.start_date and lac.end_date
6547 where sc.schedule_on = '2017-12-05'
6548 and sc.call_type_id = 49
6549 and sc.staff_id = 81
6550 on duplicate key update
6551 assignments_count = assignments_count + 1
6552
6553 (132.2ms) /* AssignmentLimitsConsecutive */
6554 /* Unique Key: assignment_limit_id, staff_id, schedule_on, start_date */
6555 insert ignore into buffer_staff_assignments_count_consecutive_1458117728 (
6556 assignment_limit_id, staff_id, schedule_on, start_date, end_date
6557 )
6558 select lac.assignment_limit_id, sc.staff_id, sc.schedule_on, lac.start_date, lac.end_date
6559 from buffer_schedules_1458117728 as sc
6560 inner join buffer_assignment_limit_call_types_1458117728 as alct
6561 on sc.call_type_id = alct.call_type_id
6562 inner join assignment_limits as al
6563 on alct.assignment_limit_id = al.id
6564 and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
6565 and al.max_consecutive_limit is not null
6566 inner join assign_staff_types as ast
6567 on sc.staff_id = ast.staff_id
6568 and sc.schedule_on between ast.begin_date and ifnull(ast.end_date, '9999-12-31')
6569 inner join buffer_assignment_limit_staff_types_1458117728 as alst
6570 on alct.assignment_limit_id = alst.assignment_limit_id
6571 and ast.staff_type_id = alst.staff_type_id
6572 inner join (
6573 select assignment_limit_id, start_date, end_date
6574 from buffer_linkage_assignments_count_consecutive_1458117728
6575 group by assignment_limit_id, start_date, end_date
6576 order by null
6577 ) as lac
6578 on alct.assignment_limit_id = lac.assignment_limit_id
6579 and sc.schedule_on between lac.start_date and lac.end_date
6580 where sc.schedule_on = '2017-12-05'
6581 and sc.call_type_id = 49
6582 and sc.staff_id = 81
6583
6584INFO : (04-06 20:54:30) scheduled for: plan unit: [id:14201749] [2017-12-05 - GI1], Stephen Mclovin. DEPTH(3)