main_dashboard.recruitment_campaign Y Normal 0 N 1000 100 - 2024/08/02 11:56:22.507 - 2024/08/02 11:56:22.507 Sort rows 2 2 Merge join 2 Y Sort rows 3 Merge join 2 Y Table input (person_registry) РФ/осень Sort rows 3 Y Table input (subpoena) РФ/осень Sort rows 2 2 Y Merge join 2 Insert / update (main_dashboard.recruitment_campaign) N Sort rows 2 2 2 Merge join 2 2 Y Sort rows 3 2 Merge join 2 2 Y Table input (subpoena) РФ/весна Sort rows 2 2 2 Y Merge join 2 2 Insert / update (main_dashboard.recruitment_campaign) 2 N Table input (person_registry) РФ/весна Sort rows 3 2 Y Get variables 2 2 Select values 2 2 Y Get variables 2 2 2 Select values 2 2 2 Y Merge join 2 Get variables 2 2 Y Select values 2 2 Insert / update (main_dashboard.recruitment_campaign) Y Merge join 2 2 Get variables 2 2 2 Y Select values 2 2 2 Insert / update (main_dashboard.recruitment_campaign) 2 Y Insert / update (main_dashboard.recruitment_campaign) InsertUpdate Y 1 none 100 ervu-dashboard = spring_autumn spring_autumn = recruitment_id REG_ID main_dashboard recruitment_campaign
subpoenas_sent count_subpoena Y appeared_on_subpoenas count_appeared Y not_appeared_on_subpoenas count_not_appeared Y new_recruits new_recruits Y postponement_have_right postponement_have_right Y postponement_granted postponement_granted Y appeared_on_subpoenas_percent appeared_on_subpoenas_percent Y not_appeared_on_subpoenas_percent not_appeared_on_subpoenas_percent Y postponement_have_right_percent postponement_have_right_percent Y postponement_granted_percent postponement_granted_percent Y recruitment_id recruitment_id N spring_autumn spring_autumn N
N 1360 128
Insert / update (main_dashboard.recruitment_campaign) 2 InsertUpdate Y 1 none 100 ervu-dashboard = spring_autumn spring_autumn = recruitment_id REG_ID main_dashboard recruitment_campaign
subpoenas_sent count_subpoena Y appeared_on_subpoenas count_appeared Y not_appeared_on_subpoenas count_not_appeared Y new_recruits new_recruits Y postponement_have_right postponement_have_right Y postponement_granted postponement_granted Y appeared_on_subpoenas_percent appeared_on_subpoenas_percent Y not_appeared_on_subpoenas_percent not_appeared_on_subpoenas_percent Y postponement_have_right_percent postponement_have_right_percent Y postponement_granted_percent postponement_granted_percent Y recruitment_id recruitment_id N spring_autumn spring_autumn N
N 1360 400
Merge join 2 MergeJoin Y 1 none FULL OUTER org org Sort rows 2 2 Sort rows 3 864 128 Merge join 2 2 MergeJoin Y 1 none FULL OUTER org org Sort rows 2 2 2 Sort rows 3 2 864 400 Sort rows 2 2 SortRows Y 1 none N %%java.io.tmpdir%% Y N N 0 org N 1000000 N 768 128 Sort rows 2 2 2 SortRows Y 1 none N %%java.io.tmpdir%% Y N N 0 org N 1000000 N 768 400 Sort rows 3 SortRows N 1 none N %%java.io.tmpdir%% Y N N 0 org N 1000000 N 752 240 Sort rows 3 2 SortRows N 1 none N %%java.io.tmpdir%% Y N N 0 org N 1000000 N 752 512 Table input (person_registry) РФ/весна TableInput Y 1 none ervu_person_registry N 0 SELECT 1 AS org, COUNT(*) FILTER ( WHERE EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 30 AND gender = 'MALE' -- мужчины от 18 до 30 лет AND (conscription IS NULL OR conscription = false) -- отсутствие отсрочки ) AS new_recruits, COUNT(*) FILTER ( WHERE conscription = true ) AS postponement_granted, ROUND(COUNT(*) FILTER (WHERE conscription = true) * 100.0 / NULLIF(COUNT(*) FILTER ( WHERE EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 30 AND gender = 'MALE' -- мужчины от 18 до 30 лет AND (conscription IS NULL OR conscription = false)), 0), 2) AS postponement_granted_percent FROM public.recruits AS r JOIN public.recruits_info AS ri ON ri.recruit_id = r.id WHERE r.vu_current_info ->> 'isMilitaryRegistered' = 'true' AND r.current_recruitment_id IS NOT NULL AND r.target_recruitment_id IS NOT NULL N 496 512 Table input (person_registry) РФ/осень TableInput Y 1 none ervu_person_registry N 0 SELECT 1 AS org, COUNT(*) FILTER ( WHERE EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 30 AND gender = 'MALE' -- мужчины от 18 до 30 лет AND (conscription IS NULL OR conscription = false) -- отсутствие отсрочки ) AS new_recruits, COUNT(*) FILTER ( WHERE conscription = true ) AS postponement_granted, ROUND(COUNT(*) FILTER (WHERE conscription = true) * 100.0 / NULLIF(COUNT(*) FILTER ( WHERE EXTRACT(YEAR FROM AGE(NOW(), birth_date)) BETWEEN 18 AND 30 AND gender = 'MALE' -- мужчины от 18 до 30 лет AND (conscription IS NULL OR conscription = false)), 0), 2) AS postponement_granted_percent FROM public.recruits AS r JOIN public.recruits_info AS ri ON ri.recruit_id = r.id WHERE r.vu_current_info ->> 'isMilitaryRegistered' = 'true' AND r.current_recruitment_id IS NOT NULL AND r.target_recruitment_id IS NOT NULL N 496 240 Table input (subpoena) РФ/весна TableInput Y 1 none postgres.subpoena N 0 WITH subpoena_data AS ( SELECT s.id AS subpoena_id, s.status_id, sr.type, ssh.code AS sub_stat_hist, s.send_date, sh.date_time::timestamp AS history_date, rdi.restriction_document_cancel_id AS restr_dc, rdi.applied_date AS ap_date, rdi.id AS rdi_id, ssi.delivery_code AS d_code, s.recruit_id, -- recruit_id добавляем, если есть sh.date_time FROM public.subpoena s JOIN public.subpoena_history AS sh ON sh.subpoena_id = s.id JOIN public.subpoena_status AS ss ON ss.id = s.status_id JOIN public.subpoena_status AS ssh ON ssh.id = sh.status_id JOIN public.subpoena_reason AS sr ON sr.id = s.reason_id LEFT JOIN public.restriction_document AS rd ON rd.subpoena_id = s.id LEFT JOIN public.restriction_document_item AS rdi ON rdi.restriction_document_create_id = rd.id LEFT JOIN public.subpoena_send_info AS ssi ON ssi.subpoena_id = s.id WHERE sr.type = '3' AND EXTRACT(YEAR FROM AGE(s.date_birth)) BETWEEN 18 AND 30 ), last_status_data AS ( -- Выбираем последнюю дату истории для каждой subpoena SELECT s.subpoena_id, MAX(s.history_date) AS last_history_date FROM subpoena_data s GROUP BY s.subpoena_id ), last_status AS ( -- Соединяем таблицу с максимальной датой и оригинальные данные, чтобы выбрать последние записи SELECT sd.* FROM subpoena_data sd JOIN last_status_data lsd ON sd.subpoena_id = lsd.subpoena_id AND sd.history_date = lsd.last_history_date ), t1 AS ( SELECT COUNT(DISTINCT subpoena_id) AS count_subpoena FROM last_status WHERE sub_stat_hist IS NOT NULL ), t2 AS ( SELECT COUNT(DISTINCT subpoena_id) AS count_appeared FROM last_status WHERE sub_stat_hist IN ('4.1', '4.2') ), t3 AS ( SELECT COUNT(DISTINCT subpoena_id) AS count_not_appeared FROM last_status WHERE sub_stat_hist in ('5', '5.1') ), t4 AS ( SELECT COUNT(DISTINCT recruit_id) AS new_recruits FROM subpoena_data ) SELECT t1.count_subpoena, t2.count_appeared, t3.count_not_appeared, ROUND(count_appeared * 100.0 / NULLIF(count_subpoena, 0), 2) AS appeared_on_subpoenas_percent, ROUND(count_not_appeared * 100.0 / NULLIF(count_subpoena, 0), 2) AS not_appeared_on_subpoenas_percent, -- t4.new_recruits, 0 AS postponement_have_right, -- 0 AS postponement_granted, 0 AS postponement_have_right_percent, -- 0 AS postponement_granted_percent, 'Весна' AS spring_autumn, '${REG_ID}' AS recruitment_id, 1 AS org FROM t1 JOIN t2 ON true JOIN t3 ON true JOIN t4 ON true; Y 496 400 Table input (subpoena) РФ/осень TableInput Y 1 none postgres.subpoena N 0 WITH subpoena_data AS ( SELECT s.id AS subpoena_id, s.status_id, sr.type, ssh.code AS sub_stat_hist, s.send_date, sh.date_time::timestamp AS history_date, rdi.restriction_document_cancel_id AS restr_dc, rdi.applied_date AS ap_date, rdi.id AS rdi_id, ssi.delivery_code AS d_code, s.recruit_id, -- recruit_id добавляем, если есть sh.date_time FROM public.subpoena s JOIN public.subpoena_history AS sh ON sh.subpoena_id = s.id JOIN public.subpoena_status AS ss ON ss.id = s.status_id JOIN public.subpoena_status AS ssh ON ssh.id = sh.status_id JOIN public.subpoena_reason AS sr ON sr.id = s.reason_id LEFT JOIN public.restriction_document AS rd ON rd.subpoena_id = s.id LEFT JOIN public.restriction_document_item AS rdi ON rdi.restriction_document_create_id = rd.id LEFT JOIN public.subpoena_send_info AS ssi ON ssi.subpoena_id = s.id WHERE sr.type = '3' -- статус изменен на 3 AND EXTRACT(YEAR FROM AGE(s.date_birth)) BETWEEN 18 AND 30 ), last_status_data AS ( -- Выбираем последнюю дату истории для каждой subpoena SELECT s.subpoena_id, MAX(s.history_date) AS last_history_date FROM subpoena_data s GROUP BY s.subpoena_id ), last_status AS ( -- Соединяем таблицу с максимальной датой и оригинальные данные, чтобы выбрать последние записи SELECT sd.* FROM subpoena_data sd JOIN last_status_data lsd ON sd.subpoena_id = lsd.subpoena_id AND sd.history_date = lsd.last_history_date ), t1 AS ( SELECT COUNT(DISTINCT subpoena_id) AS count_subpoena FROM last_status WHERE sub_stat_hist IS NOT NULL ), t2 AS ( SELECT COUNT(DISTINCT subpoena_id) AS count_appeared FROM last_status WHERE sub_stat_hist IN ('4.1', '4.2') ), t3 AS ( SELECT COUNT(DISTINCT subpoena_id) AS count_not_appeared FROM last_status WHERE sub_stat_hist in ('5', '5.1') -- добавлен статус 5.1 ), t4 AS ( SELECT COUNT(DISTINCT recruit_id) AS new_recruits FROM subpoena_data ) SELECT t1.count_subpoena, t2.count_appeared, t3.count_not_appeared, ROUND(count_appeared * 100.0 / NULLIF(count_subpoena, 0), 2) AS appeared_on_subpoenas_percent, ROUND(count_not_appeared * 100.0 / NULLIF(count_subpoena, 0), 2) AS not_appeared_on_subpoenas_percent, -- t4.new_recruits, 0 AS postponement_have_right, -- 0 AS postponement_granted, 0 AS postponement_have_right_percent, -- 0 AS postponement_granted_percent, 'Осень' AS spring_autumn, '${REG_ID}' AS recruitment_id, 1 AS org FROM t1 JOIN t2 ON true JOIN t3 ON true JOIN t4 ON true; Y 496 128 Get variables 2 2 GetVariable Y 1 none -1 REG_ID -1 none String -1 VK_ARRAY -1 none String 1008 208 Select values 2 2 SelectValues Y 1 none N REG_ID REG_ID String -2 -2 false false VK_ARRAY VK_ARRAY String -2 -2 false false 1216 208 Get variables 2 2 2 GetVariable Y 1 none -1 REG_ID -1 none String -1 VK_ARRAY -1 none String 1008 496 Select values 2 2 2 SelectValues Y 1 none N REG_ID REG_ID String -2 -2 false false VK_ARRAY VK_ARRAY String -2 -2 false false 1216 496