Files
yourpart3/backend/scripts/fix-srs-queries.sql
Torsten Schulz (local) 5cc8dde2f1
All checks were successful
Deploy to production / deploy (push) Successful in 2m11s
feat: füge Skripte zur Behebung von SRS-Elementen hinzu, die mit next_due_at gleich oder unmittelbar vor created_at erstellt wurden
2026-06-03 17:35:26 +02:00

24 lines
899 B
PL/PgSQL

-- Fix items that were created with next_due_at ~= created_at (within 2 minutes)
-- Run this after a backup. Adjust the WHERE clause if you want a different window.
BEGIN;
-- Preview rows to be changed
SELECT id, item_key, course_id, stage, next_due_at, created_at
FROM community.vocab_srs_item
WHERE created_at >= now() - interval '3 days'
AND abs(EXTRACT(EPOCH FROM (next_due_at - created_at))) < 120
ORDER BY created_at ASC
LIMIT 200;
-- Conservative update: set next_due_at to next calendar day at 08:00
UPDATE community.vocab_srs_item
SET next_due_at = date_trunc('day', created_at + interval '1 day') + interval '8 hours'
WHERE created_at >= now() - interval '3 days'
AND abs(EXTRACT(EPOCH FROM (next_due_at - created_at))) < 120
RETURNING id, item_key, course_id, stage, next_due_at, created_at;
COMMIT;
-- After running, re-run backend/scripts/diag-srs-stats.js to validate counts.