Füge SQL-Abfragen für politische Ämter hinzu und implementiere Normalisierung bestehender Ämter
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 4m1s
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 4m1s
This commit is contained in:
@@ -1412,6 +1412,41 @@ pub const QUERY_PROCESS_ELECTIONS: &str = r#"
|
||||
FROM falukant_data.process_elections();
|
||||
"#;
|
||||
|
||||
/// Aktuelle politische Ämter eines Charakters; die Rangfolge wird im Daemon
|
||||
/// einheitlich über `political_office_name_rank` bestimmt.
|
||||
pub const QUERY_GET_POLITICAL_OFFICES_FOR_CHARACTER: &str = r#"
|
||||
SELECT po.id AS office_id,
|
||||
po.office_type_id,
|
||||
COALESCE(pot.name, '') AS office_name
|
||||
FROM falukant_data.political_office po
|
||||
JOIN falukant_type.political_office_type pot ON pot.id = po.office_type_id
|
||||
WHERE po.character_id = $1::int;
|
||||
"#;
|
||||
|
||||
pub const QUERY_GET_ALL_POLITICAL_OFFICES: &str = r#"
|
||||
SELECT po.id AS office_id,
|
||||
po.character_id,
|
||||
po.office_type_id,
|
||||
COALESCE(pot.name, '') AS office_name
|
||||
FROM falukant_data.political_office po
|
||||
JOIN falukant_type.political_office_type pot ON pot.id = po.office_type_id
|
||||
ORDER BY po.character_id, po.id;
|
||||
"#;
|
||||
|
||||
/// Entfernt ein einzelnes Amt bei Beförderung bzw. unzulässiger niedriger Wahl
|
||||
/// und schreibt es wie alle regulären Amtsenden in die Historie.
|
||||
pub const QUERY_REMOVE_POLITICAL_OFFICE_BY_ID: &str = r#"
|
||||
WITH removed AS (
|
||||
DELETE FROM falukant_data.political_office
|
||||
WHERE id = $1::int
|
||||
RETURNING character_id, office_type_id, region_id, created_at
|
||||
)
|
||||
INSERT INTO falukant_log.political_office_history
|
||||
(character_id, office_type_id, region_id, start_date, end_date, created_at, updated_at)
|
||||
SELECT character_id, office_type_id, region_id, created_at, NOW(), NOW(), NOW()
|
||||
FROM removed;
|
||||
"#;
|
||||
|
||||
/// Wahlergebnis für Spieler-Kandidaten (`falukant_data.candidate` + `character.user_id IS NOT NULL`).
|
||||
/// Läuft nach `process_elections()`; Deduplizierung über bestehende `election_result`-Notifications (`tr` JSON).
|
||||
pub const QUERY_PLAYER_ELECTION_RESULT_ROWS: &str = r#"
|
||||
|
||||
Reference in New Issue
Block a user