?
PPLX-59
feature,backend,deep-research
Created: 2025-12-21 Updated: 2025-12-21
Relationships Loading...
Attachments
Loading...
Comments (3)
agent · 2025-12-21
## Fix Complete The QA failure was caused by a missing Alembic migration for the `async_queries` table. The model was added to `models.py` but no migration was created to actually create the table in the database. ### Root Cause - The `AsyncQuery` model was added in a previous commit (e4d7be0) - No corresponding Alembic migration was created - When the API tried to insert into `async_queries`, SQLite returned an error because the table didn't exist - The `search_results` table was also missing columns (`snippet`, `last_updated`, `source`) because the existing database had never had migrations applied ### Fix Applied Created new migration file `d1e2f3a4b5c6_add_async_queries_table.py` that: - Creates the `async_queries` table with all columns from the model - Adds check constraint for status values (pending/processing/completed/failed) - Creates indexes on `request_id`, `thread_id`, and `status` for query performance - Sets up foreign key constraints to `threads` and `queries` tables ### For Existing Databases The test database was at the initial migration state. Applied migrations: ```bash alembic stamp cc9d2f3bc955 # Mark existing schema state alembic upgrade head # Apply all subsequent migrations ``` ### Verification 1. **All 260 tests pass** (pytest -v --tb=short) 2. **End-to-end API test successful:** - POST /api/queries/async → Created async query, returned request_id - GET /api/queries/async/{id}/progress → status: completed - GET /api/queries/async/{id}/result → Full response with sources including snippet, last_updated, source fields 3. **Database verification:** Both `async_queries` table and `search_results` columns confirmed in SQLite schema ### Commit e68ecfe - Merged to main and pushed to origin
code-verification-qa · 2025-12-21
[QA FAILED] The implementation is missing database migrations. While all 260 automated tests pass, the API endpoints fail in production with database schema errors. The async_queries table doesn't exist, and the search_results table is missing required columns (snippet, last_updated, source). Detailed findings in /tmp/qa-PPLX-59.md. Required: Create Alembic migrations for async_queries table and missing search_results columns, then re-test end-to-end.
agent · 2025-12-21
## Implementation Complete Added async query backend endpoints as specified: ### Files Modified 1. **backend/models.py** - Added `AsyncQuery` model with: - `id`, `thread_id`, `query_id`, `request_id` (Perplexity async API ID) - `query_text`, `model`, `status` (pending/processing/completed/failed) - `error_message`, `response_content` - Timestamps: `created_at`, `started_at`, `completed_at`, `failed_at` - Indexes on `request_id`, `thread_id`, `status` 2. **backend/crud.py** - Added async query CRUD operations: - `create_async_query()` - Create new async query record - `get_async_query_by_request_id()` - Get by Perplexity request ID - `get_async_query()` - Get by internal ID - `get_async_queries()` - List with pagination and status filter - `get_async_queries_by_thread()` - List by thread - `update_async_query_status()` - Update status and related fields 3. **backend/perplexity_client.py** - Added Perplexity async API methods: - `create_async_query()` - POST /async/chat/completions - `get_async_query_status()` - GET /async/chat/completions/{request_id} - `list_async_queries()` - GET /async/chat/completions 4. **backend/routers/async_queries.py** - Updated to persist to database: - POST /api/queries/async now creates AsyncQuery record - Background task updates status to 'processing' on start - On completion, updates status to 'completed' with response - On error, updates status to 'failed' with error message 5. **backend/tests/test_models.py** - Added async_queries to expected tables ### Verification All 260 tests pass. ### Endpoints Available - POST /api/queries/async - Create async query, returns request_id - GET /api/queries/async/{request_id}/progress - Poll for progress - GET /api/queries/async/{request_id}/result - Get final result The async query state is now persisted to the database (AsyncQuery table) while maintaining in-memory state for fast progress polling.