build uppon paramParser

This commit is contained in:
2025-10-28 22:59:09 +01:00
parent a634b7a69e
commit 4bc5594dc5
4 changed files with 101 additions and 54 deletions

30
db.sql
View File

@@ -176,15 +176,15 @@ sample_bookings AS (
(d.work_date + make_time(16, floor(random()*50)::int, 0))::timestamptz AS ts,
1 AS anwesenheit_typ
FROM days d
),
ins_anw AS (
-- insert only bookings up to now (prevents future times on today)
INSERT INTO anwesenheit ("timestamp", card_uid, check_in_out, geraet_id)
SELECT ts, card_uid, check_in_out, geraet_id
FROM sample_bookings
WHERE ts <= NOW()
RETURNING 1
)
-- insert only bookings up to now (prevents future times on today)
INSERT INTO anwesenheit ("timestamp", card_uid, check_in_out, geraet_id)
SELECT ts, card_uid, check_in_out, geraet_id
FROM sample_bookings
WHERE ts <= NOW()
RETURNING 1;
-- now insert absences (uses the same days CTE)
INSERT INTO abwesenheit (card_uid, abwesenheit_typ, datum)
SELECT
@@ -247,15 +247,13 @@ all_bookings AS (
SELECT * FROM base_bookings
UNION ALL
SELECT * FROM pause_bookings
),
ins_anw AS (
INSERT INTO anwesenheit ("timestamp", "card_uid", "check_in_out", "geraet_id", "anwesenheit_typ")
SELECT ts, card_uid, check_in_out, geraet_id, 1 as anwesenheit_typ
FROM all_bookings
WHERE ts <= NOW()
ORDER BY work_date, ts
RETURNING 1
)
INSERT INTO anwesenheit ("timestamp", "card_uid", "check_in_out", "geraet_id", "anwesenheit_typ")
SELECT ts, card_uid, check_in_out, geraet_id, 1 as anwesenheit_typ
FROM all_bookings
WHERE ts <= NOW()
ORDER BY work_date, ts;
INSERT INTO abwesenheit (card_uid, abwesenheit_typ, datum)
SELECT
d.card_uid,