Füge UndergroundWorker hinzu und implementiere Logik für unterirdische Aufgaben. Aktualisiere CMakeLists.txt, um neue Quell- und Header-Dateien einzuschließen. Verbessere die Fehlerbehandlung in der Datenbank und sende Benachrichtigungen nach bestimmten Ereignissen. Integriere Hilfsfunktionen zur sicheren Verarbeitung von Daten.

This commit is contained in:
Torsten Schulz (local)
2025-08-31 23:11:09 +02:00
committed by Torsten (PC)
parent 1451225978
commit 23c07a3570
18 changed files with 1255 additions and 88 deletions

View File

@@ -451,6 +451,59 @@ private:
($1, 'notify_office_filled', NOW(), NOW());
)";
// ------------------------------------------------------------
// QUERY: Hole alle Benutzer, deren Amt in 2 Tagen abläuft
// ------------------------------------------------------------
static constexpr const char* QUERY_GET_USERS_WITH_EXPIRING_OFFICES = R"(
SELECT DISTINCT
ch.user_id
FROM
falukant_data.political_office AS po
JOIN
falukant_type.political_office_type AS pot
ON po.office_type_id = pot.id
JOIN
falukant_data."character" AS ch
ON po.character_id = ch.id
WHERE
ch.user_id IS NOT NULL
AND (po.created_at + (pot.term_length * INTERVAL '1 day'))
BETWEEN (NOW() + INTERVAL '2 days')
AND (NOW() + INTERVAL '2 days' + INTERVAL '1 second');
)";
// ------------------------------------------------------------
// QUERY: Hole alle Benutzer in Regionen mit neuen Wahlen
// ------------------------------------------------------------
static constexpr const char* QUERY_GET_USERS_IN_REGIONS_WITH_ELECTIONS = R"(
SELECT DISTINCT
ch.user_id
FROM
falukant_data.election AS e
JOIN
falukant_data."character" AS ch
ON ch.region_id = e.region_id
WHERE
ch.user_id IS NOT NULL
AND e."date" >= NOW() - INTERVAL '1 day';
)";
// ------------------------------------------------------------
// QUERY: Hole alle Benutzer, deren Amt neu besetzt wurde
// ------------------------------------------------------------
static constexpr const char* QUERY_GET_USERS_WITH_FILLED_OFFICES = R"(
SELECT DISTINCT
ch.user_id
FROM
falukant_data.political_office AS po
JOIN
falukant_data."character" AS ch
ON po.character_id = ch.id
WHERE
ch.user_id IS NOT NULL
AND po.created_at >= NOW() - INTERVAL '1 minute';
)";
static constexpr const char* QUERY_PROCESS_ELECTIONS = R"(
SELECT office_id, office_type_id, character_id, region_id
FROM falukant_data.process_elections();