multiple fixes
Some checks failed
Deploy yourpart (blue-green) / deploy (push) Has been cancelled

This commit is contained in:
Torsten Schulz (local)
2026-06-22 16:17:20 +02:00
parent 41c0e5a6f2
commit 6ed88f7ad7
2 changed files with 31 additions and 135 deletions

View File

@@ -2161,13 +2161,7 @@ pub const QUERY_TRY_MARRIAGE_CONCEPTION_UPDATE: &str = r#"
CASE WHEN c1.gender = 'male' THEN c1.region_id ELSE c2.region_id END AS region_id,
CASE WHEN c1.gender = 'male' THEN fu1.id ELSE fu2.id END AS father_uid,
CASE WHEN c1.gender = 'female' THEN fu1.id ELSE fu2.id END AS mother_uid,
(CURRENT_DATE - c_female.birthdate::date)::int AS mother_age_days,
(
SELECT COUNT(*)::int
FROM falukant_data.child_relation cr
WHERE cr.father_character_id = (CASE WHEN c1.gender = 'male' THEN c1.id ELSE c2.id END)
AND cr.mother_character_id = (CASE WHEN c1.gender = 'female' THEN c1.id ELSE c2.id END)
) AS shared_children_count
(CURRENT_DATE - c_female.birthdate::date)::int AS mother_age_days
FROM falukant_data.relationship r
JOIN falukant_type.relationship r2
ON r2.id = r.relationship_type_id AND r2.tr = 'married'
@@ -2194,58 +2188,13 @@ pub const QUERY_TRY_MARRIAGE_CONCEPTION_UPDATE: &str = r#"
p.father_uid,
p.mother_uid,
p.mother_age_days,
p.shared_children_count,
CASE
WHEN p.mother_age_days < 4380 THEN 0.005
WHEN p.mother_age_days < 4745 THEN 0.30
WHEN p.mother_age_days < 5110 THEN 0.45
WHEN p.mother_age_days < 5475 THEN 0.55
WHEN p.mother_age_days < 5840 THEN 0.60
WHEN p.mother_age_days < 6205 THEN 0.725
WHEN p.mother_age_days < 6570 THEN 0.80
WHEN p.mother_age_days < 7305 THEN 0.855
WHEN p.mother_age_days < 9125 THEN 0.875
WHEN p.mother_age_days < 10950 THEN 0.84
WHEN p.mother_age_days < 11315 THEN 0.785
WHEN p.mother_age_days < 11680 THEN 0.765
WHEN p.mother_age_days < 12045 THEN 0.74
WHEN p.mother_age_days < 12410 THEN 0.72
WHEN p.mother_age_days < 12775 THEN 0.695
WHEN p.mother_age_days < 13140 THEN 0.65
WHEN p.mother_age_days < 13505 THEN 0.63
WHEN p.mother_age_days < 13870 THEN 0.60
WHEN p.mother_age_days < 14235 THEN 0.55
WHEN p.mother_age_days < 14600 THEN 0.50
WHEN p.mother_age_days < 14965 THEN 0.45
WHEN p.mother_age_days < 15330 THEN 0.35
WHEN p.mother_age_days < 15695 THEN 0.25
WHEN p.mother_age_days < 16060 THEN 0.15
WHEN p.mother_age_days < 16425 THEN 0.075
WHEN p.mother_age_days < 16790 THEN 0.03
WHEN p.mother_age_days < 17155 THEN 0.02
WHEN p.mother_age_days < 17520 THEN 0.015
WHEN p.mother_age_days < 18250 THEN 0.005
ELSE 0.001
END AS prob_year_raw
0.72::float AS prob_year
FROM paired p
),
mother_age_final AS (
SELECT
ma.*,
CASE
WHEN ma.shared_children_count = 0
AND ma.mother_age_days >= 6570
AND ma.mother_age_days < 16000
THEN GREATEST(ma.prob_year_raw, 1.0)
ELSE ma.prob_year_raw
END AS prob_year
FROM mother_age ma
),
conceivable AS (
SELECT ma.relationship_id
FROM mother_age_final ma
WHERE ma.mother_age_days >= 4380
AND ma.mother_age_days < 18993
FROM mother_age ma
WHERE ma.mother_age_days >= 5110
AND random() < ma.prob_year
)
UPDATE falukant_data.relationship r
@@ -2275,13 +2224,7 @@ pub const QUERY_GET_LEGACY_MARRIAGE_INSTANT_PREGNANCY_CANDIDATES: &str = r#"
CASE WHEN c1.gender = 'male' THEN c1.region_id ELSE c2.region_id END AS region_id,
CASE WHEN c1.gender = 'male' THEN fu1.id ELSE fu2.id END AS father_uid,
CASE WHEN c1.gender = 'female' THEN fu1.id ELSE fu2.id END AS mother_uid,
(CURRENT_DATE - c_female.birthdate::date)::int AS mother_age_days,
(
SELECT COUNT(*)::int
FROM falukant_data.child_relation cr
WHERE cr.father_character_id = (CASE WHEN c1.gender = 'male' THEN c1.id ELSE c2.id END)
AND cr.mother_character_id = (CASE WHEN c1.gender = 'female' THEN c1.id ELSE c2.id END)
) AS shared_children_count
(CURRENT_DATE - c_female.birthdate::date)::int AS mother_age_days
FROM falukant_data.relationship r
JOIN falukant_type.relationship r2
ON r2.id = r.relationship_type_id AND r2.tr = 'married'
@@ -2312,52 +2255,8 @@ pub const QUERY_GET_LEGACY_MARRIAGE_INSTANT_PREGNANCY_CANDIDATES: &str = r#"
p.father_uid,
p.mother_uid,
p.mother_age_days,
p.shared_children_count,
CASE
WHEN p.mother_age_days < 4380 THEN 0.005
WHEN p.mother_age_days < 4745 THEN 0.30
WHEN p.mother_age_days < 5110 THEN 0.45
WHEN p.mother_age_days < 5475 THEN 0.55
WHEN p.mother_age_days < 5840 THEN 0.60
WHEN p.mother_age_days < 6205 THEN 0.725
WHEN p.mother_age_days < 6570 THEN 0.80
WHEN p.mother_age_days < 7305 THEN 0.855
WHEN p.mother_age_days < 9125 THEN 0.875
WHEN p.mother_age_days < 10950 THEN 0.84
WHEN p.mother_age_days < 11315 THEN 0.785
WHEN p.mother_age_days < 11680 THEN 0.765
WHEN p.mother_age_days < 12045 THEN 0.74
WHEN p.mother_age_days < 12410 THEN 0.72
WHEN p.mother_age_days < 12775 THEN 0.695
WHEN p.mother_age_days < 13140 THEN 0.65
WHEN p.mother_age_days < 13505 THEN 0.63
WHEN p.mother_age_days < 13870 THEN 0.60
WHEN p.mother_age_days < 14235 THEN 0.55
WHEN p.mother_age_days < 14600 THEN 0.50
WHEN p.mother_age_days < 14965 THEN 0.45
WHEN p.mother_age_days < 15330 THEN 0.35
WHEN p.mother_age_days < 15695 THEN 0.25
WHEN p.mother_age_days < 16060 THEN 0.15
WHEN p.mother_age_days < 16425 THEN 0.075
WHEN p.mother_age_days < 16790 THEN 0.03
WHEN p.mother_age_days < 17155 THEN 0.02
WHEN p.mother_age_days < 17520 THEN 0.015
WHEN p.mother_age_days < 18250 THEN 0.005
ELSE 0.001
END AS prob_year_raw
0.72::float AS prob_year
FROM paired p
),
mother_age_final AS (
SELECT
ma.*,
CASE
WHEN ma.shared_children_count = 0
AND ma.mother_age_days >= 6570
AND ma.mother_age_days < 16000
THEN GREATEST(ma.prob_year_raw, 1.0)
ELSE ma.prob_year_raw
END AS prob_year
FROM mother_age ma
)
SELECT
father_cid,
@@ -2369,9 +2268,8 @@ pub const QUERY_GET_LEGACY_MARRIAGE_INSTANT_PREGNANCY_CANDIDATES: &str = r#"
mother_uid,
mother_age_days,
prob_year * 100.0 AS prob_pct
FROM mother_age_final
WHERE mother_age_days >= 4380
AND mother_age_days < 18993
FROM mother_age
WHERE mother_age_days >= 5110
AND random() < prob_year;
"#;
@@ -3927,8 +3825,7 @@ pub const QUERY_GET_LOVER_PREGNANCY_CANDIDATES: &str = r#"
WHERE cr.mother_character_id = c_female.id
AND cr.created_at::date = CURRENT_DATE
)
AND (CURRENT_DATE - c_female.birthdate::date) >= 4380
AND (CURRENT_DATE - c_female.birthdate::date) < 18993
AND (CURRENT_DATE - c_female.birthdate::date) >= 5110
AND random() * 100.0 < (
LEAST(12.0, GREATEST(0.0,
CASE rs.lover_role
@@ -3939,11 +3836,6 @@ pub const QUERY_GET_LOVER_PREGNANCY_CANDIDATES: &str = r#"
END
+ CASE WHEN rs.affection >= 75 THEN 2.0 ELSE 0.0 END
+ CASE WHEN rs.visibility >= 70 AND rs.affection < 50 THEN -2.0 ELSE 0.0 END
+ CASE
WHEN (CURRENT_DATE - c_female.birthdate::date) > 14600
THEN -3.0
ELSE 0.0
END
))
);
"#;