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