keep ingested chunks findable and structured

Two bugs made self-ingested content useless, both silently:

- _payload wrote `chapter_number` (int) while math retrieval filters on
  `chapter` (the full "فصل ۲: کسر" string), so anything we ingest could
  never match a search — no error, just permanently invisible content.
- ingest_pdf flattened the vision extraction into one text blob and threw
  away type/keywords/generalSolution/problem/solution. LessonChunk is the
  source of truth, so rebuilding meant paying for vision again — and the
  problem/solution pairs are the input for building lesson questions.

LessonChunk now stores those fields and _payload emits them under the same
keys the other team's collections use, so ours and theirs stay one shape.

Also fixes a regression from the whitenoise commit: the Manifest storage
variant raises when staticfiles.json is absent, which broke all 23 admin
rendering tests (Django forces DEBUG=False in tests, so USE_FINDERS is off)
and would have taken the admin panel down entirely the day DEBUG=0 ships
without a collectstatic run.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-10 16:24:18 +03:30
parent f0e3e3c96c
commit 52d9694583
7 changed files with 235 additions and 3 deletions

View File

@@ -0,0 +1,48 @@
# Generated by Django 5.2.17 on 2026-09-10 12:24
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('rag', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='lessonchunk',
name='chapter_title',
field=models.CharField(blank=True, max_length=255),
),
migrations.AddField(
model_name='lessonchunk',
name='general_solution',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='lessonchunk',
name='grade_title',
field=models.CharField(blank=True, max_length=100),
),
migrations.AddField(
model_name='lessonchunk',
name='keywords',
field=models.JSONField(blank=True, default=list),
),
migrations.AddField(
model_name='lessonchunk',
name='problem',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='lessonchunk',
name='problem_type',
field=models.CharField(blank=True, max_length=255),
),
migrations.AddField(
model_name='lessonchunk',
name='solution',
field=models.TextField(blank=True),
),
]