cmd/ismdb: generate jst date for careers
ci/woodpecker/push/horsebot Pipeline was successful
ci/woodpecker/push/zenno Pipeline was successful

This commit is contained in:
2026-11-16 11:05:25 -05:00
parent 8d41c5942a
commit e7b1f23d33
3 changed files with 44 additions and 0 deletions
+38
View File
@@ -95,3 +95,41 @@ SELECT
COUNT(*)
FROM career
GROUP BY trainer_id, card_id;
CREATE VIEW daily_careers AS
WITH c AS (
SELECT
trainer_id,
jst_day,
COUNT(*) AS careers
FROM career
GROUP BY trainer_id, jst_day
), r AS (
SELECT
career.trainer_id,
career.jst_day,
COUNT(*) AS races,
COUNT(*) FILTER (WHERE result_rank = 1) AS wins,
SUM(gained_fans) AS fans
FROM career
JOIN race_history h ON career.trainer_id = h.trainer_id AND career.trained_chara_id = h.trained_chara_id
GROUP BY career.trainer_id, career.jst_day
)
SELECT
c.*,
r.races,
r.wins,
r.fans
FROM c
JOIN r ON c.trainer_id = r.trainer_id AND c.jst_day = r.jst_day;
CREATE VIEW daily_items AS
SELECT
career.trainer_id,
career.jst_day,
rr.item_id,
COUNT(*) as drops,
SUM(item_num) AS received
FROM race_reward rr
JOIN career ON rr.trainer_id = career.trainer_id AND rr.trained_chara_id = career.trained_chara_id
GROUP BY career.trainer_id, career.jst_day, rr.item_id;