поправил расчет средних показателей в обжалованиях
This commit is contained in:
parent
b06b79560d
commit
6b93e4ea29
6 changed files with 34 additions and 26 deletions
|
|
@ -259,8 +259,8 @@ WHERE recording_date = current_date
|
|||
<sql>SELECT
|
||||
COALESCE(SUM(total_appeals), 0) total_appeals,
|
||||
COALESCE(SUM(resolved), 0) resolved,
|
||||
COALESCE(SUM(average_consideration), 0) average_consideration,
|
||||
COALESCE(SUM(average_rating), 0) average_rating,
|
||||
COALESCE(ROUND(AVG(average_consideration) FILTER (where average_consideration!=0),1), 0) average_consideration,
|
||||
COALESCE(ROUND(AVG(average_rating)FILTER (where average_rating!=0),1), 0) average_rating,
|
||||
COALESCE(SUM(average_to_face), 0) average_to_face,
|
||||
COALESCE(SUM("average_EPGU"), 0) average_epgu,
|
||||
COALESCE(
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ WHERE recording_date = current_date
|
|||
<limit>0</limit>
|
||||
<sql>SELECT
|
||||
COALESCE(SUM(total_appeals), 0) total_appeals,
|
||||
COALESCE(SUM(average_consideration), 0) average_consideration,
|
||||
coalesce(ROUND(avg(average_consideration) FILTER (where average_consideration!=0),1),0) as average_consideration,
|
||||
COALESCE(SUM(resolved), 0) resolved,
|
||||
COALESCE(SUM(not_resolved), 0) not_resolved,
|
||||
COALESCE(
|
||||
|
|
@ -275,7 +275,7 @@ WHERE recording_date = current_date
|
|||
0
|
||||
) not_resolved_percent,
|
||||
|
||||
COALESCE(SUM(average_rating), 0) average_rating,
|
||||
coalesce(ROUND(avg(average_rating) FILTER (where average_rating!=0),1),0) as average_rating,
|
||||
COALESCE(
|
||||
CASE
|
||||
WHEN SUM(total_appeals) > 0
|
||||
|
|
|
|||
|
|
@ -293,8 +293,8 @@ WHERE recording_date = current_date
|
|||
<sql>SELECT
|
||||
COALESCE(SUM(total_appeals), 0) total_appeals,
|
||||
COALESCE(SUM(resolved), 0) resolved,
|
||||
COALESCE(SUM(average_consideration), 0) average_consideration,
|
||||
COALESCE(SUM(average_rating), 0) average_rating,
|
||||
COALESCE(ROUND(AVG(average_consideration) FILTER (where average_consideration!=0),1), 0) average_consideration,
|
||||
COALESCE(ROUND(AVG(average_rating)FILTER (where average_rating!=0),1), 0) average_rating,
|
||||
COALESCE(SUM(average_to_face), 0) average_to_face,
|
||||
COALESCE(SUM("average_EPGU"), 0) average_epgu,
|
||||
COALESCE(
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ WHERE recording_date = current_date
|
|||
<limit>0</limit>
|
||||
<sql>SELECT
|
||||
COALESCE(SUM(total_appeals), 0) total_appeals,
|
||||
COALESCE(SUM(average_consideration), 0) average_consideration,
|
||||
coalesce(ROUND(avg(average_consideration) FILTER (where average_consideration!=0),1),0) as average_consideration,
|
||||
COALESCE(SUM(resolved), 0) resolved,
|
||||
COALESCE(SUM(not_resolved), 0) not_resolved,
|
||||
COALESCE(
|
||||
|
|
@ -304,7 +304,7 @@ WHERE recording_date = current_date
|
|||
0
|
||||
) not_resolved_percent,
|
||||
|
||||
COALESCE(SUM(average_rating), 0) average_rating,
|
||||
coalesce(ROUND(avg(average_rating) FILTER (where average_rating!=0),1),0) as average_rating,
|
||||
COALESCE(
|
||||
CASE
|
||||
WHEN SUM(total_appeals) > 0
|
||||
|
|
|
|||
|
|
@ -361,7 +361,7 @@ aggregated_data AS (
|
|||
ELSE NULL
|
||||
END), 1) AS average_consideration,
|
||||
-- Средний рейтинг, учитывая 0 для некорректных значений
|
||||
ROUND(AVG(COALESCE(response_evalution, 0)), 1) AS average_rating,
|
||||
ROUND(AVG(response_evalution), 1) AS average_rating,
|
||||
COUNT(*) FILTER (WHERE source = 'ПОС') AS total_pos,
|
||||
COUNT(*) FILTER (WHERE source = 'ЕПГУ') AS total_epgu
|
||||
FROM base_data
|
||||
|
|
|
|||
|
|
@ -159,25 +159,21 @@ WHERE recording_date = current_date
|
|||
<condition>=</condition>
|
||||
<field>recruitment_id</field>
|
||||
<name>recruitment_id</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>schema</field>
|
||||
<name>schema</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>spring_autumn</field>
|
||||
<name>spring_autumn</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<key>
|
||||
<condition>=</condition>
|
||||
<field>recording_date</field>
|
||||
<name>recording_date</name>
|
||||
<name2/>
|
||||
</key>
|
||||
<schema>recruitment_campaign</schema>
|
||||
<table>appeals</table>
|
||||
|
|
@ -309,12 +305,12 @@ WHERE recording_date = current_date
|
|||
<limit>0</limit>
|
||||
<sql>WITH
|
||||
ids AS (
|
||||
SELECT unnest(string_to_array(trim(both '{}' from '${ARR_REG}'), ','))::uuid AS recruitment_id
|
||||
SELECT unnest(string_to_array(trim(both '{}' from '${ARR_REG}'), ','))::uuid AS recruitment_id
|
||||
),
|
||||
base_data AS (
|
||||
SELECT
|
||||
region_id,
|
||||
solution_type,
|
||||
solution_type,
|
||||
CASE
|
||||
WHEN incoming_date <> '-' THEN incoming_date::date
|
||||
ELSE NULL
|
||||
|
|
@ -346,16 +342,17 @@ aggregated_data AS (
|
|||
ELSE NULL
|
||||
END), 1) AS average_consideration,
|
||||
-- Средний рейтинг, учитывая 0 для некорректных значений
|
||||
ROUND(AVG(COALESCE(response_evalution, 0)), 1) AS average_rating
|
||||
--COUNT(*) FILTER (WHERE source = 'ПОС') AS total_pos,
|
||||
--COUNT(*) FILTER (WHERE source = 'ЕПГУ') AS total_epgu
|
||||
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
|
||||
)
|
||||
GROUP BY region_id, incoming_date
|
||||
), agr2 as (
|
||||
SELECT
|
||||
i.recruitment_id,
|
||||
current_date AS recording_date,
|
||||
'Весна' AS spring_autumn,
|
||||
COALESCE(spring_autumn, 'undefined') as spring_autumn,
|
||||
'Organization' AS schema,
|
||||
COALESCE(ad.total_appeals, 0) AS total_appeals,
|
||||
COALESCE(ad.resolved, 0) AS resolved,
|
||||
|
|
@ -364,12 +361,23 @@ SELECT
|
|||
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
|
||||
--COALESCE(ad.total_pos, 0) AS average_to_face,
|
||||
--COALESCE(ad.total_epgu, 0) AS average_epgu,
|
||||
--COALESCE(ROUND(ad.total_pos::NUMERIC * 100 / NULLIF(ad.total_appeals, 0), 1), 0) AS average_to_face_percent,
|
||||
--COALESCE(ROUND(ad.total_epgu::NUMERIC * 100 / NULLIF(ad.total_appeals, 0), 1), 0) AS average_epgu_percent
|
||||
FROM ids i
|
||||
LEFT JOIN aggregated_data ad ON ad.recruitment_id = i.recruitment_id;</sql>
|
||||
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;</sql>
|
||||
<variables_active>Y</variables_active>
|
||||
<attributes/>
|
||||
<GUI>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue