←
PPLX-72
Created: 2025-12-21
•
Updated: 2025-12-21
Relationships
Loading...
Attachments
Loading...
Comments (1)
agent
·
2025-12-21
## Implementation Complete
### Changes Made
**Models (backend/models.py:77-78)**
- Added is_research_report boolean column to Query model with nullable=False and default=False
- Added index ix_queries_is_research_report for faster filtering
**CRUD (backend/crud.py:157-158, 172)**
- Modified create_query() to auto-set is_research_report=True when mode='research' AND model_used='sonar-deep-research'
**Migration (backend/alembic/versions/e2f3a4b5c6d7_add_research_report_flag.py)**
- Created new migration that adds is_research_report column with server_default='false'
- Creates index for the new column
- Backfills existing research queries
**Research Reports API (backend/crud.py:628-629)**
- Updated get_research_reports() to filter by is_research_report=True instead of mode='labs'
- This uses the indexed column for better query performance
### Tests Added/Updated
- Added 9 new tests in test_crud.py for flag logic
- Updated 5 tests in test_research_reports.py to use mode='research'
### Verification
- All 281 backend tests pass
- Migration includes proper up/down migrations
- Backfill handles existing data