Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (146.7ms) SET NAMES utf8 COLLATE utf8_unicode_ci, @@SESSION.sql_mode = 'NO_ENGINE_SUBSTITUTION', @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
- Client Load (1064.6ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 325 LIMIT 1
- CalendarSchedule Load (143.6ms) SELECT `calendar_schedules`.* FROM `calendar_schedules` WHERE `calendar_schedules`.`client_id` = 325 AND `calendar_schedules`.`id` = 1396 ORDER BY `calendar_schedules`.`position` ASC LIMIT 1
- CallType Load (985.8ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` IN (12732, 12733, 12734)
- CalendarSchedule Load (1003.4ms) SELECT `calendar_schedules`.* FROM `calendar_schedules` WHERE `calendar_schedules`.`client_id` = 325 AND `calendar_schedules`.`id` = 1396 ORDER BY `calendar_schedules`.`position` ASC LIMIT 1
- Block Load (145.1ms) SELECT `blocks`.* FROM `blocks` INNER JOIN `block_schedules` ON `blocks`.`block_schedule_id` = `block_schedules`.`id` WHERE `block_schedules`.`id` = 456 AND `blocks`.`id` = 39648 ORDER BY start_date asc, end_date asc LIMIT 1
- BlockSchedule Load (618.6ms) SELECT `block_schedules`.* FROM `block_schedules` WHERE `block_schedules`.`id` = 456 LIMIT 1
- PopulationTimeframe Load (587.0ms) SELECT `population_timeframes`.* FROM `population_timeframes` WHERE `population_timeframes`.`client_id` = 325 AND `population_timeframes`.`timeframe_type` = 1 ORDER BY `population_timeframes`.`id` ASC LIMIT 1
- RuleSet Load (154.5ms) SELECT `rule_sets`.* FROM `rule_sets` WHERE `rule_sets`.`id` = 1538 LIMIT 1
- Block Load (151.3ms) SELECT `blocks`.* FROM `blocks` INNER JOIN `block_schedules` ON `blocks`.`block_schedule_id` = `block_schedules`.`id` WHERE `block_schedules`.`id` = 456 AND (blocks.start_date >= '2019-08-01' AND blocks.end_date <= '2019-08-31') ORDER BY start_date asc, end_date asc
- INFO : (02-15 13:32:05) phase: Scheduler::Base
- INFO : (02-15 13:32:05) from: 2019-08-01 to: 2019-08-31
- Rule Load (658.2ms) SELECT `rules`.* FROM `rules` WHERE `rules`.`rule_set_id` = 1538 ORDER BY applied desc, weight desc
- INFO : (02-15 13:32:06) rule configurations: Default
- -
- INFO : (02-15 13:32:06) started: Scheduler::Cache::Collector.collect_all
- INFO : (02-15 13:32:06) collect_staffs
- Staff Load (304.1ms) SELECT DISTINCT `staffs`.* FROM `staffs` INNER JOIN `staff_entities` `staff_entities_staffs` ON `staff_entities_staffs`.`staff_id` = `staffs`.`id` 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` INNER JOIN `staff_entities` ON `staffs`.`id` = `staff_entities`.`staff_id` WHERE `staff_entities`.`entity_id` = 325 AND `staffs`.`take_call` = 1 AND `staffs`.`active` = 1 ORDER BY staff_entities.entity_id, staff_entities.display_order, last_name, first_name
- Client Load (596.4ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` IN (319, 325)
- StaffSpecialization Load (151.8ms) SELECT `staff_specializations`.* FROM `staff_specializations` WHERE `staff_specializations`.`staff_id` IN (20702, 20733, 20704, 20739, 20695, 20722, 20740, 20738, 20747)
- Specialization Load (340.9ms) SELECT `specializations`.* FROM `specializations` WHERE `specializations`.`id` IN (711, 712) ORDER BY `specializations`.`priority` ASC
- StaffCallType Load (744.7ms) SELECT `staff_call_types`.* FROM `staff_call_types` WHERE `staff_call_types`.`staff_id` IN (20702, 20733, 20704, 20739, 20695, 20722, 20740, 20738, 20747)
- INFO : (02-15 13:32:14) initial eligibles: [20702,20733,20704,20739,20695,20722,20740,20738,20747]
- INFO : (02-15 13:32:14) collect_call_types
- CallType Load (1073.2ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`client_id` = 325 AND `call_types`.`active` = 1 ORDER BY `call_types`.`display_order` ASC
- INFO : (02-15 13:32:15) initial call types: [12732,12733,12734,12753]
- INFO : (02-15 13:32:15) collect_chain_links
- ChainLink Load (153.0ms) SELECT `chain_links`.* FROM `chain_links` WHERE `chain_links`.`client_id` = 325
- INFO : (02-15 13:32:15) collect_linkages
- INFO : (02-15 13:32:15) collect_schedules
- Schedule Load (152.4ms) SELECT `schedules`.* FROM `schedules` WHERE `schedules`.`client_id` = 325 AND (`schedules`.`schedule_on` BETWEEN '2019-08-01' AND '2019-08-31')
- INFO : (02-15 13:32:16) collect_slots
- INFO : (02-15 13:32:16) collect_approved_call_requests
- Request Load (141.9ms) SELECT `requests`.* FROM `requests` INNER JOIN `staffs` ON `staffs`.`id` = `requests`.`staff_id` WHERE `requests`.`client_id` = 325 AND `requests`.`request_type` = 1 AND `requests`.`status` = 1 AND (`requests`.`schedule_on` BETWEEN '2019-08-01' AND '2019-08-31') ORDER BY requests.schedule_on ASC, staffs.request_priority ASC, requests.created_at ASC
- INFO : (02-15 13:32:16) collect_approved_no_call_requests
- Request Load (183.5ms) SELECT `requests`.* FROM `requests` WHERE `requests`.`client_id` = 325 AND `requests`.`request_type` = 0 AND `requests`.`status` = 1 AND (`requests`.`schedule_on` BETWEEN '2019-08-01' AND '2019-08-31') ORDER BY requests.schedule_on asc, requests.created_at asc
- INFO : (02-15 13:32:16) finished: Scheduler::Cache::Collector.collect_all
- INFO : (02-15 13:32:16) == begin to process requests
- CallType Load (492.1ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`calendar_schedule_id` = 1396 AND `call_types`.`active` = 1
- (146.4ms) SELECT MAX(blocks.end_date) FROM `published_blocks` INNER JOIN `blocks` ON `blocks`.`id` = `published_blocks`.`block_id` WHERE `published_blocks`.`calendar_schedule_id` = 1396 AND ((published_blocks.assignment_ids IS NULL) AND (published_blocks.days_of_week_mask = 127))
- Request Load (155.3ms) SELECT distinct requests.* FROM `requests` INNER JOIN `request_call_types` ON `request_call_types`.`request_id` = `requests`.`id` WHERE `requests`.`client_id` = 325 AND `requests`.`status` = 1 AND `requests`.`request_type` = 1 AND `request_call_types`.`call_type_id` IN (12732, 12733, 12734) AND (requests.schedule_on > '2019-02-28')
- SQL (162.5ms) UPDATE `schedules` SET `schedules`.`populate_method` = 'auto_approved_request', `schedules`.`creator_id` = 20695 WHERE `schedules`.`client_id` = 325 AND 1=0
- INFO : (02-15 13:32:18) == end of requests processing
- Block Load (152.4ms) SELECT `blocks`.* FROM `blocks` INNER JOIN `block_schedules` ON `blocks`.`block_schedule_id` = `block_schedules`.`id` WHERE `block_schedules`.`id` = 456 AND (blocks.start_date <= '2019-08-31' AND blocks.end_date >= '2019-08-31') ORDER BY start_date asc, end_date asc LIMIT 1
- Block Load (151.4ms) SELECT `blocks`.* FROM `blocks` WHERE `blocks`.`client_id` = 325 AND `blocks`.`block_schedule_id` = 456 AND (blocks.end_date < '2019-08-01') AND (blocks.id != 39648) ORDER BY start_date desc
- Client Load (1418.5ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 325 LIMIT 1
- (498.9ms) SELECT `autopopulate_exclusions`.`schedule_on`, `autopopulate_exclusions`.`call_type_id` FROM `autopopulate_exclusions` WHERE `autopopulate_exclusions`.`client_id` = 325 AND `autopopulate_exclusions`.`schedule_on` IN ('2019-08-01', '2019-08-02', '2019-08-03', '2019-08-04', '2019-08-05', '2019-08-06', '2019-08-07', '2019-08-08', '2019-08-09', '2019-08-10', '2019-08-11', '2019-08-12', '2019-08-13', '2019-08-14', '2019-08-15', '2019-08-16', '2019-08-17', '2019-08-18', '2019-08-19', '2019-08-20', '2019-08-21', '2019-08-22', '2019-08-23', '2019-08-24', '2019-08-25', '2019-08-26', '2019-08-27', '2019-08-28', '2019-08-29', '2019-08-30', '2019-08-31')
- (141.9ms) select
- b.start_date,
- b.end_date,
- (pb.assignment_ids IS NULL) as fully_published,
- concat(pbct.assignment_type, '#', pbct.assignment_id) as assignment_uid,
- pbct.days_of_week_mask
- from blocks as b
- inner join published_blocks as pb
- on pb.block_id = b.id
- inner join published_block_call_types as pbct
- on pbct.published_block_id = pb.id
- where b.client_id = 325
- and pb.calendar_schedule_id = 1396
- and b.end_date BETWEEN '2019-08-01' AND '2019-08-31'
- INFO : (02-15 13:32:21) <-- clear: 0 - Scheduler::AutoPopulate::Queries::CreateTables
- INFO : (02-15 13:32:21) <-- clear: 1 - Scheduler::AutoPopulate::Queries::AutoPopulateSlots
- INFO : (02-15 13:32:21) <-- clear: 2 - Scheduler::AutoPopulate::Queries::Query003
- INFO : (02-15 13:32:21) <-- clear: 3 - Scheduler::AutoPopulate::Queries::Query005
- INFO : (02-15 13:32:21) <-- clear: 4 - Scheduler::AutoPopulate::Queries::Query01
- INFO : (02-15 13:32:21) <-- clear: 5 - Scheduler::AutoPopulate::Queries::Query012
- INFO : (02-15 13:32:21) <-- clear: 6 - Scheduler::AutoPopulate::Queries::QueryTargets
- INFO : (02-15 13:32:21) <-- clear: 7 - Scheduler::AutoPopulate::Queries::Query013
- INFO : (02-15 13:32:21) <-- clear: 8 - Scheduler::AutoPopulate::Queries::Query014
- INFO : (02-15 13:32:21) <-- clear: 9 - Scheduler::AutoPopulate::Queries::Query016
- INFO : (02-15 13:32:21) <-- clear: 10 - Scheduler::AutoPopulate::Queries::Query02
- INFO : (02-15 13:32:21) <-- clear: 11 - Scheduler::AutoPopulate::Queries::Query03
- INFO : (02-15 13:32:21) <-- clear: 12 - Scheduler::AutoPopulate::Queries::Query04
- INFO : (02-15 13:32:21) <-- clear: 13 - Scheduler::AutoPopulate::Queries::Query045
- INFO : (02-15 13:32:21) <-- clear: 14 - Scheduler::AutoPopulate::Queries::QueryA
- INFO : (02-15 13:32:21) <-- clear: 15 - Scheduler::AutoPopulate::Queries::QueryB
- INFO : (02-15 13:32:21) <-- clear: 16 - Scheduler::AutoPopulate::Queries::Query05
- INFO : (02-15 13:32:21) <-- clear: 17 - Scheduler::AutoPopulate::Queries::Query06
- INFO : (02-15 13:32:21) <-- clear: 18 - Scheduler::AutoPopulate::Queries::Query07
- INFO : (02-15 13:32:21) <-- clear: 19 - Scheduler::AutoPopulate::Queries::Query0702
- INFO : (02-15 13:32:21) <-- clear: 20 - Scheduler::AutoPopulate::Queries::Query0705
- INFO : (02-15 13:32:21) <-- clear: 21 - Scheduler::AutoPopulate::Queries::Query0706
- INFO : (02-15 13:32:21) <-- clear: 22 - Scheduler::AutoPopulate::Queries::Query0707
- INFO : (02-15 13:32:21) <-- clear: 23 - Scheduler::AutoPopulate::Queries::Query0708
- INFO : (02-15 13:32:21) <-- clear: 24 - Scheduler::AutoPopulate::Queries::Query0709
- INFO : (02-15 13:32:21) <-- clear: 25 - Scheduler::AutoPopulate::Queries::Query08
- INFO : (02-15 13:32:21) <-- clear: 26 - Scheduler::AutoPopulate::Queries::Query085
- INFO : (02-15 13:32:21) <-- clear: 27 - Scheduler::AutoPopulate::Queries::Query09
- INFO : (02-15 13:32:21) <-- clear: 28 - Scheduler::AutoPopulate::Queries::Query092
- INFO : (02-15 13:32:21) <-- clear: 29 - Scheduler::AutoPopulate::Queries::Query093
- INFO : (02-15 13:32:21) <-- clear: 30 - Scheduler::AutoPopulate::Queries::Query095
- INFO : (02-15 13:32:21) <-- clear: 31 - Scheduler::AutoPopulate::Queries::Query097
- INFO : (02-15 13:32:21) <-- clear: 32 - Scheduler::AutoPopulate::Queries::Query098
- INFO : (02-15 13:32:21) <-- clear: 33 - Scheduler::AutoPopulate::Queries::Query09_09_AL
- INFO : (02-15 13:32:21) <-- clear: 34 - Scheduler::AutoPopulate::Queries::AssignmentLimitApplicability
- INFO : (02-15 13:32:21) <-- clear: 35 - Scheduler::AutoPopulate::Queries::Query09_09_AL_01
- INFO : (02-15 13:32:21) <-- clear: 36 - Scheduler::AutoPopulate::Queries::Query09_09_AL_02
- INFO : (02-15 13:32:21) <-- clear: 37 - Scheduler::AutoPopulate::Queries::Query09_09_AL_03
- INFO : (02-15 13:32:21) <-- clear: 38 - Scheduler::AutoPopulate::Queries::Query09_09_AL_04
- INFO : (02-15 13:32:21) <-- clear: 39 - Scheduler::AutoPopulate::Queries::Query09_09_AL_05
- INFO : (02-15 13:32:21) <-- clear: 40 - Scheduler::AutoPopulate::Queries::Query09_09_AL_06
- INFO : (02-15 13:32:21) <-- clear: 41 - Scheduler::AutoPopulate::Queries::Query09_12_Points
- INFO : (02-15 13:32:21) <-- clear: 42 - Scheduler::AutoPopulate::Queries::Query09_12_Hours
- INFO : (02-15 13:32:21) <-- clear: 43 - Scheduler::AutoPopulate::Queries::Query10
- INFO : (02-15 13:32:21) <-- clear: 44 - Scheduler::AutoPopulate::Queries::QueryScore02
- INFO : (02-15 13:32:21) <-- clear: 45 - Scheduler::AutoPopulate::Queries::QueryScore03
- INFO : (02-15 13:32:21) <-- clear: 46 - Scheduler::AutoPopulate::Queries::QueryScore04
- INFO : (02-15 13:32:21) <-- clear: 47 - Scheduler::AutoPopulate::Queries::Query11
- INFO : (02-15 13:32:21) <-- clear: 48 - Scheduler::AutoPopulate::Queries::DropTables
- (143.3ms) DROP TABLE IF EXISTS buffer_annual_hour_targets_1511818252
- (148.3ms) DROP TABLE IF EXISTS buffer_annual_point_targets_1511818252
- (156.3ms) DROP TABLE IF EXISTS buffer_annual_targets_staff_totals_1511818252
- (521.9ms) DROP TABLE IF EXISTS buffer_auto_populate_slots_1511818252
- (155.0ms) DROP TABLE IF EXISTS buffer_call_days_targets_1511818252
- (148.5ms) DROP TABLE IF EXISTS buffer_call_type_targets_1511818252
- (141.9ms) DROP TABLE IF EXISTS buffer_cumulative_cd_targets_1511818252
- (151.4ms) DROP TABLE IF EXISTS buffer_cumulative_ct_targets_1511818252
- (142.1ms) DROP TABLE IF EXISTS buffer_cumulative_dow_targets_1511818252
- (543.4ms) DROP TABLE IF EXISTS buffer_cumulative_hour_targets_1511818252
- (154.8ms) DROP TABLE IF EXISTS buffer_cumulative_oa_targets_1511818252
- (151.8ms) DROP TABLE IF EXISTS buffer_cumulative_point_targets_1511818252
- (151.4ms) DROP TABLE IF EXISTS buffer_current_cd_targets_1511818252
- (154.8ms) DROP TABLE IF EXISTS buffer_current_ct_targets_1511818252
- (154.9ms) DROP TABLE IF EXISTS buffer_current_dow_targets_1511818252
- (152.4ms) DROP TABLE IF EXISTS buffer_current_hour_targets_1511818252
- (517.2ms) DROP TABLE IF EXISTS buffer_current_oa_targets_1511818252
- (143.3ms) DROP TABLE IF EXISTS buffer_current_point_targets_1511818252
- (149.8ms) DROP TABLE IF EXISTS buffer_day_of_week_targets_1511818252
- (142.8ms) DROP TABLE IF EXISTS buffer_hour_targets_1511818252
- (509.5ms) DROP TABLE IF EXISTS buffer_linkage_call_days_targets_1511818252
- (153.2ms) DROP TABLE IF EXISTS buffer_linkage_call_type_targets_1511818252
- (525.7ms) DROP TABLE IF EXISTS buffer_linkage_targets_1511818252
- (178.9ms) DROP TABLE IF EXISTS buffer_linkage_hour_targets_1511818252
- (150.7ms) DROP TABLE IF EXISTS buffer_linkage_point_targets_1511818252
- (148.5ms) DROP TABLE IF EXISTS buffer_location_privileges_1511818252
- (152.4ms) DROP TABLE IF EXISTS buffer_periods_1511818252
- (146.4ms) DROP TABLE IF EXISTS buffer_point_targets_1511818252
- (142.2ms) DROP TABLE IF EXISTS buffer_schedules_1511818252
- (149.1ms) DROP TABLE IF EXISTS buffer_target_call_types_1511818252
- (149.0ms) DROP TABLE IF EXISTS buffer_target_daily_points_1511818252
- (148.8ms) DROP TABLE IF EXISTS buffer_target_dates_list_1511818252
- (144.6ms) DROP TABLE IF EXISTS buffer_target_primary_availabilities_1511818252
- (156.0ms) DROP TABLE IF EXISTS buffer_targets_1511818252
- (153.7ms) DROP TABLE IF EXISTS buffer_tmp_targets_availabilities_1511818252
- (144.6ms) DROP TABLE IF EXISTS buffer_tmp_targets_availabilities_exclusions_1511818252
- (153.3ms) DROP TABLE IF EXISTS buffer_tmp_targets_client_totals_1511818252
- (152.4ms) DROP TABLE IF EXISTS buffer_tmp_targets_scheduled_1511818252
- (153.9ms) DROP TABLE IF EXISTS buffer_tmp_targets_staff_totals_1511818252
- (147.1ms) DROP TABLE IF EXISTS buffer_assignment_limit_call_types_1511818252
- (142.5ms) DROP TABLE IF EXISTS buffer_assignment_limit_periods_1511818252
- (150.7ms) DROP TABLE IF EXISTS buffer_assignment_limit_staff_types_1511818252
- (152.5ms) DROP TABLE IF EXISTS buffer_assignment_limit_staffs_1511818252
- (144.9ms) DROP TABLE IF EXISTS buffer_auto_populate_slots_1511818252
- (145.9ms) DROP TABLE IF EXISTS buffer_call_type_assignments_1511818252
- (157.8ms) DROP TABLE IF EXISTS buffer_combined_availabilities_1511818252
- (151.7ms) DROP TABLE IF EXISTS buffer_combined_availability_linkages_1511818252
- (147.6ms) DROP TABLE IF EXISTS buffer_counter_increments_1511818252
- (144.8ms) DROP TABLE IF EXISTS buffer_linkage_assigned_days_1511818252
- (501.4ms) DROP TABLE IF EXISTS buffer_linkage_call_type_assignments_1511818252
- (152.2ms) DROP TABLE IF EXISTS buffer_linkage_dow_targets_1511818252
- (152.1ms) DROP TABLE IF EXISTS buffer_linkage_patterns_1511818252
- (148.0ms) DROP TABLE IF EXISTS buffer_linkages_1511818252
- (456.9ms) DROP TABLE IF EXISTS buffer_location_privileges_1511818252
- (154.3ms) DROP TABLE IF EXISTS buffer_min_distances_1511818252
- (153.4ms) DROP TABLE IF EXISTS buffer_negative_relations_1511818252
- (148.2ms) DROP TABLE IF EXISTS buffer_rule_calc_filters_1511818252
- (142.6ms) DROP TABLE IF EXISTS buffer_rule_calc_schedules_1511818252
- (156.0ms) DROP TABLE IF EXISTS buffer_rule_scores_1511818252
- (152.0ms) DROP TABLE IF EXISTS buffer_rule_scores_with_corrections_1511818252
- (154.8ms) DROP TABLE IF EXISTS buffer_schedule_linkages_1511818252
- (153.3ms) DROP TABLE IF EXISTS buffer_schedules_linkage_patterns_1511818252
- (144.6ms) DROP TABLE IF EXISTS buffer_specialization_daily_counts_1511818252
- (152.9ms) DROP TABLE IF EXISTS buffer_staff_assigned_days_1511818252
- (144.3ms) DROP TABLE IF EXISTS buffer_staff_daily_counts_1511818252
- (887.1ms) DROP TABLE IF EXISTS buffer_staff_specializations_1511818252
- (509.6ms) DROP TABLE IF EXISTS buffer_static_availabilities_1511818252
- (158.2ms) DROP TABLE IF EXISTS buffer_target_assignments_1511818252
- (151.3ms) DROP TABLE IF EXISTS buffer_linkage_assignment_limits_1511818252
- (146.4ms) DROP TABLE IF EXISTS buffer_staff_assignment_limits_1511818252
- (153.5ms) DROP TABLE IF EXISTS buffer_assignment_limits_1511818252
- (154.4ms) delete from buffer_target_dates
- where session_id = 1511818252
- INFO : (02-15 13:32:35) --> fill: 0 - Scheduler::AutoPopulate::Queries::CreateTables
- (148.8ms) CREATE TABLE IF NOT EXISTS buffer_assignment_limit_call_types_1511818252 LIKE buffer_assignment_limit_call_types
- (154.2ms) CREATE TABLE IF NOT EXISTS buffer_assignment_limit_periods_1511818252 LIKE buffer_assignment_limit_periods
- (151.8ms) CREATE TABLE IF NOT EXISTS buffer_assignment_limit_staff_types_1511818252 LIKE buffer_assignment_limit_staff_types
- (164.9ms) CREATE TABLE IF NOT EXISTS buffer_assignment_limit_staffs_1511818252 LIKE buffer_assignment_limit_staffs
- (144.7ms) CREATE TABLE IF NOT EXISTS buffer_auto_populate_slots_1511818252 LIKE buffer_auto_populate_slots
- (155.1ms) CREATE TABLE IF NOT EXISTS buffer_call_type_assignments_1511818252 LIKE buffer_call_type_assignments
- (155.5ms) CREATE TABLE IF NOT EXISTS buffer_combined_availabilities_1511818252 LIKE buffer_combined_availabilities
- (157.6ms) CREATE TABLE IF NOT EXISTS buffer_combined_availability_linkages_1511818252 LIKE buffer_combined_availability_linkages
- (164.0ms) CREATE TABLE IF NOT EXISTS buffer_counter_increments_1511818252 LIKE buffer_counter_increments
- (151.1ms) CREATE TABLE IF NOT EXISTS buffer_linkage_assigned_days_1511818252 LIKE buffer_linkage_assigned_days
- (148.8ms) CREATE TABLE IF NOT EXISTS buffer_linkage_call_type_assignments_1511818252 LIKE buffer_linkage_call_type_assignments
- (153.8ms) CREATE TABLE IF NOT EXISTS buffer_linkage_dow_targets_1511818252 LIKE buffer_linkage_dow_targets
- (147.6ms) CREATE TABLE IF NOT EXISTS buffer_linkage_patterns_1511818252 LIKE buffer_linkage_patterns
- (153.7ms) CREATE TABLE IF NOT EXISTS buffer_linkages_1511818252 LIKE buffer_linkages
- (152.8ms) CREATE TABLE IF NOT EXISTS buffer_location_privileges_1511818252 LIKE buffer_location_privileges
- (143.8ms) CREATE TABLE IF NOT EXISTS buffer_min_distances_1511818252 LIKE buffer_min_distances
- (147.0ms) CREATE TABLE IF NOT EXISTS buffer_negative_relations_1511818252 LIKE buffer_negative_relations
- (147.6ms) CREATE TABLE IF NOT EXISTS buffer_rule_calc_filters_1511818252 LIKE buffer_rule_calc_filters
- (154.0ms) CREATE TABLE IF NOT EXISTS buffer_rule_calc_schedules_1511818252 LIKE buffer_rule_calc_schedules
- (143.2ms) CREATE TABLE IF NOT EXISTS buffer_rule_scores_1511818252 LIKE buffer_rule_scores
- (154.7ms) CREATE TABLE IF NOT EXISTS buffer_rule_scores_with_corrections_1511818252 LIKE buffer_rule_scores_with_corrections
- (514.2ms) CREATE TABLE IF NOT EXISTS buffer_schedule_linkages_1511818252 LIKE buffer_schedule_linkages
- (156.7ms) CREATE TABLE IF NOT EXISTS buffer_schedules_linkage_patterns_1511818252 LIKE buffer_schedules_linkage_patterns
- (155.3ms) CREATE TABLE IF NOT EXISTS buffer_specialization_daily_counts_1511818252 LIKE buffer_specialization_daily_counts
- (190.0ms) CREATE TABLE IF NOT EXISTS buffer_staff_assigned_days_1511818252 LIKE buffer_staff_assigned_days
- (144.6ms) CREATE TABLE IF NOT EXISTS buffer_staff_daily_counts_1511818252 LIKE buffer_staff_daily_counts
- (152.8ms) CREATE TABLE IF NOT EXISTS buffer_staff_specializations_1511818252 LIKE buffer_staff_specializations
- (153.7ms) CREATE TABLE IF NOT EXISTS buffer_static_availabilities_1511818252 LIKE buffer_static_availabilities
- (164.1ms) CREATE TABLE IF NOT EXISTS buffer_target_assignments_1511818252 LIKE buffer_target_assignments
- (147.0ms) CREATE TABLE IF NOT EXISTS buffer_linkage_assignment_limits_1511818252 LIKE buffer_linkage_assignment_limits
- (171.0ms) CREATE TABLE IF NOT EXISTS buffer_staff_assignment_limits_1511818252 LIKE buffer_staff_assignment_limits
- (145.0ms) CREATE TABLE IF NOT EXISTS buffer_assignment_limits_1511818252 LIKE buffer_assignment_limits
- (144.1ms) CREATE TABLE IF NOT EXISTS buffer_annual_hour_targets_1511818252 LIKE buffer_annual_hour_targets
- (148.0ms) CREATE TABLE IF NOT EXISTS buffer_annual_point_targets_1511818252 LIKE buffer_annual_point_targets
- (156.8ms) CREATE TABLE IF NOT EXISTS buffer_annual_targets_staff_totals_1511818252 LIKE buffer_annual_targets_staff_totals
- (153.5ms) CREATE TABLE IF NOT EXISTS buffer_auto_populate_slots_1511818252 LIKE buffer_auto_populate_slots
- (157.6ms) CREATE TABLE IF NOT EXISTS buffer_call_days_targets_1511818252 LIKE buffer_call_days_targets
- (156.9ms) CREATE TABLE IF NOT EXISTS buffer_call_type_targets_1511818252 LIKE buffer_call_type_targets
- (158.1ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_cd_targets_1511818252 LIKE buffer_cumulative_cd_targets
- (507.2ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_ct_targets_1511818252 LIKE buffer_cumulative_ct_targets
- (152.6ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_dow_targets_1511818252 LIKE buffer_cumulative_dow_targets
- (156.7ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_hour_targets_1511818252 LIKE buffer_cumulative_hour_targets
- (152.4ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_oa_targets_1511818252 LIKE buffer_cumulative_oa_targets
- (158.9ms) CREATE TABLE IF NOT EXISTS buffer_cumulative_point_targets_1511818252 LIKE buffer_cumulative_point_targets
- (154.9ms) CREATE TABLE IF NOT EXISTS buffer_current_cd_targets_1511818252 LIKE buffer_current_cd_targets
- (151.3ms) CREATE TABLE IF NOT EXISTS buffer_current_ct_targets_1511818252 LIKE buffer_current_ct_targets
- (155.3ms) CREATE TABLE IF NOT EXISTS buffer_current_dow_targets_1511818252 LIKE buffer_current_dow_targets
- (155.2ms) CREATE TABLE IF NOT EXISTS buffer_current_hour_targets_1511818252 LIKE buffer_current_hour_targets
- (160.0ms) CREATE TABLE IF NOT EXISTS buffer_current_oa_targets_1511818252 LIKE buffer_current_oa_targets
- (155.5ms) CREATE TABLE IF NOT EXISTS buffer_current_point_targets_1511818252 LIKE buffer_current_point_targets
- (153.0ms) CREATE TABLE IF NOT EXISTS buffer_day_of_week_targets_1511818252 LIKE buffer_day_of_week_targets
- (150.2ms) CREATE TABLE IF NOT EXISTS buffer_hour_targets_1511818252 LIKE buffer_hour_targets
- (150.7ms) CREATE TABLE IF NOT EXISTS buffer_linkage_call_days_targets_1511818252 LIKE buffer_linkage_call_days_targets
- (539.3ms) CREATE TABLE IF NOT EXISTS buffer_linkage_call_type_targets_1511818252 LIKE buffer_linkage_call_type_targets
- (144.8ms) CREATE TABLE IF NOT EXISTS buffer_linkage_targets_1511818252 LIKE buffer_linkage_targets
- (165.9ms) CREATE TABLE IF NOT EXISTS buffer_linkage_hour_targets_1511818252 LIKE buffer_linkage_hour_targets
- (166.1ms) CREATE TABLE IF NOT EXISTS buffer_linkage_point_targets_1511818252 LIKE buffer_linkage_point_targets
- (143.1ms) CREATE TABLE IF NOT EXISTS buffer_location_privileges_1511818252 LIKE buffer_location_privileges
- (160.5ms) CREATE TABLE IF NOT EXISTS buffer_periods_1511818252 LIKE buffer_periods
- (155.5ms) CREATE TABLE IF NOT EXISTS buffer_point_targets_1511818252 LIKE buffer_point_targets
- (151.8ms) CREATE TABLE IF NOT EXISTS buffer_schedules_1511818252 LIKE buffer_schedules
- (155.5ms) CREATE TABLE IF NOT EXISTS buffer_target_call_types_1511818252 LIKE buffer_target_call_types
- (155.9ms) CREATE TABLE IF NOT EXISTS buffer_target_daily_points_1511818252 LIKE buffer_target_daily_points
- (147.6ms) CREATE TABLE IF NOT EXISTS buffer_target_dates_list_1511818252 LIKE buffer_target_dates_list
- (462.4ms) CREATE TABLE IF NOT EXISTS buffer_target_primary_availabilities_1511818252 LIKE buffer_target_primary_availabilities
- (652.6ms) CREATE TABLE IF NOT EXISTS buffer_targets_1511818252 LIKE buffer_targets
- (156.5ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_availabilities_1511818252 LIKE buffer_tmp_targets_availabilities
- (144.1ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_availabilities_exclusions_1511818252 LIKE buffer_tmp_targets_availabilities_exclusions
- (1183.3ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_client_totals_1511818252 LIKE buffer_tmp_targets_client_totals
- (145.5ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_scheduled_1511818252 LIKE buffer_tmp_targets_scheduled
- (148.7ms) CREATE TABLE IF NOT EXISTS buffer_tmp_targets_staff_totals_1511818252 LIKE buffer_tmp_targets_staff_totals
- INFO : (02-15 13:32:49) --> fill: 1 - Scheduler::AutoPopulate::Queries::AutoPopulateSlots
- (143.8ms) select
- b.start_date,
- b.end_date,
- (pb.assignment_ids IS NULL) as fully_published,
- concat(pbct.assignment_type, '#', pbct.assignment_id) as assignment_uid,
- pbct.days_of_week_mask
- from blocks as b
- inner join published_blocks as pb
- on pb.block_id = b.id
- inner join published_block_call_types as pbct
- on pbct.published_block_id = pb.id
- where b.client_id = 325
- and pb.calendar_schedule_id = 1396
- and b.end_date BETWEEN '2019-08-01' AND '2019-08-31'
- AutopopulateExclusion Load (571.6ms) SELECT `autopopulate_exclusions`.* FROM `autopopulate_exclusions` WHERE `autopopulate_exclusions`.`client_id` = 325 AND `autopopulate_exclusions`.`schedule_on` IN ('2019-08-01', '2019-08-02', '2019-08-03', '2019-08-04', '2019-08-05', '2019-08-06', '2019-08-07', '2019-08-08', '2019-08-09', '2019-08-10', '2019-08-11', '2019-08-12', '2019-08-13', '2019-08-14', '2019-08-15', '2019-08-16', '2019-08-17', '2019-08-18', '2019-08-19', '2019-08-20', '2019-08-21', '2019-08-22', '2019-08-23', '2019-08-24', '2019-08-25', '2019-08-26', '2019-08-27', '2019-08-28', '2019-08-29', '2019-08-30', '2019-08-31')
- (156.6ms) INSERT INTO buffer_auto_populate_slots_1511818252
- (schedule_on, day_of_week_mask, call_type_id, display_order, should_be_populated)
- VALUES ('2019-08-01', 16, 12732, 0, 1), ('2019-08-01', 16, 12733, 1, 1), ('2019-08-01', 16, 12734, 2, 1), ('2019-08-02', 32, 12732, 0, 1), ('2019-08-02', 32, 12733, 1, 1), ('2019-08-02', 32, 12734, 2, 1), ('2019-08-03', 64, 12732, 0, 1), ('2019-08-03', 64, 12733, 1, 1), ('2019-08-04', 1, 12732, 0, 1), ('2019-08-04', 1, 12733, 1, 1), ('2019-08-05', 2, 12732, 0, 1), ('2019-08-05', 2, 12733, 1, 1), ('2019-08-05', 2, 12734, 2, 1), ('2019-08-06', 4, 12732, 0, 1), ('2019-08-06', 4, 12733, 1, 1), ('2019-08-06', 4, 12734, 2, 1), ('2019-08-07', 8, 12732, 0, 1), ('2019-08-07', 8, 12733, 1, 1), ('2019-08-07', 8, 12734, 2, 1), ('2019-08-08', 16, 12732, 0, 1), ('2019-08-08', 16, 12733, 1, 1), ('2019-08-08', 16, 12734, 2, 1), ('2019-08-09', 32, 12732, 0, 1), ('2019-08-09', 32, 12733, 1, 1), ('2019-08-09', 32, 12734, 2, 1), ('2019-08-10', 64, 12732, 0, 1), ('2019-08-10', 64, 12733, 1, 1), ('2019-08-11', 1, 12732, 0, 1), ('2019-08-11', 1, 12733, 1, 1), ('2019-08-12', 2, 12732, 0, 1), ('2019-08-12', 2, 12733, 1, 1), ('2019-08-12', 2, 12734, 2, 1), ('2019-08-13', 4, 12732, 0, 1), ('2019-08-13', 4, 12733, 1, 1), ('2019-08-13', 4, 12734, 2, 1), ('2019-08-14', 8, 12732, 0, 1), ('2019-08-14', 8, 12733, 1, 1), ('2019-08-14', 8, 12734, 2, 1), ('2019-08-15', 16, 12732, 0, 1), ('2019-08-15', 16, 12733, 1, 1), ('2019-08-15', 16, 12734, 2, 1), ('2019-08-16', 32, 12732, 0, 1), ('2019-08-16', 32, 12733, 1, 1), ('2019-08-16', 32, 12734, 2, 1), ('2019-08-17', 64, 12732, 0, 1), ('2019-08-17', 64, 12733, 1, 1), ('2019-08-18', 1, 12732, 0, 1), ('2019-08-18', 1, 12733, 1, 1), ('2019-08-19', 2, 12732, 0, 1), ('2019-08-19', 2, 12733, 1, 1), ('2019-08-19', 2, 12734, 2, 1), ('2019-08-20', 4, 12732, 0, 1), ('2019-08-20', 4, 12733, 1, 1), ('2019-08-20', 4, 12734, 2, 1), ('2019-08-21', 8, 12732, 0, 1), ('2019-08-21', 8, 12733, 1, 1), ('2019-08-21', 8, 12734, 2, 1), ('2019-08-22', 16, 12732, 0, 1), ('2019-08-22', 16, 12733, 1, 1), ('2019-08-22', 16, 12734, 2, 1), ('2019-08-23', 32, 12732, 0, 1), ('2019-08-23', 32, 12733, 1, 1), ('2019-08-23', 32, 12734, 2, 1), ('2019-08-24', 64, 12732, 0, 1), ('2019-08-24', 64, 12733, 1, 1), ('2019-08-25', 1, 12732, 0, 1), ('2019-08-25', 1, 12733, 1, 1), ('2019-08-26', 2, 12732, 0, 1), ('2019-08-26', 2, 12733, 1, 1), ('2019-08-26', 2, 12734, 2, 1), ('2019-08-27', 4, 12732, 0, 1), ('2019-08-27', 4, 12733, 1, 1), ('2019-08-27', 4, 12734, 2, 1), ('2019-08-28', 8, 12732, 0, 1), ('2019-08-28', 8, 12733, 1, 1), ('2019-08-28', 8, 12734, 2, 1), ('2019-08-29', 16, 12732, 0, 1), ('2019-08-29', 16, 12733, 1, 1), ('2019-08-29', 16, 12734, 2, 1), ('2019-08-30', 32, 12732, 0, 1), ('2019-08-30', 32, 12733, 1, 1), ('2019-08-30', 32, 12734, 2, 1), ('2019-08-31', 64, 12732, 0, 1), ('2019-08-31', 64, 12733, 1, 1)
- INFO : (02-15 13:32:50) --> fill: 2 - Scheduler::AutoPopulate::Queries::Query003
- (678.8ms) insert into buffer_auto_populate_slots_1511818252/* client_id */ (
- schedule_on,
- day_of_week_mask,
- call_type_id,
- display_order,
- should_be_populated
- )
- select distinct
- date_add(
- auto_populate_slots.schedule_on,
- interval soft_linkages.offset day
- ) as schedule_on,
- (1 << (
- dayofweek(
- date_add(
- auto_populate_slots.schedule_on,
- interval soft_linkages.offset day
- )
- ) - 1
- )
- ) as day_of_week_mask,
- soft_linkages.linked_call_type_id as call_type_id,
- call_types.display_order,
- 0 as should_be_populated
- from
- buffer_auto_populate_slots_1511818252/* client_id */ as auto_populate_slots
- inner join soft_linkages
- on auto_populate_slots.call_type_id = soft_linkages.call_type_id
- and auto_populate_slots.day_of_week_mask = soft_linkages.day_of_week_mask
- left join buffer_auto_populate_slots_1511818252/* client_id */ as auto_populate_slots_2
- on date_add(
- auto_populate_slots.schedule_on,
- interval soft_linkages.offset day
- ) = auto_populate_slots_2.schedule_on
- and soft_linkages.linked_call_type_id = auto_populate_slots_2.call_type_id
- inner join call_types
- on soft_linkages.linked_call_type_id = call_types.id
- where auto_populate_slots_2.id is null
- order by null
- INFO : (02-15 13:32:51) --> fill: 3 - Scheduler::AutoPopulate::Queries::Query005
- (170.7ms) insert into buffer_auto_populate_slots_1511818252 (
- schedule_on,
- day_of_week_mask,
- call_type_id,
- display_order,
- should_be_populated
- )
- select distinct
- date_add(
- auto_populate_slots.schedule_on,
- interval linkage_relations.distance_in_days day
- ) as schedule_on,
- (1 << (
- dayofweek(
- date_add(
- auto_populate_slots.schedule_on,
- interval linkage_relations.distance_in_days day
- )
- ) - 1
- )
- ) as day_of_week_mask,
- linkage_relations.linked_call_type_id as call_type_id,
- call_types.display_order,
- 0 as should_be_populated
- from
- buffer_auto_populate_slots_1511818252 as auto_populate_slots
- inner join linkage_relations
- on auto_populate_slots.call_type_id = linkage_relations.call_type_id
- and auto_populate_slots.day_of_week_mask = linkage_relations.day_of_week_mask
- left join buffer_auto_populate_slots_1511818252 as auto_populate_slots_2
- on date_add(
- auto_populate_slots.schedule_on,
- interval linkage_relations.distance_in_days day
- ) = auto_populate_slots_2.schedule_on
- and linkage_relations.linked_call_type_id = auto_populate_slots_2.call_type_id
- inner join call_types
- on linkage_relations.linked_call_type_id = call_types.id
- where auto_populate_slots_2.id is null
- order by null
- INFO : (02-15 13:32:51) --> fill: 4 - Scheduler::AutoPopulate::Queries::Query01
- (156.3ms) insert into linkage_relations (
- client_id,
- call_type_id,
- day_of_week_mask,
- linked_call_type_id,
- distance_in_days,
- linkage_template_id
- )
- select distinct
- 325 /* client_id */ as client_id,
- aps.call_type_id,
- aps.day_of_week_mask,
- aps.call_type_id as linked_call_type_id,
- 0 as distance_in_days,
- coalesce(
- lr.linkage_template_id,
- @linkage_template_max := @linkage_template_max + 1
- ) as linkage_template_id
- from
- buffer_auto_populate_slots_1511818252/* client_id */ as aps
- inner join (
- select @linkage_template_max := count(distinct linkage_template_id) - 1
- from linkage_relations
- where client_id = 325 /* client_id */
- order by null
- ) as lt
- on 1 = 1
- left join linkage_relations as lr use index (ix_linkage_relations_composite1)
- on aps.call_type_id = lr.call_type_id
- and aps.day_of_week_mask = lr.day_of_week_mask
- left join linkage_relations as lr_2 use index (ix_linkage_relations_composite1)
- on aps.call_type_id = lr_2.call_type_id
- and aps.day_of_week_mask = lr_2.day_of_week_mask
- and aps.call_type_id = lr_2.linked_call_type_id
- and lr_2.distance_in_days = 0
- where lr_2.id is null
- order by null
- (158.0ms) insert into buffer_schedules_1511818252 (
- call_type_id,
- staff_id,
- schedule_on,
- day_of_week_mask,
- is_weekend,
- display_order,
- week_number,
- should_be_evaluated,
- should_be_populated,
- linkage_instance_id
- )
- select
- call_type_id,
- staff_id,
- schedule_on,
- day_of_week_mask,
- is_weekend,
- display_order,
- week_number,
- max(should_be_evaluated) as should_be_evaluated,
- max(should_be_populated) as should_be_populated,
- min(linkage_instance_id) as linkage_instance_id
- from (
- select
- auto_populate_slots_2.call_type_id,
- schedules.staff_id,
- auto_populate_slots_2.schedule_on,
- auto_populate_slots_2.day_of_week_mask,
- case
- when (auto_populate_slots_2.day_of_week_mask & 62 > 0) then 0
- else 1
- end as is_weekend,
- auto_populate_slots_2.display_order,
- yearweek(
- auto_populate_slots_2.schedule_on,
- case
- when (clients.start_of_week = 0) then 2
- else 7
- end
- ) as week_number,
- case
- when (schedules.staff_id is null) then 1
- else 0
- end as should_be_evaluated,
- (
- case
- when (
- auto_populate_slots_2.should_be_populated = 1
- and schedules.staff_id is null
- ) then 1
- else 0
- end
- ) as should_be_populated,
- (
- linkage_relations.linkage_template_id * 1000000 +
- yearweek(
- auto_populate_slots.schedule_on,
- case
- when (clients.start_of_week = 0) then 2
- else 7
- end
- )
- ) as linkage_instance_id
- from
- buffer_auto_populate_slots_1511818252 as auto_populate_slots
- inner join clients
- on clients.id = 325 /* client_id */
- inner join linkage_relations
- on auto_populate_slots.call_type_id = linkage_relations.call_type_id
- and auto_populate_slots.day_of_week_mask = linkage_relations.day_of_week_mask
- inner join buffer_auto_populate_slots_1511818252 as auto_populate_slots_2
- on date_add(
- auto_populate_slots.schedule_on,
- interval linkage_relations.distance_in_days day
- ) = auto_populate_slots_2.schedule_on
- and linkage_relations.linked_call_type_id = auto_populate_slots_2.call_type_id
- left join schedules
- on auto_populate_slots_2.call_type_id = schedules.call_type_id
- and auto_populate_slots_2.schedule_on = schedules.schedule_on
- -- we should exclude do-not-populate slots
- left join autopopulate_exclusions
- on auto_populate_slots_2.call_type_id = autopopulate_exclusions.call_type_id
- and auto_populate_slots_2.schedule_on = autopopulate_exclusions.schedule_on
- where
- -- only empty slots can behave as do-not-populate (when they are marked appropriately)
- -- once we added someone to that slot then it should be considered as a regular one
- schedules.id is not null
- or autopopulate_exclusions.id is null
- order by null
- ) as t1
- group by
- call_type_id,
- staff_id,
- schedule_on,
- day_of_week_mask,
- display_order,
- week_number
- order by null
- INFO : (02-15 13:32:51) --> fill: 5 - Scheduler::AutoPopulate::Queries::Query012
- (154.8ms) update
- buffer_schedules_1511818252 as sc
- inner join call_types as ct
- on sc.call_type_id = ct.id
- inner join calendar_schedules as cs
- on ct.calendar_schedule_id = cs.id
- inner join blocks as b
- on cs.block_schedule_id = b.block_schedule_id
- and sc.schedule_on between b.start_date and b.end_date
- set
- sc.calendar_schedule_id = cs.id,
- sc.block_id = b.id
- BlockSchedule Load (154.0ms) SELECT `block_schedules`.* FROM `block_schedules` WHERE `block_schedules`.`id` = 456 LIMIT 1
- (159.1ms) insert into buffer_periods_1511818252 (
- calendar_schedule_id,
- block_schedule_id,
- period_offset,
- start_block_display_order,
- end_block_display_order,
- start_date,
- end_date,
- should_be_populated,
- should_be_evaluated
- )
- select
- t1.calendar_schedule_id,
- t1.block_schedule_id,
- t1.period_offset,
- t2.start_block_display_order,
- t2.end_block_display_order,
- t2.start_date,
- t2.end_date,
- t1.should_be_populated,
- t1.should_be_evaluated
- from (
- select
- sc.calendar_schedule_id,
- b.block_schedule_id,
- case
- when ((month(b.start_date) - pt.begin_period) >= 0)
- then (year(b.start_date) * 100 + (month(b.start_date) - pt.begin_period) div pt.timeframe_type)
- else
- ((year(b.start_date) - 1) * 100 + (month(b.start_date) + 12 - pt.begin_period) div pt.timeframe_type)
- end as period_offset,
- max(sc.should_be_populated) as should_be_populated,
- max(sc.should_be_evaluated) as should_be_evaluated
- from (
- select
- sc.block_id,
- sc.calendar_schedule_id,
- max(ps.should_be_populated) as should_be_populated,
- 1 as should_be_evaluated
- from
- buffer_schedules_1511818252 as sc
- inner join buffer_auto_populate_slots_1511818252 as ps
- on sc.schedule_on = ps.schedule_on
- and sc.call_type_id = ps.call_type_id
- group by
- sc.block_id,
- sc.calendar_schedule_id
- order by null
- ) as sc
- inner join blocks as b
- on sc.block_id = b.id
- inner join population_timeframes as pt
- on pt.client_id = 325
- and pt.timeframe_type = 1
- group by
- sc.calendar_schedule_id,
- b.block_schedule_id,
- period_offset
- order by null
- ) as t1
- inner join (
- select
- b.block_schedule_id,
- case
- when ((month(b.start_date) - pt.begin_period) >= 0)
- then (year(b.start_date) * 100 + (month(b.start_date) - pt.begin_period) div pt.timeframe_type)
- else
- ((year(b.start_date) - 1) * 100 + (month(b.start_date) + 12 - pt.begin_period) div pt.timeframe_type)
- end as period_offset,
- min(b.display_order) as start_block_display_order,
- max(b.display_order) as end_block_display_order,
- min(b.start_date) as start_date,
- max(b.end_date) as end_date
- from
- blocks as b
- inner join population_timeframes as pt
- on pt.client_id = 325
- and pt.timeframe_type = 1
- where
- b.client_id = 325
- group by
- b.block_schedule_id,
- period_offset
- order by null
- ) as t2
- on t1.block_schedule_id = t2.block_schedule_id
- and t1.period_offset = t2.period_offset
- order by null
- (154.0ms) update
- buffer_schedules_1511818252 as sc
- inner join buffer_periods_1511818252 as p
- on sc.calendar_schedule_id = p.calendar_schedule_id
- and sc.schedule_on between p.start_date and p.end_date
- set sc.period_offset = p.period_offset
- INFO : (02-15 13:32:52) --> fill: 6 - Scheduler::AutoPopulate::Queries::QueryTargets
- INFO : (02-15 13:32:52) --> fill: 7 - Scheduler::AutoPopulate::Queries::Query013
- (167.7ms) insert into buffer_counter_increments_1511818252 (
- schedule_id,
- calls,
- points,
- hours,
- affects_cumulative_targets
- )
- select
- sc.id as schedule_id,
- case
- when (ct.included_in_targets > 0) then 1
- else 0
- end as calls,
- coalesce(
- case
- when (hl.observed_date is null or dp.point is not null) then dp.point
- else dp_2.point
- end,
- 0.0
- ) as points,
- ct.hours,
- case
- when (b.display_order between (t1.timeframe_ending - (8 /* cumulative targets period */ - 1)) and t1.timeframe_ending) then 1
- else 0
- end as affects_cumulative_targets
- from
- buffer_schedules_1511818252 as sc
- inner join (
- select
- id,
- included_in_targets,
- coalesce(
- timestampdiff(
- minute,
- concat('1900-01-01 ', maketime(start_time_hour, start_time_minute, 0)),
- concat(
- '1900-01-0',
- case
- when ((
- start_time_hour | start_time_minute | end_time_hour | end_time_minute > 0
- )
- and (
- timediff(
- maketime(end_time_hour, end_time_minute, 0),
- maketime(start_time_hour, start_time_minute, 0)
- ) <= 0
- )
- ) then '2'
- else '1'
- end,
- ' ',
- maketime(end_time_hour, end_time_minute, 0)
- )
- ) / 60,
- 0.0
- ) as hours
- from call_types
- where
- client_id = 325
- and active = 1
- order by null
- ) as ct
- on sc.call_type_id = ct.id
- inner join blocks as b
- on sc.block_id = b.id
- inner join (
- select
- calendar_schedule_id,
- max(
- case
- when (should_be_populated = 1) then end_block_display_order
- else null
- end
- ) as timeframe_ending
- from buffer_periods_1511818252
- group by calendar_schedule_id
- order by null
- ) as t1
- on sc.calendar_schedule_id = t1.calendar_schedule_id
- left join (
- select
- hd.observed_date,
- case
- when (hd.observed_date > hd.extended_date) then hd.extended_date
- else hd.observed_date
- end as date_from,
- case
- when (hd.observed_date < hd.extended_date) then hd.extended_date
- else hd.observed_date
- end as date_to
- from
- holidays as h
- inner join holiday_dates as hd
- on h.id = hd.holiday_id
- inner join (
- select
- year(min(schedule_on)) as year_from,
- year(max(schedule_on)) as year_to
- from buffer_schedules_1511818252
- where should_be_evaluated = 1
- ) as y
- on hd.year between y.year_from and y.year_to
- where
- h.client_id = 325
- and (
- h.observed = 1
- or h.extended = 1
- )
- order by null
- ) as hl
- on sc.schedule_on between hl.date_from and hl.date_to
- left join assignment_annotations as aa
- on ct.id = aa.assignmentable_id
- and aa.assignmentable_type = 'CallType'
- and aa.annotation_id = 0 /* annotation = "None" */
- and aa.applicable = 1
- left join assignment_annotation_daily_points as dp
- on aa.id = dp.assignment_annotation_id
- and case
- when (hl.observed_date is null) then (dayofweek(sc.schedule_on) - 1)
- when (sc.schedule_on = hl.observed_date) then 7
- else 8
- end = dp.day
- left join assignment_annotation_daily_points as dp_2
- on aa.id = dp_2.assignment_annotation_id
- and (dayofweek(sc.schedule_on) - 1) = dp_2.day
- where sc.should_be_evaluated = 1
- order by null
- INFO : (02-15 13:32:52) --> fill: 8 - Scheduler::AutoPopulate::Queries::Query014
- (153.7ms) -- Prepare the information about the blocks we're populating and the linkage patterns which will be used on those blocks
- insert into buffer_linkage_patterns_1511818252 (
- period_offset,
- calendar_schedule_id,
- block_id,
- block_start_date,
- block_start_dow,
- block_length,
- linkage_pattern_id,
- pattern_start_dow,
- days_before_start,
- pattern_length,
- start_offset,
- iterations_count
- )
- select
- b1.period_offset,
- b1.calendar_schedule_id,
- b1.block_id,
- b2.start_date as block_start_date,
- dayofweek(b2.start_date) as block_start_dow,
- (datediff(b2.end_date, b2.start_date) + 1) as block_length,
- lp.id as linkage_pattern_id,
- (lp.start_on + 1) as pattern_start_dow,
- lp.days_before_start,
- (lp.length * 7) as pattern_length,
- null as start_offset,
- null as iterations_count
- from (
- select
- calendar_schedule_id,
- block_id,
- period_offset
- from buffer_schedules_1511818252
- group by
- calendar_schedule_id,
- block_id,
- period_offset
- order by null
- ) as b1
- inner join blocks as b2
- on b1.block_id = b2.id
- inner join linkage_patterns as lp
- on lp.client_id = 325
- and b1.calendar_schedule_id = lp.calendar_schedule_id
- order by null
- (158.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
- update buffer_linkage_patterns_1511818252
- set start_offset = if(
- (pattern_start_dow + (case when (pattern_start_dow < block_start_dow) then 7 else 0 end) - block_start_dow) <= days_before_start,
- (pattern_start_dow + (case when (pattern_start_dow < block_start_dow) then 7 else 0 end) - block_start_dow),
- (block_start_dow + (case when (block_start_dow < pattern_start_dow) then 7 else 0 end) - pattern_start_dow) * (-1)
- )
- (149.5ms) -- 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)
- -- a pattern should be repeated couple of times (in order to cover the entire block)
- update buffer_linkage_patterns_1511818252
- set iterations_count =
- ceiling(
- (
- block_length +
- case
- when (start_offset < 0) then abs(start_offset)
- else 0
- end
- ) * 1.0 / pattern_length
- )
- (2385.3ms) -- Generate an assignments sequence for every linkage pattern
- insert into buffer_schedules_linkage_patterns_1511818252 (
- call_type_id,
- staff_id,
- schedule_on,
- period_offset,
- day_of_week_mask,
- display_order,
- week_number,
- should_be_evaluated,
- should_be_populated,
- linkage_instance_id,
- block_id,
- calendar_schedule_id
- )
- select
- lps.assignment_id as call_type_id,
- null as staff_id,
- case
- when (lp.start_offset < 0)
- then date_add(lp.block_start_date, interval (lp.start_offset + ns.item_number * lp.pattern_length + lps.offset) day)
- else
- date_add(lp.block_start_date, interval ((lp.start_offset + ns.item_number * lp.pattern_length + lps.offset) mod lp.block_length) day)
- end as schedule_on,
- lp.period_offset,
- null as day_of_week_mask,
- null as display_order,
- null as week_number,
- 0 as should_be_evaluated,
- 0 as should_be_populated,
- lp.linkage_pattern_id as linkage_instance_id,
- lp.block_id,
- lp.calendar_schedule_id
- from
- numeric_sequence as ns
- inner join buffer_linkage_patterns_1511818252 as lp
- on ns.item_number <= (lp.iterations_count - 1)
- inner join linkage_pattern_slots as lps
- on lp.linkage_pattern_id = lps.linkage_pattern_id
- and lps.assignment_type = 'CallType'
- where
- case
- when (lp.start_offset < 0)
- then (lp.start_offset + ns.item_number * lp.pattern_length + lps.offset)
- else
- (ns.item_number * lp.pattern_length + lps.offset)
- end between 0 and (lp.block_length - 1)
- order by null
- (147.5ms) -- Fill the columns that we left blank in the previous "INSERT"
- update
- buffer_schedules_linkage_patterns_1511818252 as slp
- inner join clients as cl
- on cl.id = 325
- inner join call_types as ct
- on slp.call_type_id = ct.id
- left join buffer_schedules_1511818252 as bs
- on slp.schedule_on = bs.schedule_on
- and slp.call_type_id = bs.call_type_id
- set
- slp.day_of_week_mask = (1 << (dayofweek(slp.schedule_on) - 1)),
- slp.display_order = ct.display_order,
- slp.week_number =
- yearweek(
- slp.schedule_on,
- case
- when (cl.start_of_week = 0) then 2
- else 7
- end
- ),
- slp.should_be_evaluated = coalesce(bs.should_be_evaluated, 0),
- slp.should_be_populated = coalesce(bs.should_be_populated, 0);
- (152.5ms) -- Delete linkage patterns that don't have intersection with assignments we should auto-populate
- delete slp_1
- from
- buffer_schedules_linkage_patterns_1511818252 as slp_1
- inner join (
- select linkage_instance_id
- from buffer_schedules_linkage_patterns_1511818252
- group by linkage_instance_id
- having
- max(should_be_evaluated) = 0
- and max(should_be_populated) = 0
- order by null
- ) as slp_2
- on slp_1.linkage_instance_id = slp_2.linkage_instance_id
- (152.6ms) -- Delete do-not-populate slots
- delete slp
- from
- buffer_schedules_linkage_patterns_1511818252 as slp
- inner join autopopulate_exclusions as ae
- on slp.call_type_id = ae.call_type_id
- and slp.schedule_on = ae.schedule_on
- left join schedules as sc
- on slp.call_type_id = sc.call_type_id
- and slp.schedule_on = sc.schedule_on
- -- only empty slots can behave as do-not-populate (when they are marked appropriately)
- -- once we added someone to that slot then it should be considered as a regular one
- where sc.id is null
- (511.9ms) -- Use a linkage pattern ID instead of linkage instance ID for those assignments that intersect with linkage patterns
- update
- buffer_schedules_linkage_patterns_1511818252 as slp
- inner join buffer_schedules_1511818252 as bs_1
- on slp.schedule_on = bs_1.schedule_on
- and slp.call_type_id = bs_1.call_type_id
- inner join buffer_schedules_1511818252 as bs_2
- on bs_1.linkage_instance_id = bs_2.linkage_instance_id
- set bs_2.linkage_instance_id = slp.linkage_instance_id
- (165.0ms) -- Linkage pattern slots that don't have intersection with auto-populate assignments but are a part of a pattern that has such intersection
- -- should be copied over to the buffer schedules table (used during the auto-populate process)
- insert into buffer_schedules_1511818252 (
- call_type_id,
- staff_id,
- schedule_on,
- period_offset,
- day_of_week_mask,
- is_weekend,
- display_order,
- week_number,
- should_be_evaluated,
- should_be_populated,
- linkage_instance_id,
- block_id,
- calendar_schedule_id
- )
- select
- call_type_id,
- staff_id,
- schedule_on,
- period_offset,
- day_of_week_mask,
- case
- when (day_of_week_mask & 62 > 0) then 0
- else 1
- end as is_weekend,
- display_order,
- week_number,
- should_be_evaluated,
- should_be_populated,
- linkage_instance_id,
- block_id,
- calendar_schedule_id
- from buffer_schedules_linkage_patterns_1511818252
- where
- should_be_evaluated = 0
- and should_be_populated = 0
- INFO : (02-15 13:32:56) --> fill: 9 - Scheduler::AutoPopulate::Queries::Query016
- (152.5ms) insert into buffer_schedules_1511818252 (
- call_type_id,
- staff_id,
- schedule_on,
- day_of_week_mask,
- is_weekend,
- display_order,
- should_be_evaluated,
- should_be_populated,
- linkage_instance_id
- )
- select distinct
- schedules_call_overlap.call_type_id,
- schedules_call_overlap.staff_id,
- schedules_call_overlap.schedule_on,
- (1 << (dayofweek(schedules_call_overlap.schedule_on) - 1)) as day_of_week_mask,
- case
- when (dayofweek(schedules_call_overlap.schedule_on) between 2 and 6) then 0
- else 1
- end as is_weekend,
- call_types.display_order,
- 0 as should_be_evaluated,
- 0 as should_be_populated,
- -1 as linkage_instance_id
- from (
- select schedule_on
- from buffer_schedules_1511818252
- where should_be_evaluated = 1
- group by schedule_on
- order by null
- ) as buffer_schedules_1
- inner join schedules as schedules_call_overlap
- on schedules_call_overlap.client_id = 325
- and buffer_schedules_1.schedule_on = schedules_call_overlap.schedule_on
- left join buffer_schedules_1511818252 as buffer_schedules_2
- on schedules_call_overlap.schedule_on = buffer_schedules_2.schedule_on
- and schedules_call_overlap.call_type_id = buffer_schedules_2.call_type_id
- inner join call_types
- on schedules_call_overlap.call_type_id = call_types.id
- where buffer_schedules_2.id is null
- order by null
- INFO : (02-15 13:32:56) --> fill: 10 - Scheduler::AutoPopulate::Queries::Query02
- INFO : (02-15 13:32:56) --> fill: 11 - Scheduler::AutoPopulate::Queries::Query03
- INFO : (02-15 13:32:56) --> fill: 12 - Scheduler::AutoPopulate::Queries::Query04
- INFO : (02-15 13:32:56) --> fill: 13 - Scheduler::AutoPopulate::Queries::Query045
- INFO : (02-15 13:32:56) --> fill: 14 - Scheduler::AutoPopulate::Queries::QueryA
- (154.6ms) insert into buffer_schedules_1511818252 (
- call_type_id,
- staff_id,
- schedule_on,
- day_of_week_mask,
- is_weekend,
- display_order,
- should_be_evaluated,
- should_be_populated,
- linkage_instance_id
- )
- select distinct straight_join
- schedules.call_type_id,
- schedules.staff_id,
- schedules.schedule_on,
- (1 << (dayofweek(schedules.schedule_on) - 1)) as day_of_week_mask,
- case
- when (dayofweek(schedules.schedule_on) between 2 and 6) then 0
- else 1
- end as is_weekend,
- call_types.display_order,
- 0 as should_be_evaluated,
- 0 as should_be_populated,
- -1 as linkage_instance_id
- from
- buffer_schedules_1511818252 as buffer_schedules_1
- inner join negative_links_influences use index (ix_unique_links)
- on buffer_schedules_1.day_of_week_mask = negative_links_influences.day_of_week_mask
- and buffer_schedules_1.call_type_id = negative_links_influences.source_id
- and negative_links_influences.source_type = 'CallType'
- and negative_links_influences.target_type = 'CallType'
- inner join schedules use index (ix_schedules_call_date)
- on date_add(
- buffer_schedules_1.schedule_on,
- interval negative_links_influences.offset day
- ) = schedules.schedule_on
- and negative_links_influences.target_id = schedules.call_type_id
- left join buffer_schedules_1511818252 as buffer_schedules_2 use index (ix_buffer_schedules_composite_1)
- on schedules.schedule_on = buffer_schedules_2.schedule_on
- and schedules.call_type_id = buffer_schedules_2.call_type_id
- inner join call_types
- on schedules.call_type_id = call_types.id
- where
- buffer_schedules_1.linkage_instance_id >= 0
- and buffer_schedules_1.should_be_evaluated = 1
- and buffer_schedules_2.id is null
- order by null
- INFO : (02-15 13:32:57) --> fill: 15 - Scheduler::AutoPopulate::Queries::QueryB
- (142.8ms) insert into buffer_schedules_1511818252 (
- call_type_id,
- staff_id,
- schedule_on,
- day_of_week_mask,
- is_weekend,
- display_order,
- should_be_evaluated,
- should_be_populated,
- linkage_instance_id
- )
- select distinct straight_join
- (-1 * negative_links_influences.target_id) as call_type_id,
- vacations.staff_id,
- vacations.schedule_on,
- (1 << (dayofweek(vacations.schedule_on) - 1)) as day_of_week_mask,
- vacations.weekend_on as is_weekend,
- -1 as display_order,
- 0 as should_be_evaluated,
- 0 as should_be_populated,
- -1 as linkage_instance_id
- from
- buffer_schedules_1511818252 as buffer_schedules_1
- inner join negative_links_influences use index (ix_unique_links)
- on buffer_schedules_1.day_of_week_mask = negative_links_influences.day_of_week_mask
- and buffer_schedules_1.call_type_id = negative_links_influences.source_id
- and negative_links_influences.source_type = 'CallType'
- and negative_links_influences.target_id > 0
- and negative_links_influences.target_type in ('Vacation', 'NonClinicalType')
- inner join vacations use index (ix_vacations_on_schedule_and_client)
- on vacations.client_id = 325 /* client_id */
- and date_add(
- buffer_schedules_1.schedule_on,
- interval negative_links_influences.offset day
- ) = vacations.schedule_on
- and negative_links_influences.target_id = vacations.non_clinical_type_id
- and vacations.status in (3) /* based on the "non-working requests" settings */
- left join buffer_schedules_1511818252 as buffer_schedules_2 use index (ix_buffer_schedules_composite_1)
- on vacations.staff_id = buffer_schedules_2.staff_id
- and vacations.schedule_on = buffer_schedules_2.schedule_on
- and (-1 * negative_links_influences.target_id) = buffer_schedules_2.call_type_id
- where
- buffer_schedules_1.linkage_instance_id >= 0
- and buffer_schedules_1.should_be_evaluated = 1
- and buffer_schedules_2.id is null
- order by null
- INFO : (02-15 13:32:57) --> fill: 16 - Scheduler::AutoPopulate::Queries::Query05
- (145.6ms) insert into buffer_linkages_1511818252 (
- linkage_instance_id,
- slots_count_total,
- has_conflicts
- )
- select straight_join
- schedules.linkage_instance_id,
- count(1) as slots_count_total,
- if(linkage_conflicts.linkage_template_id is not null, 1, 0) as has_conflicts
- from
- buffer_schedules_1511818252 as schedules
- left join (
- select straight_join
- linkage_relations.linkage_template_id
- from linkage_relations
- inner join negative_links_influences use index (ix_unique_links)
- on linkage_relations.day_of_week_mask = negative_links_influences.day_of_week_mask
- and linkage_relations.call_type_id = negative_links_influences.source_id
- and negative_links_influences.source_type = 'CallType'
- and linkage_relations.linked_call_type_id = negative_links_influences.target_id
- and negative_links_influences.target_type = 'CallType'
- and linkage_relations.distance_in_days = negative_links_influences.offset
- where linkage_relations.client_id = 325 /* client_id */
- and (
- linkage_relations.call_type_id != linkage_relations.linked_call_type_id
- or linkage_relations.distance_in_days != 0
- )
- group by linkage_relations.linkage_template_id
- order by null
- ) as linkage_conflicts
- on (schedules.linkage_instance_id div 1000000) = linkage_conflicts.linkage_template_id
- where schedules.linkage_instance_id >= 0
- group by
- schedules.linkage_instance_id,
- has_conflicts
- order by null
- INFO : (02-15 13:32:57) --> fill: 17 - Scheduler::AutoPopulate::Queries::Query06
- (156.8ms) insert into buffer_target_assignments_1511818252 (
- call_type_id,
- target_group_id,
- assignment_id,
- assignment_type
- )
- select
- t1.call_type_id,
- ifnull(tg.id, 0) as target_group_id,
- if(tg.id is null, t1.call_type_id, tg.id) as assignment_id,
- if(tg.id is null, 'CallType', 'TargetGroup') as assignment_type
- from (
- select ct.id as call_type_id
- from
- buffer_schedules_1511818252 as sc
- inner join call_types as ct
- on sc.call_type_id = ct.id
- and ct.active = 1
- and ct.included_in_targets > 0
- where linkage_instance_id >= 0
- group by ct.id
- order by null
- ) as t1
- left join target_group_calls as tgc
- on t1.call_type_id = tgc.call_type_id
- left join target_groups as tg
- on tgc.target_group_id = tg.id
- and tg.active = 1
- order by null
- INFO : (02-15 13:32:57) --> fill: 18 - Scheduler::AutoPopulate::Queries::Query07
- INFO : (02-15 13:32:57) --> fill: 19 - Scheduler::AutoPopulate::Queries::Query0702
- INFO : (02-15 13:32:57) --> fill: 20 - Scheduler::AutoPopulate::Queries::Query0705
- (153.6ms) insert into buffer_linkage_call_type_assignments_1511818252 (
- linkage_instance_id,
- call_type_id,
- is_weekend,
- period_offset,
- calendar_schedule_id,
- max_assignments,
- assignments_count
- )
- select
- s.linkage_instance_id,
- s.call_type_id,
- s.is_weekend,
- s.period_offset,
- s.calendar_schedule_id,
- case
- when (s.is_weekend = 0) then ct.max_weekday_assignments
- else ct.max_weekend_assignments
- end as _max_assignments,
- sum(1) as assignments_count
- from buffer_schedules_1511818252 as s
- inner join call_types as ct
- on s.call_type_id = ct.id
- and ct.active = 1
- and (
- ct.max_weekday_assignments is not null
- or ct.max_weekend_assignments is not null
- )
- where s.linkage_instance_id >= 0
- and s.staff_id is null
- group by
- s.linkage_instance_id,
- s.call_type_id,
- s.is_weekend,
- s.period_offset,
- s.calendar_schedule_id,
- _max_assignments
- having _max_assignments >= 0
- order by null
- INFO : (02-15 13:32:57) --> fill: 21 - Scheduler::AutoPopulate::Queries::Query0706
- (155.2ms) insert into buffer_call_type_assignments_1511818252 (
- staff_id,
- call_type_id,
- is_weekend,
- period_offset,
- calendar_schedule_id,
- assignments_count
- )
- select
- sc.staff_id,
- sc.call_type_id,
- sc.weekend_on as is_weekend,
- p.period_offset,
- p.calendar_schedule_id,
- sum(1) as assignments_count
- from buffer_periods_1511818252 as p
- inner join call_types as ct
- on p.calendar_schedule_id = ct.calendar_schedule_id
- and ct.active = 1
- and (
- ct.max_weekday_assignments is not null
- or ct.max_weekend_assignments is not null
- )
- inner join schedules as sc
- on ct.id = sc.call_type_id
- and sc.schedule_on between p.start_date and p.end_date
- and sc.staff_id is not null
- where p.should_be_evaluated = 1
- group by
- sc.staff_id,
- sc.call_type_id,
- sc.weekend_on,
- p.period_offset,
- p.calendar_schedule_id
- order by null
- INFO : (02-15 13:32:57) --> fill: 22 - Scheduler::AutoPopulate::Queries::Query0707
- INFO : (02-15 13:32:57) --> fill: 23 - Scheduler::AutoPopulate::Queries::Query0708
- (154.7ms) insert into buffer_linkage_assigned_days_1511818252 (
- linkage_instance_id,
- period_offset,
- week_number,
- schedule_on,
- is_weekend
- )
- select distinct
- sc.linkage_instance_id,
- sc.period_offset,
- sc.week_number,
- sc.schedule_on,
- sc.is_weekend
- from
- buffer_schedules_1511818252 as sc
- inner join call_types as ct
- on sc.call_type_id = ct.id
- and ct.unassigned_day = 0
- where
- sc.linkage_instance_id >= 0
- and sc.staff_id is null
- order by null
- INFO : (02-15 13:32:57) --> fill: 24 - Scheduler::AutoPopulate::Queries::Query0709
- INFO : (02-15 13:32:57) --> fill: 25 - Scheduler::AutoPopulate::Queries::Query08
- (152.5ms) insert into buffer_staff_daily_counts_1511818252 (
- staff_id, schedule_on, linkage_instance_id, slots_count
- )
- select staff_id, schedule_on, null as linkage_instance_id,
- count(1) as slots_count
- from buffer_schedules_1511818252
- where staff_id is not null
- and call_type_id > 0 /* VC */
- group by staff_id, schedule_on
- order by null
- (153.8ms) insert into buffer_staff_daily_counts_1511818252 (
- staff_id, schedule_on, linkage_instance_id, slots_count
- )
- select staff_id, schedule_on, linkage_instance_id,
- count(1) as slots_count
- from buffer_schedules_1511818252
- where staff_id is not null
- and call_type_id > 0 /* VC */
- group by staff_id, schedule_on, linkage_instance_id
- order by null
- INFO : (02-15 13:32:58) --> fill: 26 - Scheduler::AutoPopulate::Queries::Query085
- (248.8ms) insert into buffer_staff_specializations_1511818252 (
- staff_id, specialization_id
- )
- select staff_id, specialization_id
- from view_staff_specializations
- where client_id = 325
- order by null
- (588.9ms) insert into buffer_specialization_daily_counts_1511818252 (
- specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
- )
- select sp.id as specialization_id,
- null as staff_id,
- bs_1.schedule_on,
- count(distinct st_sp.staff_id) as staffs_scheduled,
- sp.max_scheduled,
- 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
- from (
- select schedule_on, day_of_week_mask
- from buffer_schedules_1511818252
- where should_be_evaluated = 1
- group by schedule_on, day_of_week_mask
- order by null
- ) as bs_1
- inner join specializations as sp
- on sp.client_id = 325
- and sp.active = 1
- inner join buffer_schedules_1511818252 as bs_2
- on bs_1.schedule_on = bs_2.schedule_on
- and bs_2.call_type_id > 0 /* is not VC */
- inner join max_applicable_call_types as mact
- on sp.id = mact.specialization_id
- and bs_2.call_type_id = mact.call_type_id
- left join buffer_staff_specializations_1511818252 as st_sp
- on bs_2.staff_id = st_sp.staff_id
- and sp.id = st_sp.specialization_id
- group by sp.id, bs_1.schedule_on, sp.max_scheduled
- order by null
- (153.2ms) insert into buffer_specialization_daily_counts_1511818252 (
- specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
- )
- select sp.id as specialization_id,
- st_sp.staff_id,
- bs_1.schedule_on,
- 1 as staffs_scheduled,
- sp.max_scheduled,
- 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
- from (
- select schedule_on, day_of_week_mask
- from buffer_schedules_1511818252
- where should_be_evaluated = 1
- group by schedule_on, day_of_week_mask
- order by null
- ) as bs_1
- inner join specializations as sp
- on sp.client_id = 325
- and sp.active = 1
- inner join buffer_schedules_1511818252 as bs_2
- on bs_1.schedule_on = bs_2.schedule_on
- and bs_2.call_type_id > 0 /* is not VC */
- inner join max_applicable_call_types as mact
- on sp.id = mact.specialization_id
- and bs_2.call_type_id = mact.call_type_id
- inner join buffer_staff_specializations_1511818252 as st_sp
- on bs_2.staff_id = st_sp.staff_id
- and sp.id = st_sp.specialization_id
- group by sp.id, st_sp.staff_id, bs_1.schedule_on, sp.max_scheduled
- order by null
- INFO : (02-15 13:32:59) --> fill: 27 - Scheduler::AutoPopulate::Queries::Query09
- (169.2ms) truncate table buffer_location_privileges_1511818252
- (158.3ms) insert into buffer_location_privileges_1511818252 (
- staff_id,
- location_id,
- begin_date,
- end_date
- )
- select
- s.id as staff_id,
- l.location_id,
- '0000-00-00' as begin_date,
- '9999-12-31' as end_date
- from (
- select l.id as location_id
- from
- buffer_schedules_1511818252 as sc
- inner join call_types as ct
- on sc.call_type_id = ct.id
- and ct.active = 1
- inner join locations as l
- on ct.location_id = l.id
- and l.active = 1
- where sc.linkage_instance_id >= 0
- and sc.should_be_evaluated = 1
- group by l.id
- order by null
- ) as l
- inner join staffs as s
- on s.client_id = 325
- and s.active = 1
- and s.take_call = 1
- and s.auto_populatable = 1
- left join location_privileges as lp
- on s.id = lp.staff_id
- where lp.id is null
- union
- select
- lp.staff_id,
- lp.location_id,
- lp.begin_date,
- coalesce(lp.end_date, '9999-12-31') as end_date
- from (
- select l.id as location_id
- from
- buffer_schedules_1511818252 as sc
- inner join call_types as ct
- on sc.call_type_id = ct.id
- and ct.active = 1
- inner join locations as l
- on ct.location_id = l.id
- and l.active = 1
- where sc.linkage_instance_id >= 0
- and sc.should_be_evaluated = 1
- group by l.id
- order by null
- ) as l
- inner join location_privileges as lp
- on l.location_id = lp.location_id
- order by null;
- (444.2ms) insert into buffer_static_availabilities_1511818252 (
- schedule_id,
- staff_id,
- staff_type_id,
- is_primary
- )
- select
- schedules.id as schedule_id,
- staffs.id as staff_id,
- assign_staff_types.staff_type_id,
- 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
- from
- buffer_schedules_1511818252 as schedules
- /* AvailabilityRule */
- inner join call_types
- on schedules.call_type_id = call_types.id
- and call_types.active = 1
- and schedules.day_of_week_mask & call_types.days_of_week_mask > 0
- inner join staff_call_types
- on call_types.id = staff_call_types.call_type_id
- and schedules.day_of_week_mask & (staff_call_types.days_of_week_mask | staff_call_types.secondary_availability_days_of_week_mask) > 0
- inner join staffs
- on staff_call_types.staff_id = staffs.id
- and staffs.active = 1
- and staffs.take_call = 1
- and staffs.auto_populatable = 1
- inner join buffer_location_privileges_1511818252 as location_privileges
- on staffs.id = location_privileges.staff_id
- and call_types.location_id = location_privileges.location_id
- and schedules.schedule_on between location_privileges.begin_date and ifnull(location_privileges.end_date, '9999-12-31')
- inner join assign_staff_types
- on staffs.id = assign_staff_types.staff_id
- and schedules.schedule_on between assign_staff_types.begin_date and ifnull(assign_staff_types.end_date, '9999-12-31')
- left join eligible_staff_types
- on staff_call_types.call_type_id = eligible_staff_types.call_type_id
- and assign_staff_types.staff_type_id = eligible_staff_types.staff_type_id
- left join assign_rotation_schedules force index (ix_assign_rotation_schedules_composite_1)
- on staffs.id = assign_rotation_schedules.staff_id
- and schedules.schedule_on between assign_rotation_schedules.begin_date and assign_rotation_schedules.end_date
- left join staff_rotations force index (ix_staff_rotations_composite_1)
- on staffs.id = staff_rotations.staff_id
- and schedules.schedule_on between staff_rotations.start_date and staff_rotations.end_date
- and assign_rotation_schedules.rotation_schedule_id = staff_rotations.rotation_schedule_id
- left join daily_rotations
- on staffs.id = daily_rotations.staff_id
- and schedules.schedule_on = daily_rotations.schedule_on
- and assign_rotation_schedules.rotation_schedule_id = daily_rotations.rotation_schedule_id
- and staff_rotations.id is not null
- left join rotations
- on coalesce(daily_rotations.rotation_id, staff_rotations.rotation_id) = rotations.id
- and rotations.active = 1
- left join rotation_call_types
- on rotations.id = rotation_call_types.rotation_id
- and staff_call_types.call_type_id = rotation_call_types.call_type_id
- and schedules.day_of_week_mask & (rotation_call_types.days_of_week_mask | rotation_call_types.secondary_availability_days_of_week_mask) > 0
- /* RequiredRotationsRule */
- left join required_rotations
- on staff_call_types.call_type_id = required_rotations.call_type_id
- left join staff_rotations as rr_staff_rotations force index (ix_staff_rotations_composite_3)
- on staffs.id = rr_staff_rotations.staff_id
- and required_rotations.rotation_id = rr_staff_rotations.rotation_id
- left join assign_rotation_schedules as rr_assign_rotation_schedules force index (ix_assign_rotation_schedules_composite_1)
- on staffs.id = rr_assign_rotation_schedules.staff_id
- and rr_staff_rotations.start_date <= rr_assign_rotation_schedules.end_date
- and rr_staff_rotations.end_date >= rr_assign_rotation_schedules.begin_date
- and rr_staff_rotations.rotation_schedule_id = rr_assign_rotation_schedules.rotation_schedule_id
- /* NoCallRequestsHiddenHardRule */
- left join request_settings
- on assign_staff_types.staff_type_id = request_settings.staff_type_id
- left join requests
- on schedules.schedule_on = requests.schedule_on
- and staffs.id = requests.staff_id
- and requests.request_type = 0 /* type = no_call */
- and requests.status in (1, 3) /* status = approved or fulfilled */
- and call_types.is_no_call_requestable = 1
- left join request_call_types
- on requests.id = request_call_types.request_id
- and schedules.call_type_id = request_call_types.call_type_id
- where
- schedules.linkage_instance_id >= 0
- and schedules.should_be_evaluated = 1
- and (
- call_types.all_staff_types = 1
- or eligible_staff_types.id is not null
- )
- and (
- rotations.id is null
- or rotation_call_types.id is not null
- )
- and (
- requests.id is null
- or (
- requests.all_call_types = 1
- and request_settings.call_only_all_call_switch = 1 /* calls only */
- and call_types.assignment_type = 1 /* clinical */
- )
- or (
- requests.all_call_types = 0
- and request_call_types.id is null
- )
- )
- group by
- schedules.id,
- staffs.id,
- assign_staff_types.staff_type_id,
- is_primary
- having
- count(distinct
- case
- when (
- rr_staff_rotations.id is not null
- and rr_assign_rotation_schedules.id is not null
- and schedules.schedule_on >= greatest(rr_staff_rotations.start_date, rr_assign_rotation_schedules.begin_date)
- )
- then rr_staff_rotations.rotation_id
- else null
- end
- ) >= count(distinct required_rotations.rotation_id) /* RequiredRotationsRule */
- and is_primary IN (0,1) /* PrimaryAvailabilityRule */
- order by null
- INFO : (02-15 13:32:59) --> fill: 28 - Scheduler::AutoPopulate::Queries::Query092
- (149.7ms) /* RotationPostCallRule */
- /*
- Exclude cases when people have a rotation starting on the next day after a call we're trying to make,
- if such rotation is configured appropriately ("Post-call on first day" = "Not permitted").
- */
- delete sa
- from buffer_static_availabilities_1511818252 as sa
- inner join buffer_schedules_1511818252 as sc
- on sa.schedule_id = sc.id
- inner join call_types as ct
- on sc.call_type_id = ct.id
- and ct.assignment_type = 0 /* call */
- inner join staff_rotations as sr
- on sa.staff_id = sr.staff_id
- and date_add(sc.schedule_on, interval 1 day) between sr.start_date and sr.end_date
- inner join assign_rotation_schedules as ars
- on sa.staff_id = ars.staff_id
- and date_add(sc.schedule_on, interval 1 day) between ars.begin_date and ars.end_date
- and sr.rotation_schedule_id = ars.rotation_schedule_id
- inner join rotations as r
- on sr.rotation_id = r.id
- and r.post_call_allowed = 0
- left join assign_rotation_schedules as ars_2
- on sa.staff_id = ars_2.staff_id
- and sr.start_date <= ars_2.end_date
- and sr.end_date >= ars_2.begin_date
- and sr.rotation_schedule_id = ars_2.rotation_schedule_id
- -- Earlier intersection
- and ars.begin_date > ars_2.begin_date
- where
- date_add(sc.schedule_on, interval 1 day) = greatest(sr.start_date, ars.begin_date)
- and ars_2.id is null;
- INFO : (02-15 13:33:00) --> fill: 29 - Scheduler::AutoPopulate::Queries::Query093
- INFO : (02-15 13:33:00) --> fill: 30 - Scheduler::AutoPopulate::Queries::Query095
- (542.1ms) insert into buffer_negative_relations_1511818252 (
- schedule_id,
- affected_by_schedule_id,
- staff_id
- )
- select
- b_schedules.id as schedule_id,
- b_schedules_negative_link.id as affected_by_schedule_id,
- b_schedules_negative_link.staff_id
- from
- buffer_schedules_1511818252 as b_schedules
- /* NegativeLinkRule */
- inner join negative_links_influences
- on b_schedules.day_of_week_mask = negative_links_influences.day_of_week_mask
- and b_schedules.call_type_id = negative_links_influences.source_id
- and negative_links_influences.source_type = 'CallType'
- and negative_links_influences.target_type = 'CallType'
- inner join buffer_schedules_1511818252 as b_schedules_negative_link
- on date_add(
- b_schedules.schedule_on,
- interval negative_links_influences.offset day
- ) = b_schedules_negative_link.schedule_on
- and negative_links_influences.target_id = b_schedules_negative_link.call_type_id
- and b_schedules.id != b_schedules_negative_link.id
- where
- b_schedules.linkage_instance_id >= 0
- and b_schedules.should_be_evaluated = 1
- order by null
- (153.4ms) insert into buffer_negative_relations_1511818252 (
- schedule_id,
- affected_by_schedule_id,
- staff_id
- )
- select
- b_schedules.id as schedule_id,
- b_schedules_negative_link.id as affected_by_schedule_id,
- b_schedules_negative_link.staff_id
- from
- buffer_schedules_1511818252 as b_schedules
- /* NegativeLinkRule */
- inner join negative_links_influences
- on b_schedules.day_of_week_mask = negative_links_influences.day_of_week_mask
- and b_schedules.call_type_id = negative_links_influences.source_id
- and negative_links_influences.source_type = 'CallType'
- and negative_links_influences.target_type in ('Vacation', 'NonClinicalType')
- inner join buffer_schedules_1511818252 as b_schedules_negative_link
- on date_add(
- b_schedules.schedule_on,
- interval negative_links_influences.offset day
- ) = b_schedules_negative_link.schedule_on
- and (-1 * negative_links_influences.target_id) = b_schedules_negative_link.call_type_id
- and b_schedules.id != b_schedules_negative_link.id
- where
- b_schedules.linkage_instance_id >= 0
- and b_schedules.should_be_evaluated = 1
- order by null
- (155.3ms) delete from buffer_schedules_1511818252
- where call_type_id < 0 /* vacations and non-clinicals */
- INFO : (02-15 13:33:00) --> fill: 31 - Scheduler::AutoPopulate::Queries::Query097
- (323.3ms) insert into buffer_staff_assigned_days_1511818252 (
- staff_id, period_offset, week_number, schedule_on, is_weekend, is_assigned
- )
- select staffs.staff_id,
- if(days.within_period = 1, days.period_offset, null) as period_offset,
- yearweek(days.schedule_on, if(clients.start_of_week = 0, 2, 7)) as week_number,
- days.schedule_on,
- if(dayofweek(days.schedule_on) in (7, 1), 1, 0) as is_weekend,
- if(schedules.staff_id is not null or vacations.staff_id is not null, 1, 0) as is_assigned
- from (
- select distinct staff_id
- from buffer_static_availabilities_1511818252
- order by null
- ) as staffs
- inner join (
- select p.period_offset,
- 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,
- 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
- from buffer_periods_1511818252 as p
- inner join (
- select 0 as digit union select 1 union select 2 union select 3 union select 4
- union select 5 union select 6 union select 7 union select 8 union select 9
- ) as digits_1
- inner join (
- select 0 as digit union select 1 union select 2 union select 3 union select 4
- union select 5 union select 6 union select 7 union select 8 union select 9
- ) as digits_2
- inner join (
- select 0 as digit union select 1 union select 2 union select 3 union select 4
- union select 5 union select 6 union select 7 union select 8 union select 9
- ) as digits_3
- where p.calendar_schedule_id = 1396
- and p.should_be_evaluated = 1
- and (digits_1.digit * 100 + digits_2.digit * 10 + digits_3.digit) <= datediff(p.end_date, p.start_date) + 12
- order by null
- ) as days
- inner join (
- select min(start_date) as start_date, max(end_date) as end_date
- from buffer_periods_1511818252
- where calendar_schedule_id = 1396
- and should_be_evaluated = 1
- order by null
- ) as limits
- inner join clients
- on clients.id = 325
- left join (
- select sc.staff_id, sc.schedule_on
- from buffer_periods_1511818252 as p
- inner join schedules as sc
- on sc.client_id = 325
- and sc.schedule_on between date_add(p.start_date, interval -6 day) and date_add(p.end_date, interval 6 day)
- inner join call_types as ct
- on sc.call_type_id = ct.id
- and ct.unassigned_day = 0
- where p.calendar_schedule_id = 1396
- and p.should_be_evaluated = 1
- group by sc.staff_id, sc.schedule_on
- order by null
- ) as schedules
- on staffs.staff_id = schedules.staff_id
- and days.schedule_on = schedules.schedule_on
- left join (
- select v.staff_id, v.schedule_on
- from buffer_periods_1511818252 as p
- inner join vacations as v
- on v.client_id = 325
- and v.schedule_on between date_add(p.start_date, interval -6 day) and date_add(p.end_date, interval 6 day)
- and v.status IN (3)
- inner join non_clinical_types as nct
- on v.non_clinical_type_id = nct.id
- and nct.active = 1
- and nct.unassigned_day = 0
- where p.calendar_schedule_id = 1396
- and p.should_be_evaluated = 1
- group by v.staff_id, v.schedule_on
- order by null
- ) as vacations
- on staffs.staff_id = vacations.staff_id
- and days.schedule_on = vacations.schedule_on
- where days.within_period = 1
- or yearweek(days.schedule_on, if(clients.start_of_week = 0, 2, 7)) in (
- yearweek(limits.start_date, if(clients.start_of_week = 0, 2, 7)),
- yearweek(limits.end_date, if(clients.start_of_week = 0, 2, 7))
- )
- order by null
- INFO : (02-15 13:33:01) --> fill: 32 - Scheduler::AutoPopulate::Queries::Query098
- (517.6ms) insert into buffer_combined_availabilities_1511818252 (
- schedule_id, staff_id, staff_type_id, is_primary, linkage_instance_id, has_violations
- )
- select sc.id as schedule_id, sa.staff_id, sa.staff_type_id, sa.is_primary,
- sc.linkage_instance_id, 0 as has_violations
- from buffer_schedules_1511818252 as sc
- /* Static availability */
- inner join buffer_static_availabilities_1511818252 as sa
- on sc.id = sa.schedule_id
- inner join buffer_linkages_1511818252 as l
- on sc.linkage_instance_id = l.linkage_instance_id
- where sc.should_be_evaluated = 1
- and l.has_conflicts = 0
- (153.9ms) insert into buffer_schedule_linkages_1511818252 (
- staff_id, linkage_instance_id, slots_count
- )
- select staff_id, linkage_instance_id, count(1) as slots_count
- from buffer_schedules_1511818252 use index (ix_buffer_schedules_composite_2)
- where staff_id is not null
- and linkage_instance_id >= 0
- group by staff_id, linkage_instance_id
- order by null
- INFO : (02-15 13:33:01) --> fill: 33 - Scheduler::AutoPopulate::Queries::Query09_09_AL
- (146.6ms) insert into buffer_assignment_limits_1511818252 (
- id,
- name,
- calendar_schedule_id,
- considered_days_of_week_mask,
- limit_type,
- limit_subtypes_mask,
- timeframe_type,
- max_per_period_limit,
- max_weekly_limit,
- max_rolling_period,
- max_rolling_limit,
- max_consecutive_limit
- )
- select
- id,
- name,
- calendar_schedule_id,
- considered_days_of_week_mask,
- limit_type,
- (
- (coalesce(max_per_period_limit, -1) >= 0) * 1 +
- (coalesce(max_weekly_limit, -1) >= 0) * 2 +
- (
- coalesce(max_rolling_period, -1) > 0
- and coalesce(max_rolling_limit, -1) >= 0
- ) * 4 +
- (coalesce(max_consecutive_limit, -1) > 0) * 8
- ) as limit_subtypes_mask,
- timeframe_type,
- max_per_period_limit,
- max_weekly_limit,
- max_rolling_period,
- max_rolling_limit,
- max_consecutive_limit
- from assignment_limits
- where
- client_id = 325
- and active = 1
- and (
- max_per_period_limit >= 0
- or max_weekly_limit >= 0
- or (
- max_rolling_period > 0
- and max_rolling_limit >= 0
- )
- or max_consecutive_limit > 0
- )
- order by null
- (150.0ms) select id from buffer_assignment_limits_1511818252 limit 1
- INFO : (02-15 13:33:02) --> fill: 34 - Scheduler::AutoPopulate::Queries::AssignmentLimitApplicability
- (146.0ms) select
- coalesce(bit_or(limit_subtypes_mask), 0)
- from buffer_assignment_limits_1511818252
- INFO : (02-15 13:33:02) --> fill: 35 - Scheduler::AutoPopulate::Queries::Query09_09_AL_01
- INFO : (02-15 13:33:02) --> fill: 36 - Scheduler::AutoPopulate::Queries::Query09_09_AL_02
- INFO : (02-15 13:33:02) --> fill: 37 - Scheduler::AutoPopulate::Queries::Query09_09_AL_03
- INFO : (02-15 13:33:02) --> fill: 38 - Scheduler::AutoPopulate::Queries::Query09_09_AL_04
- INFO : (02-15 13:33:02) --> fill: 39 - Scheduler::AutoPopulate::Queries::Query09_09_AL_05
- INFO : (02-15 13:33:02) --> fill: 40 - Scheduler::AutoPopulate::Queries::Query09_09_AL_06
- INFO : (02-15 13:33:02) --> fill: 41 - Scheduler::AutoPopulate::Queries::Query09_12_Points
- INFO : (02-15 13:33:02) --> fill: 42 - Scheduler::AutoPopulate::Queries::Query09_12_Hours
- INFO : (02-15 13:33:02) --> fill: 43 - Scheduler::AutoPopulate::Queries::Query10
- (151.8ms) select
- coalesce(max(
- case
- when (ct.max_weekday_assignments > 0) then 1
- else 0
- end
- ), 0) as weekday_flag,
- coalesce(max(
- case
- when (ct.max_weekend_assignments > 0) then 1
- else 0
- end
- ), 0) as weekend_flag
- from
- buffer_auto_populate_slots_1511818252 as aps
- inner join call_types as ct
- on aps.call_type_id = ct.id
- (151.3ms) /* NegativeLinkRule */
- delete ca
- from buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_negative_relations_1511818252 as nr use index (ix_buffer_negative_relations_composite_1)
- on ca.schedule_id = nr.schedule_id
- and ca.staff_id = nr.staff_id
- (465.8ms) /* SpecializationOverlapRule */
- delete ca
- from buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_staff_specializations_1511818252 as ssp
- on ca.staff_id = ssp.staff_id
- inner join max_applicable_call_types as mact
- on ssp.specialization_id = mact.specialization_id
- and sc.call_type_id = mact.call_type_id
- inner join buffer_specialization_daily_counts_1511818252 as sdc use index (ix_buffer_specialization_daily_counts_composite_1)
- on ssp.specialization_id = sdc.specialization_id
- and sc.schedule_on = sdc.schedule_on
- and sdc.staff_id is null
- left join buffer_specialization_daily_counts_1511818252 as sdc_2 use index (ix_buffer_specialization_daily_counts_composite_1)
- on ssp.specialization_id = sdc_2.specialization_id
- and sc.schedule_on = sdc_2.schedule_on
- and ca.staff_id = sdc_2.staff_id
- where sdc.should_be_evaluated = 1
- and (sdc.staffs_scheduled + if(sdc_2.id is null, 1, 0)) > sdc.max_scheduled
- (152.6ms) /* BrokenLinkageRule */
- truncate table buffer_combined_availability_linkages_1511818252
- (154.7ms) insert into buffer_combined_availability_linkages_1511818252 (
- staff_id,
- linkage_instance_id,
- slots_count,
- is_primary,
- has_violations
- )
- select
- staff_id,
- linkage_instance_id,
- count(1) as slots_count,
- min(is_primary) as is_primary,
- max(has_violations) as has_violations
- from buffer_combined_availabilities_1511818252 use index (ix_buffer_combined_availabilities_composite_2)
- group by
- staff_id,
- linkage_instance_id
- order by null
- (153.0ms) delete ca
- from
- buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_linkages_1511818252 as l
- on sc.linkage_instance_id = l.linkage_instance_id
- inner join buffer_combined_availability_linkages_1511818252 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
- on ca.staff_id = ls_1.staff_id
- and sc.linkage_instance_id = ls_1.linkage_instance_id
- left join buffer_schedule_linkages_1511818252 as ls_2 use index (ix_buffer_schedule_linkages_composite_1)
- on ca.staff_id = ls_2.staff_id
- and sc.linkage_instance_id = ls_2.linkage_instance_id
- where (ls_1.slots_count + coalesce(ls_2.slots_count, 0)) < l.slots_count_total /* not covering the whole chain */;
- INFO : (02-15 13:33:03) --> fill: 44 - Scheduler::AutoPopulate::Queries::QueryScore02
- INFO : (02-15 13:33:03) --> fill: 45 - Scheduler::AutoPopulate::Queries::QueryScore03
- INFO : (02-15 13:33:03) --> fill: 46 - Scheduler::AutoPopulate::Queries::QueryScore04
- INFO : (02-15 13:33:03) --> fill: 47 - Scheduler::AutoPopulate::Queries::Query11
- (149.5ms) update buffer_schedules_1511818252 as sc
- left join buffer_combined_availabilities_1511818252 as ca
- on sc.id = ca.schedule_id
- set sc.should_be_evaluated = 0,
- sc.should_be_populated = 0
- where sc.should_be_evaluated = 1
- and ca.id is null
- INFO : (02-15 13:33:03) --> fill: 48 - Scheduler::AutoPopulate::Queries::DropTables
- INFO : (02-15 13:33:03) Setting up lists...
- (303.0ms) select b_schedules.schedule_on, b_schedules.call_type_id, b_schedules.linkage_instance_id, schedules.id as schedule_id
- from buffer_schedules_1511818252 as b_schedules
- left join schedules
- on schedules.client_id = 325
- and schedules.call_type_id = b_schedules.call_type_id
- and schedules.schedule_on = b_schedules.schedule_on
- where b_schedules.linkage_instance_id != -1
- order by b_schedules.linkage_instance_id, b_schedules.schedule_on
- INFO : (02-15 13:33:04) Begin to populate. Pre-set: 0. Unscheduled: 84.
- INFO : (02-15 13:33:04) plan unit: [id:201930] [2019-08-03 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:201931] [2019-08-10 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:201932] [2019-08-17 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:201933] [2019-08-24 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:201934] [2019-08-31 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:1201930] [2019-08-03 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:1201931] [2019-08-10 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:1201932] [2019-08-17 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:1201933] [2019-08-24 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:1201934] [2019-08-31 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:2201931] [2019-08-04 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:2201932] [2019-08-11 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:2201933] [2019-08-18 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:2201934] [2019-08-25 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:3201931] [2019-08-04 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:3201932] [2019-08-11 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:3201933] [2019-08-18 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:3201934] [2019-08-25 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:4201931] [2019-08-05 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:4201932] [2019-08-12 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:4201933] [2019-08-19 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:4201934] [2019-08-26 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:5201931] [2019-08-05 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:5201932] [2019-08-12 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:5201933] [2019-08-19 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:5201934] [2019-08-26 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:6201931] [2019-08-05 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:6201932] [2019-08-12 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:6201933] [2019-08-19 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:6201934] [2019-08-26 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:7201931] [2019-08-06 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:7201932] [2019-08-13 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:7201933] [2019-08-20 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:7201934] [2019-08-27 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:8201931] [2019-08-06 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:8201932] [2019-08-13 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:8201933] [2019-08-20 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:8201934] [2019-08-27 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:9201931] [2019-08-06 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:9201932] [2019-08-13 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:9201933] [2019-08-20 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:9201934] [2019-08-27 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:10201931] [2019-08-07 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:10201932] [2019-08-14 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:10201933] [2019-08-21 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:10201934] [2019-08-28 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:11201931] [2019-08-07 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:11201932] [2019-08-14 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:11201933] [2019-08-21 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:11201934] [2019-08-28 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:12201931] [2019-08-07 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:12201932] [2019-08-14 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:12201933] [2019-08-21 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:12201934] [2019-08-28 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:13201930] [2019-08-01 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:13201931] [2019-08-08 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:13201932] [2019-08-15 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:13201933] [2019-08-22 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:13201934] [2019-08-29 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:14201930] [2019-08-01 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:14201931] [2019-08-08 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:14201932] [2019-08-15 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:14201933] [2019-08-22 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:14201934] [2019-08-29 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:15201930] [2019-08-01 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:15201931] [2019-08-08 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:15201932] [2019-08-15 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:15201933] [2019-08-22 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:15201934] [2019-08-29 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:16201930] [2019-08-02 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:16201931] [2019-08-09 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:16201932] [2019-08-16 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:16201933] [2019-08-23 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:16201934] [2019-08-30 - OR]
- INFO : (02-15 13:33:04) plan unit: [id:17201930] [2019-08-02 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:17201931] [2019-08-09 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:17201932] [2019-08-16 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:17201933] [2019-08-23 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:17201934] [2019-08-30 - OB]
- INFO : (02-15 13:33:04) plan unit: [id:18201930] [2019-08-02 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:18201931] [2019-08-09 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:18201932] [2019-08-16 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:18201933] [2019-08-23 - SSGE]
- INFO : (02-15 13:33:04) plan unit: [id:18201934] [2019-08-30 - SSGE]
- (152.2ms) select
- coalesce(max(
- case
- when (ct.max_weekday_assignments > 0) then 1
- else 0
- end
- ), 0) as weekday_flag,
- coalesce(max(
- case
- when (ct.max_weekend_assignments > 0) then 1
- else 0
- end
- ), 0) as weekend_flag
- from
- buffer_auto_populate_slots_1511818252 as aps
- inner join call_types as ct
- on aps.call_type_id = ct.id
- (508.6ms) /* NegativeLinkRule */
- delete ca
- from buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_negative_relations_1511818252 as nr use index (ix_buffer_negative_relations_composite_1)
- on ca.schedule_id = nr.schedule_id
- and ca.staff_id = nr.staff_id
- (141.9ms) /* SpecializationOverlapRule */
- delete ca
- from buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_staff_specializations_1511818252 as ssp
- on ca.staff_id = ssp.staff_id
- inner join max_applicable_call_types as mact
- on ssp.specialization_id = mact.specialization_id
- and sc.call_type_id = mact.call_type_id
- inner join buffer_specialization_daily_counts_1511818252 as sdc use index (ix_buffer_specialization_daily_counts_composite_1)
- on ssp.specialization_id = sdc.specialization_id
- and sc.schedule_on = sdc.schedule_on
- and sdc.staff_id is null
- left join buffer_specialization_daily_counts_1511818252 as sdc_2 use index (ix_buffer_specialization_daily_counts_composite_1)
- on ssp.specialization_id = sdc_2.specialization_id
- and sc.schedule_on = sdc_2.schedule_on
- and ca.staff_id = sdc_2.staff_id
- where sdc.should_be_evaluated = 1
- and (sdc.staffs_scheduled + if(sdc_2.id is null, 1, 0)) > sdc.max_scheduled
- (148.2ms) /* BrokenLinkageRule */
- truncate table buffer_combined_availability_linkages_1511818252
- (146.0ms) insert into buffer_combined_availability_linkages_1511818252 (
- staff_id,
- linkage_instance_id,
- slots_count,
- is_primary,
- has_violations
- )
- select
- staff_id,
- linkage_instance_id,
- count(1) as slots_count,
- min(is_primary) as is_primary,
- max(has_violations) as has_violations
- from buffer_combined_availabilities_1511818252 use index (ix_buffer_combined_availabilities_composite_2)
- group by
- staff_id,
- linkage_instance_id
- order by null
- (158.2ms) delete ca
- from
- buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_linkages_1511818252 as l
- on sc.linkage_instance_id = l.linkage_instance_id
- inner join buffer_combined_availability_linkages_1511818252 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
- on ca.staff_id = ls_1.staff_id
- and sc.linkage_instance_id = ls_1.linkage_instance_id
- left join buffer_schedule_linkages_1511818252 as ls_2 use index (ix_buffer_schedule_linkages_composite_1)
- on ca.staff_id = ls_2.staff_id
- and sc.linkage_instance_id = ls_2.linkage_instance_id
- where (ls_1.slots_count + coalesce(ls_2.slots_count, 0)) < l.slots_count_total /* not covering the whole chain */;
- (162.1ms) select straight_join
- sc.schedule_on,
- sc.call_type_id,
- count(distinct ca.staff_id) as available_members_count,
- group_concat(
- distinct concat(if(ls_1.is_primary = 1, 'p', 's'), ca.staff_id)
- order by ls_1.is_primary desc, ca.staff_id
- separator ', '
- ) as available_members_ids,
- sc.linkage_instance_id,
- l.slots_count_total as linkage_slots_count
- from buffer_combined_availabilities_1511818252 as ca
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_linkages_1511818252 as l
- on sc.linkage_instance_id = l.linkage_instance_id
- inner join buffer_combined_availability_linkages_1511818252 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
- on ca.staff_id = ls_1.staff_id
- and sc.linkage_instance_id = ls_1.linkage_instance_id
- and ls_1.has_violations = 0
- where sc.should_be_evaluated = 1
- and sc.should_be_populated = 1
- group by sc.schedule_on, sc.call_type_id, sc.linkage_instance_id, l.slots_count_total
- order by available_members_count, sc.schedule_on, sc.display_order
- limit 1
- (148.5ms) truncate table buffer_rule_scores_1511818252
- (143.1ms) truncate table buffer_rule_calc_filters_1511818252
- (528.0ms) insert into buffer_rule_calc_filters_1511818252 (
- linkage_instance_id,
- staff_id
- ) values (15201930, 20739)
- (144.5ms) truncate table buffer_rule_scores_with_corrections_1511818252
- (141.8ms) insert into buffer_rule_scores_with_corrections_1511818252 (
- linkage_instance_id, schedule_id, staff_id, rule_name, value
- )
- select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id, rule_scores.rule_name,
- ifnull(rule_scores.value, max_values.max_value + 1) as value
- from buffer_rule_scores_1511818252 as rule_scores
- inner join (
- select rule_name, max(value) as max_value
- from buffer_rule_scores_1511818252
- group by rule_name
- order by null
- ) as max_values
- on rule_scores.rule_name = max_values.rule_name
- order by null
- (178.2ms) select linkage_instance_id, staff_id, avg(slot_scores) as scores
- from (
- select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id,
- sum(
- if((total_values.total_value > 0), (rule_scores.value / total_values.total_value), 0) *
- rules.weight *
- total_values.slots_count
- ) as slot_scores
- from buffer_rule_scores_with_corrections_1511818252 as rule_scores
- inner join (
- select rule_name, sum(abs(value)) as total_value,
- count(distinct schedule_id) as slots_count
- from buffer_rule_scores_with_corrections_1511818252
- group by rule_name
- order by null
- ) as total_values
- on rule_scores.rule_name = total_values.rule_name
- inner join rules
- on rule_scores.rule_name = rules.type
- where rules.rule_set_id = 1538
- and rules.applied = 1
- group by rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id
- order by null
- ) as staff_scores
- group by linkage_instance_id, staff_id
- order by round(avg(slot_scores), 5) desc, rand()
- limit 1
- WARN : (02-15 13:33:06) No score found. Using fake score...
- PublishedBlock Load (143.2ms) SELECT `published_blocks`.* FROM `published_blocks` INNER JOIN `blocks` ON `blocks`.`id` = `published_blocks`.`block_id` WHERE `published_blocks`.`client_id` = 325 AND ('2019-08-01' BETWEEN blocks.start_date AND blocks.end_date) AND `published_blocks`.`calendar_schedule_id` = 1396 ORDER BY `published_blocks`.`id` ASC LIMIT 1
- (150.9ms) BEGIN
- (153.9ms) SELECT COALESCE(pb.updated_at, pbct.updated_at)
- FROM call_types AS ct
- INNER JOIN calendar_schedules AS cs
- ON ct.calendar_schedule_id = cs.id
- INNER JOIN blocks AS b
- ON b.client_id = ct.client_id
- AND b.block_schedule_id = cs.block_schedule_id
- AND '2019-08-01' BETWEEN b.start_date AND b.end_date
- INNER JOIN published_blocks AS pb
- ON pb.client_id = ct.client_id
- AND pb.block_id = b.id
- AND pb.calendar_schedule_id = cs.id
- LEFT JOIN published_block_call_types AS pbct
- ON pbct.client_id = ct.client_id
- AND pbct.assignment_id = ct.id
- AND pbct.assignment_type = 'CallType'
- AND pbct.block_id = b.id
- AND (
- (1 << (DAYOFWEEK('2019-08-01') - 1) & pbct.days_of_week_mask) > 0
- )
- WHERE ct.id = 12734
- AND (
- (
- pb.assignment_ids IS NULL
- AND (1 << (DAYOFWEEK('2019-08-01') - 1) & pb.days_of_week_mask) > 0
- )
- OR pbct.id IS NOT NULL
- )
- CallType Load (586.8ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 12734 LIMIT 1
- Client Load (437.5ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 325 LIMIT 1
- Staff Load (150.0ms) SELECT `staffs`.* FROM `staffs` WHERE `staffs`.`id` = 20739 LIMIT 1
- Schedule Exists (142.4ms) SELECT 1 AS one FROM `schedules` WHERE `schedules`.`call_type_id` = 12734 AND `schedules`.`client_id` = 325 AND `schedules`.`schedule_on` = '2019-08-01' LIMIT 1
- SQL (163.1ms) INSERT INTO `schedules` (`client_id`, `call_type_id`, `staff_id`, `schedule_on`, `created_at`, `updated_at`, `weekend_on`, `dayofweek_on`, `populate_method`, `creator_id`) VALUES (325, 12734, 20739, '2019-08-01', '2019-02-15 13:33:36', '2019-02-15 13:33:36', 0, 5, 'auto_populate_step', 20695)
- VisibleAssignment Load (149.0ms) SELECT `visible_assignments`.* FROM `visible_assignments` WHERE `visible_assignments`.`client_id` = 325 AND `visible_assignments`.`date` = '2019-08-01' AND `visible_assignments`.`assignment_type` = 'CallType' AND `visible_assignments`.`assignment_id` = 12734 ORDER BY `visible_assignments`.`id` ASC LIMIT 1
- (144.9ms) COMMIT
- FLUSHED: nil:nil
- (145.3ms) UPDATE buffer_schedules_1511818252
- SET staff_id = 20739,
- should_be_populated = 0,
- should_be_evaluated = 0
- WHERE
- call_type_id = 12734
- AND schedule_on = '2019-08-01'
- (143.6ms) delete from buffer_combined_availabilities_1511818252
- where linkage_instance_id = 15201930
- (156.5ms) UPDATE buffer_rule_calc_schedules_1511818252
- SET staff_id = 20739
- WHERE call_type_id = 12734
- AND schedule_on = '2019-08-01'
- (143.0ms) INSERT INTO buffer_rule_calc_schedules_1511818252
- SET staff_id = 20739,
- call_type_id = 12734,
- schedule_on = '2019-08-01',
- day_of_week_mask = 16
- (147.8ms) /* NegativeLinkRule */
- UPDATE buffer_negative_relations_1511818252
- SET staff_id = 20739
- WHERE affected_by_schedule_id = (
- SELECT id
- FROM buffer_schedules_1511818252
- WHERE schedule_on = '2019-08-01'
- AND call_type_id = 12734
- )
- (149.4ms) /* SpecializationOverlapRule */
- update buffer_staff_specializations_1511818252 as st_sp
- inner join max_applicable_call_types as mact
- on st_sp.specialization_id = mact.specialization_id
- and mact.call_type_id = 12734
- inner join buffer_specialization_daily_counts_1511818252 as sp_dc
- on st_sp.specialization_id = sp_dc.specialization_id
- and sp_dc.staff_id is null
- and sp_dc.schedule_on = '2019-08-01'
- left join buffer_specialization_daily_counts_1511818252 as sp_dc_2
- on st_sp.specialization_id = sp_dc_2.specialization_id
- and st_sp.staff_id = sp_dc_2.staff_id
- and sp_dc_2.schedule_on = '2019-08-01'
- set sp_dc.staffs_scheduled = sp_dc.staffs_scheduled + 1
- where st_sp.staff_id = 20739
- and sp_dc_2.id is null
- (143.3ms) insert into buffer_specialization_daily_counts_1511818252 (
- specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
- )
- select sp.id as specialization_id,
- 20739 as staff_id,
- '2019-08-01' as schedule_on,
- 1 as staffs_scheduled,
- sp.max_scheduled,
- sp_dc.should_be_evaluated
- from buffer_staff_specializations_1511818252 as st_sp
- inner join specializations as sp
- on st_sp.specialization_id = sp.id
- inner join max_applicable_call_types as mact
- on st_sp.specialization_id = mact.specialization_id
- and mact.call_type_id = 12734
- inner join buffer_specialization_daily_counts_1511818252 as sp_dc
- on st_sp.specialization_id = sp_dc.specialization_id
- and sp_dc.staff_id is null
- and sp_dc.schedule_on = '2019-08-01'
- left join buffer_specialization_daily_counts_1511818252 as sp_dc_2
- on st_sp.specialization_id = sp_dc_2.specialization_id
- and st_sp.staff_id = sp_dc_2.staff_id
- and sp_dc_2.schedule_on = '2019-08-01'
- where st_sp.staff_id = 20739
- and sp_dc_2.id is null
- (145.7ms) /* MaxAssignmentsRule */
- delete from buffer_linkage_call_type_assignments_1511818252
- where linkage_instance_id = 15201930;
- (507.1ms) /* MaxAssignmentsRule */
- update
- buffer_schedules_1511818252 as sc
- inner join call_types as ct
- on sc.call_type_id = ct.id
- and ct.active = 1
- inner join buffer_call_type_assignments_1511818252 as cta
- on sc.staff_id = cta.staff_id
- and sc.call_type_id = cta.call_type_id
- and sc.is_weekend = cta.is_weekend
- and sc.period_offset = cta.period_offset
- and sc.calendar_schedule_id = cta.calendar_schedule_id
- set cta.assignments_count = cta.assignments_count + 1
- where
- sc.schedule_on = '2019-08-01'
- and sc.call_type_id = 12734
- and sc.staff_id = 20739
- (528.2ms) insert into buffer_call_type_assignments_1511818252 (
- staff_id,
- call_type_id,
- is_weekend,
- period_offset,
- calendar_schedule_id,
- assignments_count
- )
- select
- sc.staff_id,
- sc.call_type_id,
- sc.is_weekend,
- sc.period_offset,
- sc.calendar_schedule_id,
- 1 as assignments_count
- from buffer_schedules_1511818252 as sc
- where
- sc.staff_id = 20739
- and sc.schedule_on = '2019-08-01'
- and sc.call_type_id = 12734
- (151.3ms) /* UnassignedDaysRule */
- delete from buffer_linkage_assigned_days_1511818252
- where linkage_instance_id = 15201930
- (142.4ms) /* UnassignedDaysRule */
- UPDATE buffer_staff_assigned_days_1511818252 as sad
- inner join call_types as ct
- on ct.id = 12734
- and ct.unassigned_day = 0
- SET sad.is_assigned = 1
- WHERE sad.staff_id = 20739
- AND sad.schedule_on = '2019-08-01'
- (147.8ms) delete
- from buffer_linkage_assignment_limits_1511818252
- where
- staff_id = 20739
- and linkage_instance_id = 15201930
- (154.2ms) insert into buffer_staff_assignment_limits_1511818252 (
- staff_id,
- assignment_limit_id,
- period_id,
- consecutive_days_mask,
- current_value
- )
- select
- sc.staff_id,
- al.id as assignment_limit_id,
- alp.id as period_id,
- case
- when (alp.limit_subtype_mask = 8 /* consecutive */) then
- (1 << datediff(sc.schedule_on, alp.start_date))
- else 0
- end as consecutive_days_mask,
- case
- when (al.limit_type = 0 /* assignments */) then 1.0
- when (al.limit_type = 1 /* points */) then ci.points
- when (al.limit_type = 2 /* hours */) then ci.hours
- else 0
- end as current_value
- from
- buffer_schedules_1511818252 as sc
- inner join buffer_assignment_limit_call_types_1511818252 as alct
- on sc.call_type_id = alct.call_type_id
- inner join buffer_assignment_limits_1511818252 as al
- on alct.assignment_limit_id = al.id
- and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
- inner join buffer_assignment_limit_staffs_1511818252 as als
- on al.id = als.assignment_limit_id
- and sc.staff_id = als.staff_id
- inner join assign_staff_types as ast
- on sc.staff_id = ast.staff_id
- and sc.schedule_on between ast.begin_date and coalesce(ast.end_date, '9999-12-31')
- inner join buffer_assignment_limit_staff_types_1511818252 as alst
- on al.id = alst.assignment_limit_id
- and ast.staff_type_id = alst.staff_type_id
- inner join buffer_assignment_limit_periods_1511818252 as alp
- on al.id = alp.assignment_limit_id
- and sc.schedule_on between alp.start_date and alp.end_date
- inner join buffer_counter_increments_1511818252 as ci
- on sc.id = ci.schedule_id
- where
- sc.schedule_on = '2019-08-01'
- and sc.call_type_id = 12734
- and sc.staff_id = 20739
- on duplicate key update
- consecutive_days_mask = consecutive_days_mask | values(consecutive_days_mask),
- current_value = current_value + values(current_value)
- INFO : (02-15 13:33:40) scheduled for: plan unit: [id:15201930] [2019-08-01 - SSGE], Ron Dobrovinsky. DEPTH(1)
- (150.8ms) select
- coalesce(max(
- case
- when (ct.max_weekday_assignments > 0) then 1
- else 0
- end
- ), 0) as weekday_flag,
- coalesce(max(
- case
- when (ct.max_weekend_assignments > 0) then 1
- else 0
- end
- ), 0) as weekend_flag
- from
- buffer_auto_populate_slots_1511818252 as aps
- inner join call_types as ct
- on aps.call_type_id = ct.id
- (145.8ms) /* NegativeLinkRule */
- delete ca
- from buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_negative_relations_1511818252 as nr use index (ix_buffer_negative_relations_composite_1)
- on ca.schedule_id = nr.schedule_id
- and ca.staff_id = nr.staff_id
- (449.1ms) /* SpecializationOverlapRule */
- delete ca
- from buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_staff_specializations_1511818252 as ssp
- on ca.staff_id = ssp.staff_id
- inner join max_applicable_call_types as mact
- on ssp.specialization_id = mact.specialization_id
- and sc.call_type_id = mact.call_type_id
- inner join buffer_specialization_daily_counts_1511818252 as sdc use index (ix_buffer_specialization_daily_counts_composite_1)
- on ssp.specialization_id = sdc.specialization_id
- and sc.schedule_on = sdc.schedule_on
- and sdc.staff_id is null
- left join buffer_specialization_daily_counts_1511818252 as sdc_2 use index (ix_buffer_specialization_daily_counts_composite_1)
- on ssp.specialization_id = sdc_2.specialization_id
- and sc.schedule_on = sdc_2.schedule_on
- and ca.staff_id = sdc_2.staff_id
- where sdc.should_be_evaluated = 1
- and (sdc.staffs_scheduled + if(sdc_2.id is null, 1, 0)) > sdc.max_scheduled
- (150.3ms) /* BrokenLinkageRule */
- truncate table buffer_combined_availability_linkages_1511818252
- (153.9ms) insert into buffer_combined_availability_linkages_1511818252 (
- staff_id,
- linkage_instance_id,
- slots_count,
- is_primary,
- has_violations
- )
- select
- staff_id,
- linkage_instance_id,
- count(1) as slots_count,
- min(is_primary) as is_primary,
- max(has_violations) as has_violations
- from buffer_combined_availabilities_1511818252 use index (ix_buffer_combined_availabilities_composite_2)
- group by
- staff_id,
- linkage_instance_id
- order by null
- (153.2ms) delete ca
- from
- buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_linkages_1511818252 as l
- on sc.linkage_instance_id = l.linkage_instance_id
- inner join buffer_combined_availability_linkages_1511818252 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
- on ca.staff_id = ls_1.staff_id
- and sc.linkage_instance_id = ls_1.linkage_instance_id
- left join buffer_schedule_linkages_1511818252 as ls_2 use index (ix_buffer_schedule_linkages_composite_1)
- on ca.staff_id = ls_2.staff_id
- and sc.linkage_instance_id = ls_2.linkage_instance_id
- where (ls_1.slots_count + coalesce(ls_2.slots_count, 0)) < l.slots_count_total /* not covering the whole chain */;
- (161.4ms) select straight_join
- sc.schedule_on,
- sc.call_type_id,
- count(distinct ca.staff_id) as available_members_count,
- group_concat(
- distinct concat(if(ls_1.is_primary = 1, 'p', 's'), ca.staff_id)
- order by ls_1.is_primary desc, ca.staff_id
- separator ', '
- ) as available_members_ids,
- sc.linkage_instance_id,
- l.slots_count_total as linkage_slots_count
- from buffer_combined_availabilities_1511818252 as ca
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_linkages_1511818252 as l
- on sc.linkage_instance_id = l.linkage_instance_id
- inner join buffer_combined_availability_linkages_1511818252 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
- on ca.staff_id = ls_1.staff_id
- and sc.linkage_instance_id = ls_1.linkage_instance_id
- and ls_1.has_violations = 0
- where sc.should_be_evaluated = 1
- and sc.should_be_populated = 1
- group by sc.schedule_on, sc.call_type_id, sc.linkage_instance_id, l.slots_count_total
- order by available_members_count, sc.schedule_on, sc.display_order
- limit 1
- (149.0ms) truncate table buffer_rule_scores_1511818252
- (141.0ms) truncate table buffer_rule_calc_filters_1511818252
- (541.2ms) insert into buffer_rule_calc_filters_1511818252 (
- linkage_instance_id,
- staff_id
- ) values (18201930, 20739)
- (152.7ms) truncate table buffer_rule_scores_with_corrections_1511818252
- (147.2ms) insert into buffer_rule_scores_with_corrections_1511818252 (
- linkage_instance_id, schedule_id, staff_id, rule_name, value
- )
- select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id, rule_scores.rule_name,
- ifnull(rule_scores.value, max_values.max_value + 1) as value
- from buffer_rule_scores_1511818252 as rule_scores
- inner join (
- select rule_name, max(value) as max_value
- from buffer_rule_scores_1511818252
- group by rule_name
- order by null
- ) as max_values
- on rule_scores.rule_name = max_values.rule_name
- order by null
- (162.9ms) select linkage_instance_id, staff_id, avg(slot_scores) as scores
- from (
- select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id,
- sum(
- if((total_values.total_value > 0), (rule_scores.value / total_values.total_value), 0) *
- rules.weight *
- total_values.slots_count
- ) as slot_scores
- from buffer_rule_scores_with_corrections_1511818252 as rule_scores
- inner join (
- select rule_name, sum(abs(value)) as total_value,
- count(distinct schedule_id) as slots_count
- from buffer_rule_scores_with_corrections_1511818252
- group by rule_name
- order by null
- ) as total_values
- on rule_scores.rule_name = total_values.rule_name
- inner join rules
- on rule_scores.rule_name = rules.type
- where rules.rule_set_id = 1538
- and rules.applied = 1
- group by rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id
- order by null
- ) as staff_scores
- group by linkage_instance_id, staff_id
- order by round(avg(slot_scores), 5) desc, rand()
- limit 1
- WARN : (02-15 13:33:43) No score found. Using fake score...
- PublishedBlock Load (149.9ms) SELECT `published_blocks`.* FROM `published_blocks` INNER JOIN `blocks` ON `blocks`.`id` = `published_blocks`.`block_id` WHERE `published_blocks`.`client_id` = 325 AND ('2019-08-02' BETWEEN blocks.start_date AND blocks.end_date) AND `published_blocks`.`calendar_schedule_id` = 1396 ORDER BY `published_blocks`.`id` ASC LIMIT 1
- (149.6ms) BEGIN
- (152.5ms) SELECT COALESCE(pb.updated_at, pbct.updated_at)
- FROM call_types AS ct
- INNER JOIN calendar_schedules AS cs
- ON ct.calendar_schedule_id = cs.id
- INNER JOIN blocks AS b
- ON b.client_id = ct.client_id
- AND b.block_schedule_id = cs.block_schedule_id
- AND '2019-08-02' BETWEEN b.start_date AND b.end_date
- INNER JOIN published_blocks AS pb
- ON pb.client_id = ct.client_id
- AND pb.block_id = b.id
- AND pb.calendar_schedule_id = cs.id
- LEFT JOIN published_block_call_types AS pbct
- ON pbct.client_id = ct.client_id
- AND pbct.assignment_id = ct.id
- AND pbct.assignment_type = 'CallType'
- AND pbct.block_id = b.id
- AND (
- (1 << (DAYOFWEEK('2019-08-02') - 1) & pbct.days_of_week_mask) > 0
- )
- WHERE ct.id = 12734
- AND (
- (
- pb.assignment_ids IS NULL
- AND (1 << (DAYOFWEEK('2019-08-02') - 1) & pb.days_of_week_mask) > 0
- )
- OR pbct.id IS NOT NULL
- )
- CallType Load (285.4ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 12734 LIMIT 1
- Client Load (739.1ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 325 LIMIT 1
- Staff Load (146.7ms) SELECT `staffs`.* FROM `staffs` WHERE `staffs`.`id` = 20739 LIMIT 1
- Schedule Exists (151.6ms) SELECT 1 AS one FROM `schedules` WHERE `schedules`.`call_type_id` = 12734 AND `schedules`.`client_id` = 325 AND `schedules`.`schedule_on` = '2019-08-02' LIMIT 1
- SQL (151.9ms) INSERT INTO `schedules` (`client_id`, `call_type_id`, `staff_id`, `schedule_on`, `created_at`, `updated_at`, `weekend_on`, `dayofweek_on`, `populate_method`, `creator_id`) VALUES (325, 12734, 20739, '2019-08-02', '2019-02-15 13:33:46', '2019-02-15 13:33:46', 0, 6, 'auto_populate_step', 20695)
- VisibleAssignment Load (524.9ms) SELECT `visible_assignments`.* FROM `visible_assignments` WHERE `visible_assignments`.`client_id` = 325 AND `visible_assignments`.`date` = '2019-08-02' AND `visible_assignments`.`assignment_type` = 'CallType' AND `visible_assignments`.`assignment_id` = 12734 ORDER BY `visible_assignments`.`id` ASC LIMIT 1
- (169.9ms) COMMIT
- FLUSHED: nil:nil
- (154.0ms) UPDATE buffer_schedules_1511818252
- SET staff_id = 20739,
- should_be_populated = 0,
- should_be_evaluated = 0
- WHERE
- call_type_id = 12734
- AND schedule_on = '2019-08-02'
- (150.0ms) delete from buffer_combined_availabilities_1511818252
- where linkage_instance_id = 18201930
- (510.0ms) UPDATE buffer_rule_calc_schedules_1511818252
- SET staff_id = 20739
- WHERE call_type_id = 12734
- AND schedule_on = '2019-08-02'
- (481.5ms) INSERT INTO buffer_rule_calc_schedules_1511818252
- SET staff_id = 20739,
- call_type_id = 12734,
- schedule_on = '2019-08-02',
- day_of_week_mask = 32
- (160.6ms) /* NegativeLinkRule */
- UPDATE buffer_negative_relations_1511818252
- SET staff_id = 20739
- WHERE affected_by_schedule_id = (
- SELECT id
- FROM buffer_schedules_1511818252
- WHERE schedule_on = '2019-08-02'
- AND call_type_id = 12734
- )
- (143.2ms) /* SpecializationOverlapRule */
- update buffer_staff_specializations_1511818252 as st_sp
- inner join max_applicable_call_types as mact
- on st_sp.specialization_id = mact.specialization_id
- and mact.call_type_id = 12734
- inner join buffer_specialization_daily_counts_1511818252 as sp_dc
- on st_sp.specialization_id = sp_dc.specialization_id
- and sp_dc.staff_id is null
- and sp_dc.schedule_on = '2019-08-02'
- left join buffer_specialization_daily_counts_1511818252 as sp_dc_2
- on st_sp.specialization_id = sp_dc_2.specialization_id
- and st_sp.staff_id = sp_dc_2.staff_id
- and sp_dc_2.schedule_on = '2019-08-02'
- set sp_dc.staffs_scheduled = sp_dc.staffs_scheduled + 1
- where st_sp.staff_id = 20739
- and sp_dc_2.id is null
- (296.8ms) insert into buffer_specialization_daily_counts_1511818252 (
- specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
- )
- select sp.id as specialization_id,
- 20739 as staff_id,
- '2019-08-02' as schedule_on,
- 1 as staffs_scheduled,
- sp.max_scheduled,
- sp_dc.should_be_evaluated
- from buffer_staff_specializations_1511818252 as st_sp
- inner join specializations as sp
- on st_sp.specialization_id = sp.id
- inner join max_applicable_call_types as mact
- on st_sp.specialization_id = mact.specialization_id
- and mact.call_type_id = 12734
- inner join buffer_specialization_daily_counts_1511818252 as sp_dc
- on st_sp.specialization_id = sp_dc.specialization_id
- and sp_dc.staff_id is null
- and sp_dc.schedule_on = '2019-08-02'
- left join buffer_specialization_daily_counts_1511818252 as sp_dc_2
- on st_sp.specialization_id = sp_dc_2.specialization_id
- and st_sp.staff_id = sp_dc_2.staff_id
- and sp_dc_2.schedule_on = '2019-08-02'
- where st_sp.staff_id = 20739
- and sp_dc_2.id is null
- (166.0ms) /* MaxAssignmentsRule */
- delete from buffer_linkage_call_type_assignments_1511818252
- where linkage_instance_id = 18201930;
- (152.0ms) /* MaxAssignmentsRule */
- update
- buffer_schedules_1511818252 as sc
- inner join call_types as ct
- on sc.call_type_id = ct.id
- and ct.active = 1
- inner join buffer_call_type_assignments_1511818252 as cta
- on sc.staff_id = cta.staff_id
- and sc.call_type_id = cta.call_type_id
- and sc.is_weekend = cta.is_weekend
- and sc.period_offset = cta.period_offset
- and sc.calendar_schedule_id = cta.calendar_schedule_id
- set cta.assignments_count = cta.assignments_count + 1
- where
- sc.schedule_on = '2019-08-02'
- and sc.call_type_id = 12734
- and sc.staff_id = 20739
- (152.0ms) /* UnassignedDaysRule */
- delete from buffer_linkage_assigned_days_1511818252
- where linkage_instance_id = 18201930
- (822.2ms) /* UnassignedDaysRule */
- UPDATE buffer_staff_assigned_days_1511818252 as sad
- inner join call_types as ct
- on ct.id = 12734
- and ct.unassigned_day = 0
- SET sad.is_assigned = 1
- WHERE sad.staff_id = 20739
- AND sad.schedule_on = '2019-08-02'
- (152.6ms) delete
- from buffer_linkage_assignment_limits_1511818252
- where
- staff_id = 20739
- and linkage_instance_id = 18201930
- (154.7ms) insert into buffer_staff_assignment_limits_1511818252 (
- staff_id,
- assignment_limit_id,
- period_id,
- consecutive_days_mask,
- current_value
- )
- select
- sc.staff_id,
- al.id as assignment_limit_id,
- alp.id as period_id,
- case
- when (alp.limit_subtype_mask = 8 /* consecutive */) then
- (1 << datediff(sc.schedule_on, alp.start_date))
- else 0
- end as consecutive_days_mask,
- case
- when (al.limit_type = 0 /* assignments */) then 1.0
- when (al.limit_type = 1 /* points */) then ci.points
- when (al.limit_type = 2 /* hours */) then ci.hours
- else 0
- end as current_value
- from
- buffer_schedules_1511818252 as sc
- inner join buffer_assignment_limit_call_types_1511818252 as alct
- on sc.call_type_id = alct.call_type_id
- inner join buffer_assignment_limits_1511818252 as al
- on alct.assignment_limit_id = al.id
- and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
- inner join buffer_assignment_limit_staffs_1511818252 as als
- on al.id = als.assignment_limit_id
- and sc.staff_id = als.staff_id
- inner join assign_staff_types as ast
- on sc.staff_id = ast.staff_id
- and sc.schedule_on between ast.begin_date and coalesce(ast.end_date, '9999-12-31')
- inner join buffer_assignment_limit_staff_types_1511818252 as alst
- on al.id = alst.assignment_limit_id
- and ast.staff_type_id = alst.staff_type_id
- inner join buffer_assignment_limit_periods_1511818252 as alp
- on al.id = alp.assignment_limit_id
- and sc.schedule_on between alp.start_date and alp.end_date
- inner join buffer_counter_increments_1511818252 as ci
- on sc.id = ci.schedule_id
- where
- sc.schedule_on = '2019-08-02'
- and sc.call_type_id = 12734
- and sc.staff_id = 20739
- on duplicate key update
- consecutive_days_mask = consecutive_days_mask | values(consecutive_days_mask),
- current_value = current_value + values(current_value)
- INFO : (02-15 13:33:50) scheduled for: plan unit: [id:18201930] [2019-08-02 - SSGE], Ron Dobrovinsky. DEPTH(2)
- (571.6ms) select
- coalesce(max(
- case
- when (ct.max_weekday_assignments > 0) then 1
- else 0
- end
- ), 0) as weekday_flag,
- coalesce(max(
- case
- when (ct.max_weekend_assignments > 0) then 1
- else 0
- end
- ), 0) as weekend_flag
- from
- buffer_auto_populate_slots_1511818252 as aps
- inner join call_types as ct
- on aps.call_type_id = ct.id
- (145.9ms) /* NegativeLinkRule */
- delete ca
- from buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_negative_relations_1511818252 as nr use index (ix_buffer_negative_relations_composite_1)
- on ca.schedule_id = nr.schedule_id
- and ca.staff_id = nr.staff_id
- (173.6ms) /* SpecializationOverlapRule */
- delete ca
- from buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_staff_specializations_1511818252 as ssp
- on ca.staff_id = ssp.staff_id
- inner join max_applicable_call_types as mact
- on ssp.specialization_id = mact.specialization_id
- and sc.call_type_id = mact.call_type_id
- inner join buffer_specialization_daily_counts_1511818252 as sdc use index (ix_buffer_specialization_daily_counts_composite_1)
- on ssp.specialization_id = sdc.specialization_id
- and sc.schedule_on = sdc.schedule_on
- and sdc.staff_id is null
- left join buffer_specialization_daily_counts_1511818252 as sdc_2 use index (ix_buffer_specialization_daily_counts_composite_1)
- on ssp.specialization_id = sdc_2.specialization_id
- and sc.schedule_on = sdc_2.schedule_on
- and ca.staff_id = sdc_2.staff_id
- where sdc.should_be_evaluated = 1
- and (sdc.staffs_scheduled + if(sdc_2.id is null, 1, 0)) > sdc.max_scheduled
- (145.8ms) /* BrokenLinkageRule */
- truncate table buffer_combined_availability_linkages_1511818252
- (152.2ms) insert into buffer_combined_availability_linkages_1511818252 (
- staff_id,
- linkage_instance_id,
- slots_count,
- is_primary,
- has_violations
- )
- select
- staff_id,
- linkage_instance_id,
- count(1) as slots_count,
- min(is_primary) as is_primary,
- max(has_violations) as has_violations
- from buffer_combined_availabilities_1511818252 use index (ix_buffer_combined_availabilities_composite_2)
- group by
- staff_id,
- linkage_instance_id
- order by null
- (153.4ms) delete ca
- from
- buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_linkages_1511818252 as l
- on sc.linkage_instance_id = l.linkage_instance_id
- inner join buffer_combined_availability_linkages_1511818252 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
- on ca.staff_id = ls_1.staff_id
- and sc.linkage_instance_id = ls_1.linkage_instance_id
- left join buffer_schedule_linkages_1511818252 as ls_2 use index (ix_buffer_schedule_linkages_composite_1)
- on ca.staff_id = ls_2.staff_id
- and sc.linkage_instance_id = ls_2.linkage_instance_id
- where (ls_1.slots_count + coalesce(ls_2.slots_count, 0)) < l.slots_count_total /* not covering the whole chain */;
- (182.0ms) select straight_join
- sc.schedule_on,
- sc.call_type_id,
- count(distinct ca.staff_id) as available_members_count,
- group_concat(
- distinct concat(if(ls_1.is_primary = 1, 'p', 's'), ca.staff_id)
- order by ls_1.is_primary desc, ca.staff_id
- separator ', '
- ) as available_members_ids,
- sc.linkage_instance_id,
- l.slots_count_total as linkage_slots_count
- from buffer_combined_availabilities_1511818252 as ca
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_linkages_1511818252 as l
- on sc.linkage_instance_id = l.linkage_instance_id
- inner join buffer_combined_availability_linkages_1511818252 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
- on ca.staff_id = ls_1.staff_id
- and sc.linkage_instance_id = ls_1.linkage_instance_id
- and ls_1.has_violations = 0
- where sc.should_be_evaluated = 1
- and sc.should_be_populated = 1
- group by sc.schedule_on, sc.call_type_id, sc.linkage_instance_id, l.slots_count_total
- order by available_members_count, sc.schedule_on, sc.display_order
- limit 1
- (153.6ms) truncate table buffer_rule_scores_1511818252
- (152.4ms) truncate table buffer_rule_calc_filters_1511818252
- (152.5ms) insert into buffer_rule_calc_filters_1511818252 (
- linkage_instance_id,
- staff_id
- ) values (6201931, 20739)
- (155.7ms) truncate table buffer_rule_scores_with_corrections_1511818252
- (149.3ms) insert into buffer_rule_scores_with_corrections_1511818252 (
- linkage_instance_id, schedule_id, staff_id, rule_name, value
- )
- select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id, rule_scores.rule_name,
- ifnull(rule_scores.value, max_values.max_value + 1) as value
- from buffer_rule_scores_1511818252 as rule_scores
- inner join (
- select rule_name, max(value) as max_value
- from buffer_rule_scores_1511818252
- group by rule_name
- order by null
- ) as max_values
- on rule_scores.rule_name = max_values.rule_name
- order by null
- (303.2ms) select linkage_instance_id, staff_id, avg(slot_scores) as scores
- from (
- select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id,
- sum(
- if((total_values.total_value > 0), (rule_scores.value / total_values.total_value), 0) *
- rules.weight *
- total_values.slots_count
- ) as slot_scores
- from buffer_rule_scores_with_corrections_1511818252 as rule_scores
- inner join (
- select rule_name, sum(abs(value)) as total_value,
- count(distinct schedule_id) as slots_count
- from buffer_rule_scores_with_corrections_1511818252
- group by rule_name
- order by null
- ) as total_values
- on rule_scores.rule_name = total_values.rule_name
- inner join rules
- on rule_scores.rule_name = rules.type
- where rules.rule_set_id = 1538
- and rules.applied = 1
- group by rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id
- order by null
- ) as staff_scores
- group by linkage_instance_id, staff_id
- order by round(avg(slot_scores), 5) desc, rand()
- limit 1
- WARN : (02-15 13:33:53) No score found. Using fake score...
- PublishedBlock Load (150.6ms) SELECT `published_blocks`.* FROM `published_blocks` INNER JOIN `blocks` ON `blocks`.`id` = `published_blocks`.`block_id` WHERE `published_blocks`.`client_id` = 325 AND ('2019-08-05' BETWEEN blocks.start_date AND blocks.end_date) AND `published_blocks`.`calendar_schedule_id` = 1396 ORDER BY `published_blocks`.`id` ASC LIMIT 1
- (169.2ms) BEGIN
- (147.8ms) SELECT COALESCE(pb.updated_at, pbct.updated_at)
- FROM call_types AS ct
- INNER JOIN calendar_schedules AS cs
- ON ct.calendar_schedule_id = cs.id
- INNER JOIN blocks AS b
- ON b.client_id = ct.client_id
- AND b.block_schedule_id = cs.block_schedule_id
- AND '2019-08-05' BETWEEN b.start_date AND b.end_date
- INNER JOIN published_blocks AS pb
- ON pb.client_id = ct.client_id
- AND pb.block_id = b.id
- AND pb.calendar_schedule_id = cs.id
- LEFT JOIN published_block_call_types AS pbct
- ON pbct.client_id = ct.client_id
- AND pbct.assignment_id = ct.id
- AND pbct.assignment_type = 'CallType'
- AND pbct.block_id = b.id
- AND (
- (1 << (DAYOFWEEK('2019-08-05') - 1) & pbct.days_of_week_mask) > 0
- )
- WHERE ct.id = 12734
- AND (
- (
- pb.assignment_ids IS NULL
- AND (1 << (DAYOFWEEK('2019-08-05') - 1) & pb.days_of_week_mask) > 0
- )
- OR pbct.id IS NOT NULL
- )
- CallType Load (309.2ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 12734 LIMIT 1
- Client Load (597.3ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 325 LIMIT 1
- Staff Load (287.4ms) SELECT `staffs`.* FROM `staffs` WHERE `staffs`.`id` = 20739 LIMIT 1
- Schedule Exists (162.8ms) SELECT 1 AS one FROM `schedules` WHERE `schedules`.`call_type_id` = 12734 AND `schedules`.`client_id` = 325 AND `schedules`.`schedule_on` = '2019-08-05' LIMIT 1
- SQL (457.5ms) INSERT INTO `schedules` (`client_id`, `call_type_id`, `staff_id`, `schedule_on`, `created_at`, `updated_at`, `weekend_on`, `dayofweek_on`, `populate_method`, `creator_id`) VALUES (325, 12734, 20739, '2019-08-05', '2019-02-15 13:33:55', '2019-02-15 13:33:55', 0, 2, 'auto_populate_step', 20695)
- VisibleAssignment Load (145.9ms) SELECT `visible_assignments`.* FROM `visible_assignments` WHERE `visible_assignments`.`client_id` = 325 AND `visible_assignments`.`date` = '2019-08-05' AND `visible_assignments`.`assignment_type` = 'CallType' AND `visible_assignments`.`assignment_id` = 12734 ORDER BY `visible_assignments`.`id` ASC LIMIT 1
- (143.7ms) COMMIT
- FLUSHED: nil:nil
- (459.9ms) UPDATE buffer_schedules_1511818252
- SET staff_id = 20739,
- should_be_populated = 0,
- should_be_evaluated = 0
- WHERE
- call_type_id = 12734
- AND schedule_on = '2019-08-05'
- (150.4ms) delete from buffer_combined_availabilities_1511818252
- where linkage_instance_id = 6201931
- (149.1ms) UPDATE buffer_rule_calc_schedules_1511818252
- SET staff_id = 20739
- WHERE call_type_id = 12734
- AND schedule_on = '2019-08-05'
- (147.1ms) INSERT INTO buffer_rule_calc_schedules_1511818252
- SET staff_id = 20739,
- call_type_id = 12734,
- schedule_on = '2019-08-05',
- day_of_week_mask = 2
- (154.3ms) /* NegativeLinkRule */
- UPDATE buffer_negative_relations_1511818252
- SET staff_id = 20739
- WHERE affected_by_schedule_id = (
- SELECT id
- FROM buffer_schedules_1511818252
- WHERE schedule_on = '2019-08-05'
- AND call_type_id = 12734
- )
- (152.6ms) /* SpecializationOverlapRule */
- update buffer_staff_specializations_1511818252 as st_sp
- inner join max_applicable_call_types as mact
- on st_sp.specialization_id = mact.specialization_id
- and mact.call_type_id = 12734
- inner join buffer_specialization_daily_counts_1511818252 as sp_dc
- on st_sp.specialization_id = sp_dc.specialization_id
- and sp_dc.staff_id is null
- and sp_dc.schedule_on = '2019-08-05'
- left join buffer_specialization_daily_counts_1511818252 as sp_dc_2
- on st_sp.specialization_id = sp_dc_2.specialization_id
- and st_sp.staff_id = sp_dc_2.staff_id
- and sp_dc_2.schedule_on = '2019-08-05'
- set sp_dc.staffs_scheduled = sp_dc.staffs_scheduled + 1
- where st_sp.staff_id = 20739
- and sp_dc_2.id is null
- (318.5ms) insert into buffer_specialization_daily_counts_1511818252 (
- specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
- )
- select sp.id as specialization_id,
- 20739 as staff_id,
- '2019-08-05' as schedule_on,
- 1 as staffs_scheduled,
- sp.max_scheduled,
- sp_dc.should_be_evaluated
- from buffer_staff_specializations_1511818252 as st_sp
- inner join specializations as sp
- on st_sp.specialization_id = sp.id
- inner join max_applicable_call_types as mact
- on st_sp.specialization_id = mact.specialization_id
- and mact.call_type_id = 12734
- inner join buffer_specialization_daily_counts_1511818252 as sp_dc
- on st_sp.specialization_id = sp_dc.specialization_id
- and sp_dc.staff_id is null
- and sp_dc.schedule_on = '2019-08-05'
- left join buffer_specialization_daily_counts_1511818252 as sp_dc_2
- on st_sp.specialization_id = sp_dc_2.specialization_id
- and st_sp.staff_id = sp_dc_2.staff_id
- and sp_dc_2.schedule_on = '2019-08-05'
- where st_sp.staff_id = 20739
- and sp_dc_2.id is null
- (462.0ms) /* MaxAssignmentsRule */
- delete from buffer_linkage_call_type_assignments_1511818252
- where linkage_instance_id = 6201931;
- (461.1ms) /* MaxAssignmentsRule */
- update
- buffer_schedules_1511818252 as sc
- inner join call_types as ct
- on sc.call_type_id = ct.id
- and ct.active = 1
- inner join buffer_call_type_assignments_1511818252 as cta
- on sc.staff_id = cta.staff_id
- and sc.call_type_id = cta.call_type_id
- and sc.is_weekend = cta.is_weekend
- and sc.period_offset = cta.period_offset
- and sc.calendar_schedule_id = cta.calendar_schedule_id
- set cta.assignments_count = cta.assignments_count + 1
- where
- sc.schedule_on = '2019-08-05'
- and sc.call_type_id = 12734
- and sc.staff_id = 20739
- (149.5ms) /* UnassignedDaysRule */
- delete from buffer_linkage_assigned_days_1511818252
- where linkage_instance_id = 6201931
- (153.9ms) /* UnassignedDaysRule */
- UPDATE buffer_staff_assigned_days_1511818252 as sad
- inner join call_types as ct
- on ct.id = 12734
- and ct.unassigned_day = 0
- SET sad.is_assigned = 1
- WHERE sad.staff_id = 20739
- AND sad.schedule_on = '2019-08-05'
- (473.8ms) delete
- from buffer_linkage_assignment_limits_1511818252
- where
- staff_id = 20739
- and linkage_instance_id = 6201931
- (175.7ms) insert into buffer_staff_assignment_limits_1511818252 (
- staff_id,
- assignment_limit_id,
- period_id,
- consecutive_days_mask,
- current_value
- )
- select
- sc.staff_id,
- al.id as assignment_limit_id,
- alp.id as period_id,
- case
- when (alp.limit_subtype_mask = 8 /* consecutive */) then
- (1 << datediff(sc.schedule_on, alp.start_date))
- else 0
- end as consecutive_days_mask,
- case
- when (al.limit_type = 0 /* assignments */) then 1.0
- when (al.limit_type = 1 /* points */) then ci.points
- when (al.limit_type = 2 /* hours */) then ci.hours
- else 0
- end as current_value
- from
- buffer_schedules_1511818252 as sc
- inner join buffer_assignment_limit_call_types_1511818252 as alct
- on sc.call_type_id = alct.call_type_id
- inner join buffer_assignment_limits_1511818252 as al
- on alct.assignment_limit_id = al.id
- and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
- inner join buffer_assignment_limit_staffs_1511818252 as als
- on al.id = als.assignment_limit_id
- and sc.staff_id = als.staff_id
- inner join assign_staff_types as ast
- on sc.staff_id = ast.staff_id
- and sc.schedule_on between ast.begin_date and coalesce(ast.end_date, '9999-12-31')
- inner join buffer_assignment_limit_staff_types_1511818252 as alst
- on al.id = alst.assignment_limit_id
- and ast.staff_type_id = alst.staff_type_id
- inner join buffer_assignment_limit_periods_1511818252 as alp
- on al.id = alp.assignment_limit_id
- and sc.schedule_on between alp.start_date and alp.end_date
- inner join buffer_counter_increments_1511818252 as ci
- on sc.id = ci.schedule_id
- where
- sc.schedule_on = '2019-08-05'
- and sc.call_type_id = 12734
- and sc.staff_id = 20739
- on duplicate key update
- consecutive_days_mask = consecutive_days_mask | values(consecutive_days_mask),
- current_value = current_value + values(current_value)
- INFO : (02-15 13:33:59) scheduled for: plan unit: [id:6201931] [2019-08-05 - SSGE], Ron Dobrovinsky. DEPTH(3)
- (146.0ms) select
- coalesce(max(
- case
- when (ct.max_weekday_assignments > 0) then 1
- else 0
- end
- ), 0) as weekday_flag,
- coalesce(max(
- case
- when (ct.max_weekend_assignments > 0) then 1
- else 0
- end
- ), 0) as weekend_flag
- from
- buffer_auto_populate_slots_1511818252 as aps
- inner join call_types as ct
- on aps.call_type_id = ct.id
- (155.2ms) /* NegativeLinkRule */
- delete ca
- from buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_negative_relations_1511818252 as nr use index (ix_buffer_negative_relations_composite_1)
- on ca.schedule_id = nr.schedule_id
- and ca.staff_id = nr.staff_id
- (834.2ms) /* SpecializationOverlapRule */
- delete ca
- from buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_staff_specializations_1511818252 as ssp
- on ca.staff_id = ssp.staff_id
- inner join max_applicable_call_types as mact
- on ssp.specialization_id = mact.specialization_id
- and sc.call_type_id = mact.call_type_id
- inner join buffer_specialization_daily_counts_1511818252 as sdc use index (ix_buffer_specialization_daily_counts_composite_1)
- on ssp.specialization_id = sdc.specialization_id
- and sc.schedule_on = sdc.schedule_on
- and sdc.staff_id is null
- left join buffer_specialization_daily_counts_1511818252 as sdc_2 use index (ix_buffer_specialization_daily_counts_composite_1)
- on ssp.specialization_id = sdc_2.specialization_id
- and sc.schedule_on = sdc_2.schedule_on
- and ca.staff_id = sdc_2.staff_id
- where sdc.should_be_evaluated = 1
- and (sdc.staffs_scheduled + if(sdc_2.id is null, 1, 0)) > sdc.max_scheduled
- (931.4ms) /* BrokenLinkageRule */
- truncate table buffer_combined_availability_linkages_1511818252
- (152.5ms) insert into buffer_combined_availability_linkages_1511818252 (
- staff_id,
- linkage_instance_id,
- slots_count,
- is_primary,
- has_violations
- )
- select
- staff_id,
- linkage_instance_id,
- count(1) as slots_count,
- min(is_primary) as is_primary,
- max(has_violations) as has_violations
- from buffer_combined_availabilities_1511818252 use index (ix_buffer_combined_availabilities_composite_2)
- group by
- staff_id,
- linkage_instance_id
- order by null
- (149.0ms) delete ca
- from
- buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_linkages_1511818252 as l
- on sc.linkage_instance_id = l.linkage_instance_id
- inner join buffer_combined_availability_linkages_1511818252 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
- on ca.staff_id = ls_1.staff_id
- and sc.linkage_instance_id = ls_1.linkage_instance_id
- left join buffer_schedule_linkages_1511818252 as ls_2 use index (ix_buffer_schedule_linkages_composite_1)
- on ca.staff_id = ls_2.staff_id
- and sc.linkage_instance_id = ls_2.linkage_instance_id
- where (ls_1.slots_count + coalesce(ls_2.slots_count, 0)) < l.slots_count_total /* not covering the whole chain */;
- (157.4ms) select straight_join
- sc.schedule_on,
- sc.call_type_id,
- count(distinct ca.staff_id) as available_members_count,
- group_concat(
- distinct concat(if(ls_1.is_primary = 1, 'p', 's'), ca.staff_id)
- order by ls_1.is_primary desc, ca.staff_id
- separator ', '
- ) as available_members_ids,
- sc.linkage_instance_id,
- l.slots_count_total as linkage_slots_count
- from buffer_combined_availabilities_1511818252 as ca
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_linkages_1511818252 as l
- on sc.linkage_instance_id = l.linkage_instance_id
- inner join buffer_combined_availability_linkages_1511818252 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
- on ca.staff_id = ls_1.staff_id
- and sc.linkage_instance_id = ls_1.linkage_instance_id
- and ls_1.has_violations = 0
- where sc.should_be_evaluated = 1
- and sc.should_be_populated = 1
- group by sc.schedule_on, sc.call_type_id, sc.linkage_instance_id, l.slots_count_total
- order by available_members_count, sc.schedule_on, sc.display_order
- limit 1
- (451.3ms) truncate table buffer_rule_scores_1511818252
- (150.6ms) truncate table buffer_rule_calc_filters_1511818252
- (165.7ms) insert into buffer_rule_calc_filters_1511818252 (
- linkage_instance_id,
- staff_id
- ) values (9201931, 20739)
- (141.6ms) truncate table buffer_rule_scores_with_corrections_1511818252
- (162.9ms) insert into buffer_rule_scores_with_corrections_1511818252 (
- linkage_instance_id, schedule_id, staff_id, rule_name, value
- )
- select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id, rule_scores.rule_name,
- ifnull(rule_scores.value, max_values.max_value + 1) as value
- from buffer_rule_scores_1511818252 as rule_scores
- inner join (
- select rule_name, max(value) as max_value
- from buffer_rule_scores_1511818252
- group by rule_name
- order by null
- ) as max_values
- on rule_scores.rule_name = max_values.rule_name
- order by null
- (152.3ms) select linkage_instance_id, staff_id, avg(slot_scores) as scores
- from (
- select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id,
- sum(
- if((total_values.total_value > 0), (rule_scores.value / total_values.total_value), 0) *
- rules.weight *
- total_values.slots_count
- ) as slot_scores
- from buffer_rule_scores_with_corrections_1511818252 as rule_scores
- inner join (
- select rule_name, sum(abs(value)) as total_value,
- count(distinct schedule_id) as slots_count
- from buffer_rule_scores_with_corrections_1511818252
- group by rule_name
- order by null
- ) as total_values
- on rule_scores.rule_name = total_values.rule_name
- inner join rules
- on rule_scores.rule_name = rules.type
- where rules.rule_set_id = 1538
- and rules.applied = 1
- group by rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id
- order by null
- ) as staff_scores
- group by linkage_instance_id, staff_id
- order by round(avg(slot_scores), 5) desc, rand()
- limit 1
- WARN : (02-15 13:34:03) No score found. Using fake score...
- PublishedBlock Load (568.5ms) SELECT `published_blocks`.* FROM `published_blocks` INNER JOIN `blocks` ON `blocks`.`id` = `published_blocks`.`block_id` WHERE `published_blocks`.`client_id` = 325 AND ('2019-08-06' BETWEEN blocks.start_date AND blocks.end_date) AND `published_blocks`.`calendar_schedule_id` = 1396 ORDER BY `published_blocks`.`id` ASC LIMIT 1
- (139.4ms) BEGIN
- (456.8ms) SELECT COALESCE(pb.updated_at, pbct.updated_at)
- FROM call_types AS ct
- INNER JOIN calendar_schedules AS cs
- ON ct.calendar_schedule_id = cs.id
- INNER JOIN blocks AS b
- ON b.client_id = ct.client_id
- AND b.block_schedule_id = cs.block_schedule_id
- AND '2019-08-06' BETWEEN b.start_date AND b.end_date
- INNER JOIN published_blocks AS pb
- ON pb.client_id = ct.client_id
- AND pb.block_id = b.id
- AND pb.calendar_schedule_id = cs.id
- LEFT JOIN published_block_call_types AS pbct
- ON pbct.client_id = ct.client_id
- AND pbct.assignment_id = ct.id
- AND pbct.assignment_type = 'CallType'
- AND pbct.block_id = b.id
- AND (
- (1 << (DAYOFWEEK('2019-08-06') - 1) & pbct.days_of_week_mask) > 0
- )
- WHERE ct.id = 12734
- AND (
- (
- pb.assignment_ids IS NULL
- AND (1 << (DAYOFWEEK('2019-08-06') - 1) & pb.days_of_week_mask) > 0
- )
- OR pbct.id IS NOT NULL
- )
- CallType Load (297.2ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 12734 LIMIT 1
- Client Load (590.3ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 325 LIMIT 1
- Staff Load (1423.6ms) SELECT `staffs`.* FROM `staffs` WHERE `staffs`.`id` = 20739 LIMIT 1
- Schedule Exists (146.9ms) SELECT 1 AS one FROM `schedules` WHERE `schedules`.`call_type_id` = 12734 AND `schedules`.`client_id` = 325 AND `schedules`.`schedule_on` = '2019-08-06' LIMIT 1
- SQL (151.7ms) INSERT INTO `schedules` (`client_id`, `call_type_id`, `staff_id`, `schedule_on`, `created_at`, `updated_at`, `weekend_on`, `dayofweek_on`, `populate_method`, `creator_id`) VALUES (325, 12734, 20739, '2019-08-06', '2019-02-15 13:34:06', '2019-02-15 13:34:06', 0, 3, 'auto_populate_step', 20695)
- VisibleAssignment Load (145.3ms) SELECT `visible_assignments`.* FROM `visible_assignments` WHERE `visible_assignments`.`client_id` = 325 AND `visible_assignments`.`date` = '2019-08-06' AND `visible_assignments`.`assignment_type` = 'CallType' AND `visible_assignments`.`assignment_id` = 12734 ORDER BY `visible_assignments`.`id` ASC LIMIT 1
- (143.6ms) COMMIT
- FLUSHED: nil:nil
- (154.1ms) UPDATE buffer_schedules_1511818252
- SET staff_id = 20739,
- should_be_populated = 0,
- should_be_evaluated = 0
- WHERE
- call_type_id = 12734
- AND schedule_on = '2019-08-06'
- (147.5ms) delete from buffer_combined_availabilities_1511818252
- where linkage_instance_id = 9201931
- (144.8ms) UPDATE buffer_rule_calc_schedules_1511818252
- SET staff_id = 20739
- WHERE call_type_id = 12734
- AND schedule_on = '2019-08-06'
- (153.6ms) INSERT INTO buffer_rule_calc_schedules_1511818252
- SET staff_id = 20739,
- call_type_id = 12734,
- schedule_on = '2019-08-06',
- day_of_week_mask = 4
- (544.4ms) /* NegativeLinkRule */
- UPDATE buffer_negative_relations_1511818252
- SET staff_id = 20739
- WHERE affected_by_schedule_id = (
- SELECT id
- FROM buffer_schedules_1511818252
- WHERE schedule_on = '2019-08-06'
- AND call_type_id = 12734
- )
- (142.9ms) /* SpecializationOverlapRule */
- update buffer_staff_specializations_1511818252 as st_sp
- inner join max_applicable_call_types as mact
- on st_sp.specialization_id = mact.specialization_id
- and mact.call_type_id = 12734
- inner join buffer_specialization_daily_counts_1511818252 as sp_dc
- on st_sp.specialization_id = sp_dc.specialization_id
- and sp_dc.staff_id is null
- and sp_dc.schedule_on = '2019-08-06'
- left join buffer_specialization_daily_counts_1511818252 as sp_dc_2
- on st_sp.specialization_id = sp_dc_2.specialization_id
- and st_sp.staff_id = sp_dc_2.staff_id
- and sp_dc_2.schedule_on = '2019-08-06'
- set sp_dc.staffs_scheduled = sp_dc.staffs_scheduled + 1
- where st_sp.staff_id = 20739
- and sp_dc_2.id is null
- (148.6ms) insert into buffer_specialization_daily_counts_1511818252 (
- specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
- )
- select sp.id as specialization_id,
- 20739 as staff_id,
- '2019-08-06' as schedule_on,
- 1 as staffs_scheduled,
- sp.max_scheduled,
- sp_dc.should_be_evaluated
- from buffer_staff_specializations_1511818252 as st_sp
- inner join specializations as sp
- on st_sp.specialization_id = sp.id
- inner join max_applicable_call_types as mact
- on st_sp.specialization_id = mact.specialization_id
- and mact.call_type_id = 12734
- inner join buffer_specialization_daily_counts_1511818252 as sp_dc
- on st_sp.specialization_id = sp_dc.specialization_id
- and sp_dc.staff_id is null
- and sp_dc.schedule_on = '2019-08-06'
- left join buffer_specialization_daily_counts_1511818252 as sp_dc_2
- on st_sp.specialization_id = sp_dc_2.specialization_id
- and st_sp.staff_id = sp_dc_2.staff_id
- and sp_dc_2.schedule_on = '2019-08-06'
- where st_sp.staff_id = 20739
- and sp_dc_2.id is null
- (512.5ms) /* MaxAssignmentsRule */
- delete from buffer_linkage_call_type_assignments_1511818252
- where linkage_instance_id = 9201931;
- (154.9ms) /* MaxAssignmentsRule */
- update
- buffer_schedules_1511818252 as sc
- inner join call_types as ct
- on sc.call_type_id = ct.id
- and ct.active = 1
- inner join buffer_call_type_assignments_1511818252 as cta
- on sc.staff_id = cta.staff_id
- and sc.call_type_id = cta.call_type_id
- and sc.is_weekend = cta.is_weekend
- and sc.period_offset = cta.period_offset
- and sc.calendar_schedule_id = cta.calendar_schedule_id
- set cta.assignments_count = cta.assignments_count + 1
- where
- sc.schedule_on = '2019-08-06'
- and sc.call_type_id = 12734
- and sc.staff_id = 20739
- (143.9ms) /* UnassignedDaysRule */
- delete from buffer_linkage_assigned_days_1511818252
- where linkage_instance_id = 9201931
- (153.8ms) /* UnassignedDaysRule */
- UPDATE buffer_staff_assigned_days_1511818252 as sad
- inner join call_types as ct
- on ct.id = 12734
- and ct.unassigned_day = 0
- SET sad.is_assigned = 1
- WHERE sad.staff_id = 20739
- AND sad.schedule_on = '2019-08-06'
- (152.9ms) delete
- from buffer_linkage_assignment_limits_1511818252
- where
- staff_id = 20739
- and linkage_instance_id = 9201931
- (152.1ms) insert into buffer_staff_assignment_limits_1511818252 (
- staff_id,
- assignment_limit_id,
- period_id,
- consecutive_days_mask,
- current_value
- )
- select
- sc.staff_id,
- al.id as assignment_limit_id,
- alp.id as period_id,
- case
- when (alp.limit_subtype_mask = 8 /* consecutive */) then
- (1 << datediff(sc.schedule_on, alp.start_date))
- else 0
- end as consecutive_days_mask,
- case
- when (al.limit_type = 0 /* assignments */) then 1.0
- when (al.limit_type = 1 /* points */) then ci.points
- when (al.limit_type = 2 /* hours */) then ci.hours
- else 0
- end as current_value
- from
- buffer_schedules_1511818252 as sc
- inner join buffer_assignment_limit_call_types_1511818252 as alct
- on sc.call_type_id = alct.call_type_id
- inner join buffer_assignment_limits_1511818252 as al
- on alct.assignment_limit_id = al.id
- and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
- inner join buffer_assignment_limit_staffs_1511818252 as als
- on al.id = als.assignment_limit_id
- and sc.staff_id = als.staff_id
- inner join assign_staff_types as ast
- on sc.staff_id = ast.staff_id
- and sc.schedule_on between ast.begin_date and coalesce(ast.end_date, '9999-12-31')
- inner join buffer_assignment_limit_staff_types_1511818252 as alst
- on al.id = alst.assignment_limit_id
- and ast.staff_type_id = alst.staff_type_id
- inner join buffer_assignment_limit_periods_1511818252 as alp
- on al.id = alp.assignment_limit_id
- and sc.schedule_on between alp.start_date and alp.end_date
- inner join buffer_counter_increments_1511818252 as ci
- on sc.id = ci.schedule_id
- where
- sc.schedule_on = '2019-08-06'
- and sc.call_type_id = 12734
- and sc.staff_id = 20739
- on duplicate key update
- consecutive_days_mask = consecutive_days_mask | values(consecutive_days_mask),
- current_value = current_value + values(current_value)
- INFO : (02-15 13:34:09) scheduled for: plan unit: [id:9201931] [2019-08-06 - SSGE], Ron Dobrovinsky. DEPTH(4)
- (160.8ms) select
- coalesce(max(
- case
- when (ct.max_weekday_assignments > 0) then 1
- else 0
- end
- ), 0) as weekday_flag,
- coalesce(max(
- case
- when (ct.max_weekend_assignments > 0) then 1
- else 0
- end
- ), 0) as weekend_flag
- from
- buffer_auto_populate_slots_1511818252 as aps
- inner join call_types as ct
- on aps.call_type_id = ct.id
- (143.3ms) /* NegativeLinkRule */
- delete ca
- from buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_negative_relations_1511818252 as nr use index (ix_buffer_negative_relations_composite_1)
- on ca.schedule_id = nr.schedule_id
- and ca.staff_id = nr.staff_id
- (315.1ms) /* SpecializationOverlapRule */
- delete ca
- from buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_staff_specializations_1511818252 as ssp
- on ca.staff_id = ssp.staff_id
- inner join max_applicable_call_types as mact
- on ssp.specialization_id = mact.specialization_id
- and sc.call_type_id = mact.call_type_id
- inner join buffer_specialization_daily_counts_1511818252 as sdc use index (ix_buffer_specialization_daily_counts_composite_1)
- on ssp.specialization_id = sdc.specialization_id
- and sc.schedule_on = sdc.schedule_on
- and sdc.staff_id is null
- left join buffer_specialization_daily_counts_1511818252 as sdc_2 use index (ix_buffer_specialization_daily_counts_composite_1)
- on ssp.specialization_id = sdc_2.specialization_id
- and sc.schedule_on = sdc_2.schedule_on
- and ca.staff_id = sdc_2.staff_id
- where sdc.should_be_evaluated = 1
- and (sdc.staffs_scheduled + if(sdc_2.id is null, 1, 0)) > sdc.max_scheduled
- (949.5ms) /* BrokenLinkageRule */
- truncate table buffer_combined_availability_linkages_1511818252
- (144.9ms) insert into buffer_combined_availability_linkages_1511818252 (
- staff_id,
- linkage_instance_id,
- slots_count,
- is_primary,
- has_violations
- )
- select
- staff_id,
- linkage_instance_id,
- count(1) as slots_count,
- min(is_primary) as is_primary,
- max(has_violations) as has_violations
- from buffer_combined_availabilities_1511818252 use index (ix_buffer_combined_availabilities_composite_2)
- group by
- staff_id,
- linkage_instance_id
- order by null
- (152.9ms) delete ca
- from
- buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_linkages_1511818252 as l
- on sc.linkage_instance_id = l.linkage_instance_id
- inner join buffer_combined_availability_linkages_1511818252 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
- on ca.staff_id = ls_1.staff_id
- and sc.linkage_instance_id = ls_1.linkage_instance_id
- left join buffer_schedule_linkages_1511818252 as ls_2 use index (ix_buffer_schedule_linkages_composite_1)
- on ca.staff_id = ls_2.staff_id
- and sc.linkage_instance_id = ls_2.linkage_instance_id
- where (ls_1.slots_count + coalesce(ls_2.slots_count, 0)) < l.slots_count_total /* not covering the whole chain */;
- (645.5ms) select straight_join
- sc.schedule_on,
- sc.call_type_id,
- count(distinct ca.staff_id) as available_members_count,
- group_concat(
- distinct concat(if(ls_1.is_primary = 1, 'p', 's'), ca.staff_id)
- order by ls_1.is_primary desc, ca.staff_id
- separator ', '
- ) as available_members_ids,
- sc.linkage_instance_id,
- l.slots_count_total as linkage_slots_count
- from buffer_combined_availabilities_1511818252 as ca
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_linkages_1511818252 as l
- on sc.linkage_instance_id = l.linkage_instance_id
- inner join buffer_combined_availability_linkages_1511818252 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
- on ca.staff_id = ls_1.staff_id
- and sc.linkage_instance_id = ls_1.linkage_instance_id
- and ls_1.has_violations = 0
- where sc.should_be_evaluated = 1
- and sc.should_be_populated = 1
- group by sc.schedule_on, sc.call_type_id, sc.linkage_instance_id, l.slots_count_total
- order by available_members_count, sc.schedule_on, sc.display_order
- limit 1
- (150.7ms) truncate table buffer_rule_scores_1511818252
- (151.3ms) truncate table buffer_rule_calc_filters_1511818252
- (152.2ms) insert into buffer_rule_calc_filters_1511818252 (
- linkage_instance_id,
- staff_id
- ) values (12201931, 20739)
- (157.3ms) truncate table buffer_rule_scores_with_corrections_1511818252
- (155.0ms) insert into buffer_rule_scores_with_corrections_1511818252 (
- linkage_instance_id, schedule_id, staff_id, rule_name, value
- )
- select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id, rule_scores.rule_name,
- ifnull(rule_scores.value, max_values.max_value + 1) as value
- from buffer_rule_scores_1511818252 as rule_scores
- inner join (
- select rule_name, max(value) as max_value
- from buffer_rule_scores_1511818252
- group by rule_name
- order by null
- ) as max_values
- on rule_scores.rule_name = max_values.rule_name
- order by null
- (152.8ms) select linkage_instance_id, staff_id, avg(slot_scores) as scores
- from (
- select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id,
- sum(
- if((total_values.total_value > 0), (rule_scores.value / total_values.total_value), 0) *
- rules.weight *
- total_values.slots_count
- ) as slot_scores
- from buffer_rule_scores_with_corrections_1511818252 as rule_scores
- inner join (
- select rule_name, sum(abs(value)) as total_value,
- count(distinct schedule_id) as slots_count
- from buffer_rule_scores_with_corrections_1511818252
- group by rule_name
- order by null
- ) as total_values
- on rule_scores.rule_name = total_values.rule_name
- inner join rules
- on rule_scores.rule_name = rules.type
- where rules.rule_set_id = 1538
- and rules.applied = 1
- group by rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id
- order by null
- ) as staff_scores
- group by linkage_instance_id, staff_id
- order by round(avg(slot_scores), 5) desc, rand()
- limit 1
- WARN : (02-15 13:34:13) No score found. Using fake score...
- PublishedBlock Load (141.4ms) SELECT `published_blocks`.* FROM `published_blocks` INNER JOIN `blocks` ON `blocks`.`id` = `published_blocks`.`block_id` WHERE `published_blocks`.`client_id` = 325 AND ('2019-08-07' BETWEEN blocks.start_date AND blocks.end_date) AND `published_blocks`.`calendar_schedule_id` = 1396 ORDER BY `published_blocks`.`id` ASC LIMIT 1
- (534.7ms) BEGIN
- (152.2ms) SELECT COALESCE(pb.updated_at, pbct.updated_at)
- FROM call_types AS ct
- INNER JOIN calendar_schedules AS cs
- ON ct.calendar_schedule_id = cs.id
- INNER JOIN blocks AS b
- ON b.client_id = ct.client_id
- AND b.block_schedule_id = cs.block_schedule_id
- AND '2019-08-07' BETWEEN b.start_date AND b.end_date
- INNER JOIN published_blocks AS pb
- ON pb.client_id = ct.client_id
- AND pb.block_id = b.id
- AND pb.calendar_schedule_id = cs.id
- LEFT JOIN published_block_call_types AS pbct
- ON pbct.client_id = ct.client_id
- AND pbct.assignment_id = ct.id
- AND pbct.assignment_type = 'CallType'
- AND pbct.block_id = b.id
- AND (
- (1 << (DAYOFWEEK('2019-08-07') - 1) & pbct.days_of_week_mask) > 0
- )
- WHERE ct.id = 12734
- AND (
- (
- pb.assignment_ids IS NULL
- AND (1 << (DAYOFWEEK('2019-08-07') - 1) & pb.days_of_week_mask) > 0
- )
- OR pbct.id IS NOT NULL
- )
- CallType Load (297.0ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 12734 LIMIT 1
- Client Load (601.9ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 325 LIMIT 1
- Staff Load (351.7ms) SELECT `staffs`.* FROM `staffs` WHERE `staffs`.`id` = 20739 LIMIT 1
- Schedule Exists (151.9ms) SELECT 1 AS one FROM `schedules` WHERE `schedules`.`call_type_id` = 12734 AND `schedules`.`client_id` = 325 AND `schedules`.`schedule_on` = '2019-08-07' LIMIT 1
- SQL (159.8ms) INSERT INTO `schedules` (`client_id`, `call_type_id`, `staff_id`, `schedule_on`, `created_at`, `updated_at`, `weekend_on`, `dayofweek_on`, `populate_method`, `creator_id`) VALUES (325, 12734, 20739, '2019-08-07', '2019-02-15 13:34:15', '2019-02-15 13:34:15', 0, 4, 'auto_populate_step', 20695)
- VisibleAssignment Load (152.1ms) SELECT `visible_assignments`.* FROM `visible_assignments` WHERE `visible_assignments`.`client_id` = 325 AND `visible_assignments`.`date` = '2019-08-07' AND `visible_assignments`.`assignment_type` = 'CallType' AND `visible_assignments`.`assignment_id` = 12734 ORDER BY `visible_assignments`.`id` ASC LIMIT 1
- (153.4ms) COMMIT
- FLUSHED: nil:nil
- (453.3ms) UPDATE buffer_schedules_1511818252
- SET staff_id = 20739,
- should_be_populated = 0,
- should_be_evaluated = 0
- WHERE
- call_type_id = 12734
- AND schedule_on = '2019-08-07'
- (142.0ms) delete from buffer_combined_availabilities_1511818252
- where linkage_instance_id = 12201931
- (910.8ms) UPDATE buffer_rule_calc_schedules_1511818252
- SET staff_id = 20739
- WHERE call_type_id = 12734
- AND schedule_on = '2019-08-07'
- (511.0ms) INSERT INTO buffer_rule_calc_schedules_1511818252
- SET staff_id = 20739,
- call_type_id = 12734,
- schedule_on = '2019-08-07',
- day_of_week_mask = 8
- (150.3ms) /* NegativeLinkRule */
- UPDATE buffer_negative_relations_1511818252
- SET staff_id = 20739
- WHERE affected_by_schedule_id = (
- SELECT id
- FROM buffer_schedules_1511818252
- WHERE schedule_on = '2019-08-07'
- AND call_type_id = 12734
- )
- (151.5ms) /* SpecializationOverlapRule */
- update buffer_staff_specializations_1511818252 as st_sp
- inner join max_applicable_call_types as mact
- on st_sp.specialization_id = mact.specialization_id
- and mact.call_type_id = 12734
- inner join buffer_specialization_daily_counts_1511818252 as sp_dc
- on st_sp.specialization_id = sp_dc.specialization_id
- and sp_dc.staff_id is null
- and sp_dc.schedule_on = '2019-08-07'
- left join buffer_specialization_daily_counts_1511818252 as sp_dc_2
- on st_sp.specialization_id = sp_dc_2.specialization_id
- and st_sp.staff_id = sp_dc_2.staff_id
- and sp_dc_2.schedule_on = '2019-08-07'
- set sp_dc.staffs_scheduled = sp_dc.staffs_scheduled + 1
- where st_sp.staff_id = 20739
- and sp_dc_2.id is null
- (146.5ms) insert into buffer_specialization_daily_counts_1511818252 (
- specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
- )
- select sp.id as specialization_id,
- 20739 as staff_id,
- '2019-08-07' as schedule_on,
- 1 as staffs_scheduled,
- sp.max_scheduled,
- sp_dc.should_be_evaluated
- from buffer_staff_specializations_1511818252 as st_sp
- inner join specializations as sp
- on st_sp.specialization_id = sp.id
- inner join max_applicable_call_types as mact
- on st_sp.specialization_id = mact.specialization_id
- and mact.call_type_id = 12734
- inner join buffer_specialization_daily_counts_1511818252 as sp_dc
- on st_sp.specialization_id = sp_dc.specialization_id
- and sp_dc.staff_id is null
- and sp_dc.schedule_on = '2019-08-07'
- left join buffer_specialization_daily_counts_1511818252 as sp_dc_2
- on st_sp.specialization_id = sp_dc_2.specialization_id
- and st_sp.staff_id = sp_dc_2.staff_id
- and sp_dc_2.schedule_on = '2019-08-07'
- where st_sp.staff_id = 20739
- and sp_dc_2.id is null
- (144.3ms) /* MaxAssignmentsRule */
- delete from buffer_linkage_call_type_assignments_1511818252
- where linkage_instance_id = 12201931;
- (148.0ms) /* MaxAssignmentsRule */
- update
- buffer_schedules_1511818252 as sc
- inner join call_types as ct
- on sc.call_type_id = ct.id
- and ct.active = 1
- inner join buffer_call_type_assignments_1511818252 as cta
- on sc.staff_id = cta.staff_id
- and sc.call_type_id = cta.call_type_id
- and sc.is_weekend = cta.is_weekend
- and sc.period_offset = cta.period_offset
- and sc.calendar_schedule_id = cta.calendar_schedule_id
- set cta.assignments_count = cta.assignments_count + 1
- where
- sc.schedule_on = '2019-08-07'
- and sc.call_type_id = 12734
- and sc.staff_id = 20739
- (148.4ms) /* UnassignedDaysRule */
- delete from buffer_linkage_assigned_days_1511818252
- where linkage_instance_id = 12201931
- (150.4ms) /* UnassignedDaysRule */
- UPDATE buffer_staff_assigned_days_1511818252 as sad
- inner join call_types as ct
- on ct.id = 12734
- and ct.unassigned_day = 0
- SET sad.is_assigned = 1
- WHERE sad.staff_id = 20739
- AND sad.schedule_on = '2019-08-07'
- (154.5ms) delete
- from buffer_linkage_assignment_limits_1511818252
- where
- staff_id = 20739
- and linkage_instance_id = 12201931
- (287.5ms) insert into buffer_staff_assignment_limits_1511818252 (
- staff_id,
- assignment_limit_id,
- period_id,
- consecutive_days_mask,
- current_value
- )
- select
- sc.staff_id,
- al.id as assignment_limit_id,
- alp.id as period_id,
- case
- when (alp.limit_subtype_mask = 8 /* consecutive */) then
- (1 << datediff(sc.schedule_on, alp.start_date))
- else 0
- end as consecutive_days_mask,
- case
- when (al.limit_type = 0 /* assignments */) then 1.0
- when (al.limit_type = 1 /* points */) then ci.points
- when (al.limit_type = 2 /* hours */) then ci.hours
- else 0
- end as current_value
- from
- buffer_schedules_1511818252 as sc
- inner join buffer_assignment_limit_call_types_1511818252 as alct
- on sc.call_type_id = alct.call_type_id
- inner join buffer_assignment_limits_1511818252 as al
- on alct.assignment_limit_id = al.id
- and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
- inner join buffer_assignment_limit_staffs_1511818252 as als
- on al.id = als.assignment_limit_id
- and sc.staff_id = als.staff_id
- inner join assign_staff_types as ast
- on sc.staff_id = ast.staff_id
- and sc.schedule_on between ast.begin_date and coalesce(ast.end_date, '9999-12-31')
- inner join buffer_assignment_limit_staff_types_1511818252 as alst
- on al.id = alst.assignment_limit_id
- and ast.staff_type_id = alst.staff_type_id
- inner join buffer_assignment_limit_periods_1511818252 as alp
- on al.id = alp.assignment_limit_id
- and sc.schedule_on between alp.start_date and alp.end_date
- inner join buffer_counter_increments_1511818252 as ci
- on sc.id = ci.schedule_id
- where
- sc.schedule_on = '2019-08-07'
- and sc.call_type_id = 12734
- and sc.staff_id = 20739
- on duplicate key update
- consecutive_days_mask = consecutive_days_mask | values(consecutive_days_mask),
- current_value = current_value + values(current_value)
- INFO : (02-15 13:34:19) scheduled for: plan unit: [id:12201931] [2019-08-07 - SSGE], Ron Dobrovinsky. DEPTH(5)
- (149.2ms) select
- coalesce(max(
- case
- when (ct.max_weekday_assignments > 0) then 1
- else 0
- end
- ), 0) as weekday_flag,
- coalesce(max(
- case
- when (ct.max_weekend_assignments > 0) then 1
- else 0
- end
- ), 0) as weekend_flag
- from
- buffer_auto_populate_slots_1511818252 as aps
- inner join call_types as ct
- on aps.call_type_id = ct.id
- (491.2ms) /* NegativeLinkRule */
- delete ca
- from buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_negative_relations_1511818252 as nr use index (ix_buffer_negative_relations_composite_1)
- on ca.schedule_id = nr.schedule_id
- and ca.staff_id = nr.staff_id
- (142.6ms) /* SpecializationOverlapRule */
- delete ca
- from buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_staff_specializations_1511818252 as ssp
- on ca.staff_id = ssp.staff_id
- inner join max_applicable_call_types as mact
- on ssp.specialization_id = mact.specialization_id
- and sc.call_type_id = mact.call_type_id
- inner join buffer_specialization_daily_counts_1511818252 as sdc use index (ix_buffer_specialization_daily_counts_composite_1)
- on ssp.specialization_id = sdc.specialization_id
- and sc.schedule_on = sdc.schedule_on
- and sdc.staff_id is null
- left join buffer_specialization_daily_counts_1511818252 as sdc_2 use index (ix_buffer_specialization_daily_counts_composite_1)
- on ssp.specialization_id = sdc_2.specialization_id
- and sc.schedule_on = sdc_2.schedule_on
- and ca.staff_id = sdc_2.staff_id
- where sdc.should_be_evaluated = 1
- and (sdc.staffs_scheduled + if(sdc_2.id is null, 1, 0)) > sdc.max_scheduled
- (173.9ms) /* BrokenLinkageRule */
- truncate table buffer_combined_availability_linkages_1511818252
- (516.2ms) insert into buffer_combined_availability_linkages_1511818252 (
- staff_id,
- linkage_instance_id,
- slots_count,
- is_primary,
- has_violations
- )
- select
- staff_id,
- linkage_instance_id,
- count(1) as slots_count,
- min(is_primary) as is_primary,
- max(has_violations) as has_violations
- from buffer_combined_availabilities_1511818252 use index (ix_buffer_combined_availabilities_composite_2)
- group by
- staff_id,
- linkage_instance_id
- order by null
- (141.9ms) delete ca
- from
- buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_linkages_1511818252 as l
- on sc.linkage_instance_id = l.linkage_instance_id
- inner join buffer_combined_availability_linkages_1511818252 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
- on ca.staff_id = ls_1.staff_id
- and sc.linkage_instance_id = ls_1.linkage_instance_id
- left join buffer_schedule_linkages_1511818252 as ls_2 use index (ix_buffer_schedule_linkages_composite_1)
- on ca.staff_id = ls_2.staff_id
- and sc.linkage_instance_id = ls_2.linkage_instance_id
- where (ls_1.slots_count + coalesce(ls_2.slots_count, 0)) < l.slots_count_total /* not covering the whole chain */;
- (150.2ms) select straight_join
- sc.schedule_on,
- sc.call_type_id,
- count(distinct ca.staff_id) as available_members_count,
- group_concat(
- distinct concat(if(ls_1.is_primary = 1, 'p', 's'), ca.staff_id)
- order by ls_1.is_primary desc, ca.staff_id
- separator ', '
- ) as available_members_ids,
- sc.linkage_instance_id,
- l.slots_count_total as linkage_slots_count
- from buffer_combined_availabilities_1511818252 as ca
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_linkages_1511818252 as l
- on sc.linkage_instance_id = l.linkage_instance_id
- inner join buffer_combined_availability_linkages_1511818252 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
- on ca.staff_id = ls_1.staff_id
- and sc.linkage_instance_id = ls_1.linkage_instance_id
- and ls_1.has_violations = 0
- where sc.should_be_evaluated = 1
- and sc.should_be_populated = 1
- group by sc.schedule_on, sc.call_type_id, sc.linkage_instance_id, l.slots_count_total
- order by available_members_count, sc.schedule_on, sc.display_order
- limit 1
- (155.2ms) truncate table buffer_rule_scores_1511818252
- (142.1ms) truncate table buffer_rule_calc_filters_1511818252
- (154.8ms) insert into buffer_rule_calc_filters_1511818252 (
- linkage_instance_id,
- staff_id
- ) values (15201931, 20739)
- (509.4ms) truncate table buffer_rule_scores_with_corrections_1511818252
- (816.5ms) insert into buffer_rule_scores_with_corrections_1511818252 (
- linkage_instance_id, schedule_id, staff_id, rule_name, value
- )
- select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id, rule_scores.rule_name,
- ifnull(rule_scores.value, max_values.max_value + 1) as value
- from buffer_rule_scores_1511818252 as rule_scores
- inner join (
- select rule_name, max(value) as max_value
- from buffer_rule_scores_1511818252
- group by rule_name
- order by null
- ) as max_values
- on rule_scores.rule_name = max_values.rule_name
- order by null
- (154.6ms) select linkage_instance_id, staff_id, avg(slot_scores) as scores
- from (
- select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id,
- sum(
- if((total_values.total_value > 0), (rule_scores.value / total_values.total_value), 0) *
- rules.weight *
- total_values.slots_count
- ) as slot_scores
- from buffer_rule_scores_with_corrections_1511818252 as rule_scores
- inner join (
- select rule_name, sum(abs(value)) as total_value,
- count(distinct schedule_id) as slots_count
- from buffer_rule_scores_with_corrections_1511818252
- group by rule_name
- order by null
- ) as total_values
- on rule_scores.rule_name = total_values.rule_name
- inner join rules
- on rule_scores.rule_name = rules.type
- where rules.rule_set_id = 1538
- and rules.applied = 1
- group by rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id
- order by null
- ) as staff_scores
- group by linkage_instance_id, staff_id
- order by round(avg(slot_scores), 5) desc, rand()
- limit 1
- WARN : (02-15 13:34:23) No score found. Using fake score...
- PublishedBlock Load (298.0ms) SELECT `published_blocks`.* FROM `published_blocks` INNER JOIN `blocks` ON `blocks`.`id` = `published_blocks`.`block_id` WHERE `published_blocks`.`client_id` = 325 AND ('2019-08-08' BETWEEN blocks.start_date AND blocks.end_date) AND `published_blocks`.`calendar_schedule_id` = 1396 ORDER BY `published_blocks`.`id` ASC LIMIT 1
- (148.1ms) BEGIN
- (153.4ms) SELECT COALESCE(pb.updated_at, pbct.updated_at)
- FROM call_types AS ct
- INNER JOIN calendar_schedules AS cs
- ON ct.calendar_schedule_id = cs.id
- INNER JOIN blocks AS b
- ON b.client_id = ct.client_id
- AND b.block_schedule_id = cs.block_schedule_id
- AND '2019-08-08' BETWEEN b.start_date AND b.end_date
- INNER JOIN published_blocks AS pb
- ON pb.client_id = ct.client_id
- AND pb.block_id = b.id
- AND pb.calendar_schedule_id = cs.id
- LEFT JOIN published_block_call_types AS pbct
- ON pbct.client_id = ct.client_id
- AND pbct.assignment_id = ct.id
- AND pbct.assignment_type = 'CallType'
- AND pbct.block_id = b.id
- AND (
- (1 << (DAYOFWEEK('2019-08-08') - 1) & pbct.days_of_week_mask) > 0
- )
- WHERE ct.id = 12734
- AND (
- (
- pb.assignment_ids IS NULL
- AND (1 << (DAYOFWEEK('2019-08-08') - 1) & pb.days_of_week_mask) > 0
- )
- OR pbct.id IS NOT NULL
- )
- CallType Load (2045.6ms) SELECT `call_types`.* FROM `call_types` WHERE `call_types`.`id` = 12734 LIMIT 1
- Client Load (441.9ms) SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 325 LIMIT 1
- Staff Load (141.0ms) SELECT `staffs`.* FROM `staffs` WHERE `staffs`.`id` = 20739 LIMIT 1
- Schedule Exists (142.8ms) SELECT 1 AS one FROM `schedules` WHERE `schedules`.`call_type_id` = 12734 AND `schedules`.`client_id` = 325 AND `schedules`.`schedule_on` = '2019-08-08' LIMIT 1
- SQL (144.9ms) INSERT INTO `schedules` (`client_id`, `call_type_id`, `staff_id`, `schedule_on`, `created_at`, `updated_at`, `weekend_on`, `dayofweek_on`, `populate_method`, `creator_id`) VALUES (325, 12734, 20739, '2019-08-08', '2019-02-15 13:34:26', '2019-02-15 13:34:26', 0, 5, 'auto_populate_step', 20695)
- VisibleAssignment Load (149.2ms) SELECT `visible_assignments`.* FROM `visible_assignments` WHERE `visible_assignments`.`client_id` = 325 AND `visible_assignments`.`date` = '2019-08-08' AND `visible_assignments`.`assignment_type` = 'CallType' AND `visible_assignments`.`assignment_id` = 12734 ORDER BY `visible_assignments`.`id` ASC LIMIT 1
- (148.3ms) COMMIT
- FLUSHED: nil:nil
- (144.9ms) UPDATE buffer_schedules_1511818252
- SET staff_id = 20739,
- should_be_populated = 0,
- should_be_evaluated = 0
- WHERE
- call_type_id = 12734
- AND schedule_on = '2019-08-08'
- (144.2ms) delete from buffer_combined_availabilities_1511818252
- where linkage_instance_id = 15201931
- (140.0ms) UPDATE buffer_rule_calc_schedules_1511818252
- SET staff_id = 20739
- WHERE call_type_id = 12734
- AND schedule_on = '2019-08-08'
- (141.6ms) INSERT INTO buffer_rule_calc_schedules_1511818252
- SET staff_id = 20739,
- call_type_id = 12734,
- schedule_on = '2019-08-08',
- day_of_week_mask = 16
- (148.7ms) /* NegativeLinkRule */
- UPDATE buffer_negative_relations_1511818252
- SET staff_id = 20739
- WHERE affected_by_schedule_id = (
- SELECT id
- FROM buffer_schedules_1511818252
- WHERE schedule_on = '2019-08-08'
- AND call_type_id = 12734
- )
- (162.9ms) /* SpecializationOverlapRule */
- update buffer_staff_specializations_1511818252 as st_sp
- inner join max_applicable_call_types as mact
- on st_sp.specialization_id = mact.specialization_id
- and mact.call_type_id = 12734
- inner join buffer_specialization_daily_counts_1511818252 as sp_dc
- on st_sp.specialization_id = sp_dc.specialization_id
- and sp_dc.staff_id is null
- and sp_dc.schedule_on = '2019-08-08'
- left join buffer_specialization_daily_counts_1511818252 as sp_dc_2
- on st_sp.specialization_id = sp_dc_2.specialization_id
- and st_sp.staff_id = sp_dc_2.staff_id
- and sp_dc_2.schedule_on = '2019-08-08'
- set sp_dc.staffs_scheduled = sp_dc.staffs_scheduled + 1
- where st_sp.staff_id = 20739
- and sp_dc_2.id is null
- (152.4ms) insert into buffer_specialization_daily_counts_1511818252 (
- specialization_id, staff_id, schedule_on, staffs_scheduled, max_scheduled, should_be_evaluated
- )
- select sp.id as specialization_id,
- 20739 as staff_id,
- '2019-08-08' as schedule_on,
- 1 as staffs_scheduled,
- sp.max_scheduled,
- sp_dc.should_be_evaluated
- from buffer_staff_specializations_1511818252 as st_sp
- inner join specializations as sp
- on st_sp.specialization_id = sp.id
- inner join max_applicable_call_types as mact
- on st_sp.specialization_id = mact.specialization_id
- and mact.call_type_id = 12734
- inner join buffer_specialization_daily_counts_1511818252 as sp_dc
- on st_sp.specialization_id = sp_dc.specialization_id
- and sp_dc.staff_id is null
- and sp_dc.schedule_on = '2019-08-08'
- left join buffer_specialization_daily_counts_1511818252 as sp_dc_2
- on st_sp.specialization_id = sp_dc_2.specialization_id
- and st_sp.staff_id = sp_dc_2.staff_id
- and sp_dc_2.schedule_on = '2019-08-08'
- where st_sp.staff_id = 20739
- and sp_dc_2.id is null
- (155.5ms) /* MaxAssignmentsRule */
- delete from buffer_linkage_call_type_assignments_1511818252
- where linkage_instance_id = 15201931;
- (154.9ms) /* MaxAssignmentsRule */
- update
- buffer_schedules_1511818252 as sc
- inner join call_types as ct
- on sc.call_type_id = ct.id
- and ct.active = 1
- inner join buffer_call_type_assignments_1511818252 as cta
- on sc.staff_id = cta.staff_id
- and sc.call_type_id = cta.call_type_id
- and sc.is_weekend = cta.is_weekend
- and sc.period_offset = cta.period_offset
- and sc.calendar_schedule_id = cta.calendar_schedule_id
- set cta.assignments_count = cta.assignments_count + 1
- where
- sc.schedule_on = '2019-08-08'
- and sc.call_type_id = 12734
- and sc.staff_id = 20739
- (147.5ms) /* UnassignedDaysRule */
- delete from buffer_linkage_assigned_days_1511818252
- where linkage_instance_id = 15201931
- (147.3ms) /* UnassignedDaysRule */
- UPDATE buffer_staff_assigned_days_1511818252 as sad
- inner join call_types as ct
- on ct.id = 12734
- and ct.unassigned_day = 0
- SET sad.is_assigned = 1
- WHERE sad.staff_id = 20739
- AND sad.schedule_on = '2019-08-08'
- (455.3ms) delete
- from buffer_linkage_assignment_limits_1511818252
- where
- staff_id = 20739
- and linkage_instance_id = 15201931
- (610.4ms) insert into buffer_staff_assignment_limits_1511818252 (
- staff_id,
- assignment_limit_id,
- period_id,
- consecutive_days_mask,
- current_value
- )
- select
- sc.staff_id,
- al.id as assignment_limit_id,
- alp.id as period_id,
- case
- when (alp.limit_subtype_mask = 8 /* consecutive */) then
- (1 << datediff(sc.schedule_on, alp.start_date))
- else 0
- end as consecutive_days_mask,
- case
- when (al.limit_type = 0 /* assignments */) then 1.0
- when (al.limit_type = 1 /* points */) then ci.points
- when (al.limit_type = 2 /* hours */) then ci.hours
- else 0
- end as current_value
- from
- buffer_schedules_1511818252 as sc
- inner join buffer_assignment_limit_call_types_1511818252 as alct
- on sc.call_type_id = alct.call_type_id
- inner join buffer_assignment_limits_1511818252 as al
- on alct.assignment_limit_id = al.id
- and (sc.day_of_week_mask & al.considered_days_of_week_mask) > 0
- inner join buffer_assignment_limit_staffs_1511818252 as als
- on al.id = als.assignment_limit_id
- and sc.staff_id = als.staff_id
- inner join assign_staff_types as ast
- on sc.staff_id = ast.staff_id
- and sc.schedule_on between ast.begin_date and coalesce(ast.end_date, '9999-12-31')
- inner join buffer_assignment_limit_staff_types_1511818252 as alst
- on al.id = alst.assignment_limit_id
- and ast.staff_type_id = alst.staff_type_id
- inner join buffer_assignment_limit_periods_1511818252 as alp
- on al.id = alp.assignment_limit_id
- and sc.schedule_on between alp.start_date and alp.end_date
- inner join buffer_counter_increments_1511818252 as ci
- on sc.id = ci.schedule_id
- where
- sc.schedule_on = '2019-08-08'
- and sc.call_type_id = 12734
- and sc.staff_id = 20739
- on duplicate key update
- consecutive_days_mask = consecutive_days_mask | values(consecutive_days_mask),
- current_value = current_value + values(current_value)
- INFO : (02-15 13:34:30) scheduled for: plan unit: [id:15201931] [2019-08-08 - SSGE], Ron Dobrovinsky. DEPTH(6)
- (145.3ms) select
- coalesce(max(
- case
- when (ct.max_weekday_assignments > 0) then 1
- else 0
- end
- ), 0) as weekday_flag,
- coalesce(max(
- case
- when (ct.max_weekend_assignments > 0) then 1
- else 0
- end
- ), 0) as weekend_flag
- from
- buffer_auto_populate_slots_1511818252 as aps
- inner join call_types as ct
- on aps.call_type_id = ct.id
- (152.5ms) /* NegativeLinkRule */
- delete ca
- from buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_negative_relations_1511818252 as nr use index (ix_buffer_negative_relations_composite_1)
- on ca.schedule_id = nr.schedule_id
- and ca.staff_id = nr.staff_id
- (147.1ms) /* SpecializationOverlapRule */
- delete ca
- from buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_staff_specializations_1511818252 as ssp
- on ca.staff_id = ssp.staff_id
- inner join max_applicable_call_types as mact
- on ssp.specialization_id = mact.specialization_id
- and sc.call_type_id = mact.call_type_id
- inner join buffer_specialization_daily_counts_1511818252 as sdc use index (ix_buffer_specialization_daily_counts_composite_1)
- on ssp.specialization_id = sdc.specialization_id
- and sc.schedule_on = sdc.schedule_on
- and sdc.staff_id is null
- left join buffer_specialization_daily_counts_1511818252 as sdc_2 use index (ix_buffer_specialization_daily_counts_composite_1)
- on ssp.specialization_id = sdc_2.specialization_id
- and sc.schedule_on = sdc_2.schedule_on
- and ca.staff_id = sdc_2.staff_id
- where sdc.should_be_evaluated = 1
- and (sdc.staffs_scheduled + if(sdc_2.id is null, 1, 0)) > sdc.max_scheduled
- (441.2ms) /* BrokenLinkageRule */
- truncate table buffer_combined_availability_linkages_1511818252
- (520.8ms) insert into buffer_combined_availability_linkages_1511818252 (
- staff_id,
- linkage_instance_id,
- slots_count,
- is_primary,
- has_violations
- )
- select
- staff_id,
- linkage_instance_id,
- count(1) as slots_count,
- min(is_primary) as is_primary,
- max(has_violations) as has_violations
- from buffer_combined_availabilities_1511818252 use index (ix_buffer_combined_availabilities_composite_2)
- group by
- staff_id,
- linkage_instance_id
- order by null
- (154.2ms) delete ca
- from
- buffer_combined_availabilities_1511818252 as ca use index (ix_buffer_combined_availabilities_composite_1)
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_linkages_1511818252 as l
- on sc.linkage_instance_id = l.linkage_instance_id
- inner join buffer_combined_availability_linkages_1511818252 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
- on ca.staff_id = ls_1.staff_id
- and sc.linkage_instance_id = ls_1.linkage_instance_id
- left join buffer_schedule_linkages_1511818252 as ls_2 use index (ix_buffer_schedule_linkages_composite_1)
- on ca.staff_id = ls_2.staff_id
- and sc.linkage_instance_id = ls_2.linkage_instance_id
- where (ls_1.slots_count + coalesce(ls_2.slots_count, 0)) < l.slots_count_total /* not covering the whole chain */;
- (195.0ms) select straight_join
- sc.schedule_on,
- sc.call_type_id,
- count(distinct ca.staff_id) as available_members_count,
- group_concat(
- distinct concat(if(ls_1.is_primary = 1, 'p', 's'), ca.staff_id)
- order by ls_1.is_primary desc, ca.staff_id
- separator ', '
- ) as available_members_ids,
- sc.linkage_instance_id,
- l.slots_count_total as linkage_slots_count
- from buffer_combined_availabilities_1511818252 as ca
- inner join buffer_schedules_1511818252 as sc
- on ca.schedule_id = sc.id
- inner join buffer_linkages_1511818252 as l
- on sc.linkage_instance_id = l.linkage_instance_id
- inner join buffer_combined_availability_linkages_1511818252 as ls_1 use index (ix_buffer_combined_availability_linkages_composite_1)
- on ca.staff_id = ls_1.staff_id
- and sc.linkage_instance_id = ls_1.linkage_instance_id
- and ls_1.has_violations = 0
- where sc.should_be_evaluated = 1
- and sc.should_be_populated = 1
- group by sc.schedule_on, sc.call_type_id, sc.linkage_instance_id, l.slots_count_total
- order by available_members_count, sc.schedule_on, sc.display_order
- limit 1
- (150.3ms) truncate table buffer_rule_scores_1511818252
- (145.7ms) truncate table buffer_rule_calc_filters_1511818252
- (536.1ms) insert into buffer_rule_calc_filters_1511818252 (
- linkage_instance_id,
- staff_id
- ) values (18201931, 20739)
- (149.1ms) truncate table buffer_rule_scores_with_corrections_1511818252
- (140.7ms) insert into buffer_rule_scores_with_corrections_1511818252 (
- linkage_instance_id, schedule_id, staff_id, rule_name, value
- )
- select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id, rule_scores.rule_name,
- ifnull(rule_scores.value, max_values.max_value + 1) as value
- from buffer_rule_scores_1511818252 as rule_scores
- inner join (
- select rule_name, max(value) as max_value
- from buffer_rule_scores_1511818252
- group by rule_name
- order by null
- ) as max_values
- on rule_scores.rule_name = max_values.rule_name
- order by null
- (141.1ms) select linkage_instance_id, staff_id, avg(slot_scores) as scores
- from (
- select rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id,
- sum(
- if((total_values.total_value > 0), (rule_scores.value / total_values.total_value), 0) *
- rules.weight *
- total_values.slots_count
- ) as slot_scores
- from buffer_rule_scores_with_corrections_1511818252 as rule_scores
- inner join (
- select rule_name, sum(abs(value)) as total_value,
- count(distinct schedule_id) as slots_count
- from buffer_rule_scores_with_corrections_1511818252
- group by rule_name
- order by null
- ) as total_values
- on rule_scores.rule_name = total_values.rule_name
- inner join rules
- on rule_scores.rule_name = rules.type
- where rules.rule_set_id = 1538
- and rules.applied = 1
- group by rule_scores.linkage_instance_id, rule_scores.schedule_id, rule_scores.staff_id
- order by null
- ) as staff_scores
- group by linkage_instance_id, staff_id
- order by round(avg(slot_scores), 5) desc, rand()
- limit 1
- WARN : (02-15 13:34:33) No score found. Using fake score...
- **Airbrake: closed
Add Comment
Please, Sign In to add comment