Year
1. What is a Year?
The Year entity is a per-course bucket of MCQ counts, scoped to a single calendar year. It exists so the product can show “how many PYQs / DQs / EQs do we have for 2023 in UPSC?“
2. Connection With Other Entities
┌────────────┐ ┌────────────┐
│ Course │ ──── scopes ───────────▶ │ YEAR │
│ (NEET,UPSC)│ one row per (course,yr) │ bucket │
└────────────┘ └─────┬──────┘
│
counts │ refreshed
│ on every
│ MCQ change
▼
┌────────────┐
│ MCQ │
│ (year + │
│ question_ │
│ type) │
└────────────┘
In plain English: every Course has its own set of Year rows. Each Year row caches counts of MCQs that carry that same year value, split by question type (PYQ / DQ / EQ). Whenever an MCQ with a year is created, edited, or deleted, the corresponding Year row’s counters are recomputed in the background.
Year has no direct link to Taxonomy, Docket, or Block — it is purely a course-level MCQ aggregate.
3. Parameters of a Year
_id— composite primary key of the form{course_id}_{year}(e.g.1_2023); guarantees one Year row per course per calendar yearcourse_id— the course this year belongs to (NEET, UPSC, etc.); used for scoping and access controlyear— calendar year (e.g.2023); derived from_idvia helper, not stored as a separate field on every recordpyq_count— total number of PYQ MCQs for this (course, year), across all statusesdq_count— total number of DQ MCQs for this (course, year), across all statuseseq_count— total number of EQ MCQs for this (course, year), across all statusespublished_pyq_count— PYQ MCQs inPUBLISHEDstatus only; this is what students see on the year filterpublished_dq_count— DQ MCQs inPUBLISHEDstatus onlypublished_eq_count— EQ MCQs inPUBLISHEDstatus onlystatus—DRAFT|PUBLISHED|UNPUBLISHED|ARCHIVE; drives visibility on student surfaces and allowed transitionsis_deleted— soft-delete flag; excluded from reads unless explicitly requestedcreated_at/updated_at— epoch-ms timestamps (UTC);updated_atadvances on every count refreshcreated_by/updated_by— user IDs (orsystemfor background-task writes)
4. Lifecycle
┌──────────┐ publish ┌────────────┐ unpublish ┌──────────────┐
auto- │ DRAFT │ ──────────▶ │ PUBLISHED │ ───────────▶ │ UNPUBLISHED │
create │ │ │ │ ◀─────────── │ │
─────▶ │ │ │ │ republish │ │
└────┬─────┘ └──────┬─────┘ └──────┬───────┘
│ │ │
│ archive │ archive │ archive
▼ ▼ ▼
┌────────────┐
│ ARCHIVE │ (terminal)
└────────────┘
│
│ + orthogonal
▼
┌────────────┐
│ soft delete│ (is_deleted=true, reversible)
└────────────┘
| State | Who sees it | Notes |
|---|---|---|
| Draft | Admin only | Auto-assigned default for newly auto-created rows in some flows. |
| Published | Students (mobile sync, web list) | Visible in year filter dropdowns. |
| Unpublished | Admin only | Temporarily hidden from students; counts still kept. Can be republished. |
| Archive | Admin only | Terminal — no transitions out. Year retired from product surfaces. |
| Soft-deleted | No-one | Orthogonal to status. Recoverable. |