Enhance income update logic in DirectorWorker: Introduced a nested SQL query to calculate desired income based on title of nobility and knowledge averages. Updated the income setting logic to utilize this calculated desired income, ensuring more accurate adjustments for directors with auto-adjust settings enabled.
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 1m30s
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 1m30s
This commit is contained in:
@@ -625,11 +625,32 @@ UPDATE falukant_data.director SET last_salary_payout = NOW() WHERE id = $1;
|
||||
|
||||
pub const QUERY_UPDATE_SATISFACTION: &str = r#"
|
||||
WITH adjusted_income AS (
|
||||
WITH desired AS (
|
||||
SELECT
|
||||
d.id,
|
||||
d.employer_user_id,
|
||||
GREATEST(
|
||||
0,
|
||||
ROUND(
|
||||
GREATEST(
|
||||
1.0,
|
||||
c.title_of_nobility::float8
|
||||
* POWER(1.231, AVG(k.knowledge) / 1.5)
|
||||
)
|
||||
)::int
|
||||
) AS desired_income
|
||||
FROM falukant_data.director d
|
||||
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
|
||||
WHERE COALESCE(d.auto_adjust_income, false) = true
|
||||
GROUP BY d.id, d.employer_user_id, c.title_of_nobility
|
||||
)
|
||||
UPDATE falukant_data.director d
|
||||
SET income = GREATEST(0, COALESCE(d.wished_income, d.income)),
|
||||
SET income = des.desired_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))
|
||||
FROM desired des
|
||||
WHERE d.id = des.id
|
||||
AND d.income IS DISTINCT FROM des.desired_income
|
||||
RETURNING d.id, d.employer_user_id
|
||||
),
|
||||
salary_gap AS (
|
||||
|
||||
Reference in New Issue
Block a user