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
|
||||
)
|
||||
UPDATE falukant_data.director d
|
||||
SET income = des.desired_income,
|
||||
updated_at = NOW()
|
||||
SET income = des.desired_income
|
||||
FROM desired des
|
||||
WHERE d.id = des.id
|
||||
AND d.income IS DISTINCT FROM des.desired_income
|
||||
@@ -686,16 +685,18 @@ new_sats AS (
|
||||
END
|
||||
)::int AS new_satisfaction
|
||||
FROM salary_gap sg
|
||||
),
|
||||
updated_satisfaction AS (
|
||||
UPDATE falukant_data.director dir
|
||||
SET satisfaction = ns.new_satisfaction
|
||||
FROM new_sats ns
|
||||
WHERE dir.id = ns.id
|
||||
AND dir.satisfaction IS DISTINCT FROM ns.new_satisfaction
|
||||
RETURNING dir.employer_user_id
|
||||
)
|
||||
UPDATE falukant_data.director dir
|
||||
SET satisfaction = ns.new_satisfaction
|
||||
FROM new_sats ns
|
||||
WHERE dir.id = ns.id
|
||||
AND dir.satisfaction IS DISTINCT FROM ns.new_satisfaction
|
||||
RETURNING dir.employer_user_id
|
||||
SELECT employer_user_id FROM updated_satisfaction
|
||||
UNION
|
||||
SELECT ai.employer_user_id
|
||||
FROM adjusted_income ai;
|
||||
SELECT employer_user_id FROM adjusted_income;
|
||||
"#;
|
||||
|
||||
pub const QUERY_GET_DIRECTOR_USER: &str = r#"
|
||||
|
||||
Reference in New Issue
Block a user