recruitment_campaign.appeals(reg) Y Normal 0 N 1000 100 - 2024/08/02 11:56:22.507 - 2024/08/02 11:56:22.507 Get variables 3 2 Select values 3 2 N Table input (appeal_document) регионы Get variables 3 2 N Select values 3 2 Insert / update (main_dashboard.appeals) N Execute SQL script Table input (appeal_document) регионы Y Insert / update (main_dashboard.appeals) Execute SQL script 2 Y Table input (appeal_document) регионы Insert / update (main_dashboard.appeals) Y Execute SQL script ExecSql N 1 none ervu-dashboard N N N N N DELETE FROM recruitment_campaign.appeals WHERE recording_date = current_date AND schema = 'Organization' 256 272 Execute SQL script 2 ExecSql N 1 none ervu-dashboard N N N N N DELETE FROM recruitment_campaign.appeals WHERE recording_date = current_date AND schema = 'REG_LVL' 1360 272 Get variables 3 2 GetVariable Y 1 none -1 REG_ID -1 none String -1 VK_ARRAY -1 none String 704 416 Insert / update (main_dashboard.appeals) InsertUpdate Y 1 none 100 ervu-dashboard = recruitment_id recruitment_id = schema schema = spring_autumn spring_autumn = recording_date recording_date recruitment_campaign appeals
total_appeals total_appeals Y average_consideration average_consideration Y resolved resolved Y not_resolved not_resolved Y not_resolved_percent not_resolved_percent Y average_rating average_rating Y resolved_percent resolved_percent Y recruitment_id recruitment_id N spring_autumn spring_autumn N schema schema N
N 1088 272
Select values 3 2 SelectValues Y 1 none N REG_ID REG_ID String -2 -2 false false VK_ARRAY VK_ARRAY String -2 -2 false false 848 416 Table input (appeal_document) регионы TableInput Y 1 none ervu-dashboard N 0 WITH ids AS ( SELECT unnest(string_to_array(trim(both '{}' from '${ARR_REG}'), ','))::uuid AS recruitment_id ), base_data AS ( SELECT region_id, solution_type, CASE WHEN incoming_date <> '-' THEN to_date(incoming_date, 'DD.MM.YYYY') ELSE NULL END AS incoming_date, CASE WHEN fact_end_date <> '-' THEN to_date(fact_end_date, 'DD.MM.YYYY') ELSE NULL END AS fact_end_date, CASE WHEN response_evalution <> '-' THEN response_evalution::NUMERIC -- оценка ответа заявителем ELSE 0 END AS response_evalution, source FROM appeals.appeals_list al WHERE region_id::uuid IN (SELECT recruitment_id FROM ids) ), aggregated_data AS ( SELECT region_id AS recruitment_id, COUNT(*) AS total_appeals, COUNT(*) FILTER (WHERE solution_type = 'Решено') AS resolved, COUNT(*) FILTER (WHERE solution_type != 'Решено') AS not_resolved, -- Среднее время рассмотрения, учитывая возможные NULL для дат ROUND(AVG(CASE WHEN fact_end_date IS NOT NULL AND incoming_date IS NOT NULL THEN fact_end_date::DATE - incoming_date::DATE ELSE NULL END), 1) AS average_consideration, -- Средний рейтинг, учитывая 0 для некорректных значений ROUND(AVG(response_evalution), 1) AS average_rating, CASE WHEN incoming_date between (extract (year from incoming_date)||'-04-01')::date and (extract (year from incoming_date)||'-09-30')::date then 'Весна' WHEN incoming_date between (extract (year from incoming_date)||'-10-01')::date and (extract (year from incoming_date)+1||'-03-31')::date then 'Осень' END AS spring_autumn FROM base_data GROUP BY region_id, incoming_date ), agr2 as ( SELECT i.recruitment_id, current_date AS recording_date, COALESCE(spring_autumn, 'undefined') as spring_autumn, 'Organization' AS schema, COALESCE(ad.total_appeals, 0) AS total_appeals, COALESCE(ad.resolved, 0) AS resolved, COALESCE(ad.not_resolved, 0) AS not_resolved, COALESCE(ad.average_consideration, 0) AS average_consideration, COALESCE(ad.average_rating, 0) AS average_rating, COALESCE(ROUND(ad.resolved::NUMERIC * 100 / NULLIF(ad.total_appeals, 0), 1), 0) AS resolved_percent, COALESCE(ROUND(ad.not_resolved::NUMERIC * 100 / NULLIF(ad.total_appeals, 0), 1), 0) AS not_resolved_percent FROM ids i LEFT JOIN aggregated_data ad ON ad.recruitment_id = i.recruitment_id ) SELECT recruitment_id, recording_date, spring_autumn, schema, sum(total_appeals) as total_appeals, sum(resolved) as resolved, sum(not_resolved) as not_resolved, coalesce(ROUND(avg(average_consideration) FILTER (where average_consideration!=0),1),0) as average_consideration, coalesce(ROUND(avg(average_rating) FILTER (where average_rating!=0),1),0) as average_rating, COALESCE(ROUND(sum(resolved::NUMERIC) * 100 / NULLIF(sum(total_appeals), 0), 1), 0) AS resolved_percent, COALESCE(ROUND(sum(not_resolved)::NUMERIC * 100 / NULLIF(sum(total_appeals), 0), 1), 0) AS not_resolved_percent from agr2 GROUP BY 1,2,3,4; Y 496 272