Refactor satisfaction update logic in DirectorWorker: Simplified the SQL query for updating director satisfaction by introducing a common table expression (CTE) for updated satisfaction values. This change enhances readability and maintains the integrity of satisfaction updates while ensuring accurate data retrieval from both new and adjusted income calculations.
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 2m23s
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 2m23s
This commit is contained in:
@@ -646,8 +646,7 @@ WITH adjusted_income AS (
|
|||||||
GROUP BY d.id, d.employer_user_id, c.title_of_nobility
|
GROUP BY d.id, d.employer_user_id, c.title_of_nobility
|
||||||
)
|
)
|
||||||
UPDATE falukant_data.director d
|
UPDATE falukant_data.director d
|
||||||
SET income = des.desired_income,
|
SET income = des.desired_income
|
||||||
updated_at = NOW()
|
|
||||||
FROM desired des
|
FROM desired des
|
||||||
WHERE d.id = des.id
|
WHERE d.id = des.id
|
||||||
AND d.income IS DISTINCT FROM des.desired_income
|
AND d.income IS DISTINCT FROM des.desired_income
|
||||||
@@ -686,16 +685,18 @@ new_sats AS (
|
|||||||
END
|
END
|
||||||
)::int AS new_satisfaction
|
)::int AS new_satisfaction
|
||||||
FROM salary_gap sg
|
FROM salary_gap sg
|
||||||
)
|
),
|
||||||
|
updated_satisfaction AS (
|
||||||
UPDATE falukant_data.director dir
|
UPDATE falukant_data.director dir
|
||||||
SET satisfaction = ns.new_satisfaction
|
SET satisfaction = ns.new_satisfaction
|
||||||
FROM new_sats ns
|
FROM new_sats ns
|
||||||
WHERE dir.id = ns.id
|
WHERE dir.id = ns.id
|
||||||
AND dir.satisfaction IS DISTINCT FROM ns.new_satisfaction
|
AND dir.satisfaction IS DISTINCT FROM ns.new_satisfaction
|
||||||
RETURNING dir.employer_user_id
|
RETURNING dir.employer_user_id
|
||||||
|
)
|
||||||
|
SELECT employer_user_id FROM updated_satisfaction
|
||||||
UNION
|
UNION
|
||||||
SELECT ai.employer_user_id
|
SELECT employer_user_id FROM adjusted_income;
|
||||||
FROM adjusted_income ai;
|
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
pub const QUERY_GET_DIRECTOR_USER: &str = r#"
|
pub const QUERY_GET_DIRECTOR_USER: &str = r#"
|
||||||
|
|||||||
Reference in New Issue
Block a user