Anki/rslib/src/storage/deck/due_counts.sql
Damien Elmes 13519a929c rework various aspects of the test scheduler
- Daily limits are no longer inherited - each deck limits its own
cards, and the selected deck enforces a maximum limit.
- Fetching of review cards now uses a single query, and sorts in advance.
In collections with a large number of overdue cards and decks, this is
faster than iterating over each deck in turn.
- Include interday learning count in review count & review limit, and
allow them to be buried.
- Warn when parent review limit is lower than child deck in deck options.
- Cap the new card limit to the review limit.
- Add option to control whether new card fetching short-circuits.
2021-05-16 20:23:07 +10:00

40 lines
No EOL
747 B
SQL

SELECT did,
sum(queue = :new_queue),
sum(
queue = :review_queue
AND due <= :day_cutoff
),
-- interday learning
sum(
queue = :daylearn_queue
AND due <= :day_cutoff
),
-- intraday learning
sum(
(
CASE
:sched_ver
WHEN 2 THEN (
-- v2 scheduler
(
queue = :learn_queue
AND due < :learn_cutoff
)
OR (
queue = :preview_queue
AND due <= :learn_cutoff
)
)
ELSE (
-- v1 scheduler
CASE
WHEN queue = :learn_queue
AND due < :learn_cutoff THEN left / 1000
ELSE 0
END
)
END
)
)
FROM cards
WHERE queue >= 0