Enhance satisfaction update logic in DirectorWorker: Introduced an adjusted income calculation to update director incomes based on their wished income and auto-adjust settings. Modified the SQL query for satisfaction updates to include this new logic, ensuring accurate satisfaction calculations while maintaining existing functionality for directors not utilizing auto-adjust income.
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 1m36s
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 1m36s
This commit is contained in:
@@ -624,7 +624,15 @@ UPDATE falukant_data.director SET last_salary_payout = NOW() WHERE id = $1;
|
|||||||
"#;
|
"#;
|
||||||
|
|
||||||
pub const QUERY_UPDATE_SATISFACTION: &str = r#"
|
pub const QUERY_UPDATE_SATISFACTION: &str = r#"
|
||||||
WITH salary_gap AS (
|
WITH adjusted_income AS (
|
||||||
|
UPDATE falukant_data.director d
|
||||||
|
SET income = GREATEST(0, COALESCE(d.wished_income, d.income)),
|
||||||
|
updated_at = NOW()
|
||||||
|
WHERE COALESCE(d.auto_adjust_income, false) = true
|
||||||
|
AND d.income IS DISTINCT FROM GREATEST(0, COALESCE(d.wished_income, d.income))
|
||||||
|
RETURNING d.id, d.employer_user_id
|
||||||
|
),
|
||||||
|
salary_gap AS (
|
||||||
SELECT
|
SELECT
|
||||||
d.id,
|
d.id,
|
||||||
d.employer_user_id,
|
d.employer_user_id,
|
||||||
@@ -639,6 +647,7 @@ WITH salary_gap AS (
|
|||||||
FROM falukant_data.director d
|
FROM falukant_data.director d
|
||||||
JOIN falukant_data.knowledge k ON d.director_character_id = k.character_id
|
JOIN falukant_data.knowledge k ON d.director_character_id = k.character_id
|
||||||
JOIN falukant_data.character c ON c.id = d.director_character_id
|
JOIN falukant_data.character c ON c.id = d.director_character_id
|
||||||
|
WHERE COALESCE(d.auto_adjust_income, false) = false
|
||||||
GROUP BY d.id, d.employer_user_id, d.satisfaction, d.income, c.title_of_nobility
|
GROUP BY d.id, d.employer_user_id, d.satisfaction, d.income, c.title_of_nobility
|
||||||
),
|
),
|
||||||
new_sats AS (
|
new_sats AS (
|
||||||
@@ -662,7 +671,10 @@ UPDATE falukant_data.director dir
|
|||||||
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
|
||||||
|
UNION
|
||||||
|
SELECT ai.employer_user_id
|
||||||
|
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