Refactor pagination with cursor-based support and standardized response format
- Implement cursor-based pagination in pagination.py - Update response models to standardize pagination structure - Add cursor pagination utilities for repositories - Update HistoryArchiveRepository and ImportLogRepository with new pagination - Add comprehensive tests for cursor pagination - Update documentation for backend development and task tracking Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -107,7 +107,7 @@ _SCHEMA_STATEMENTS: list[str] = [
|
||||
_CREATE_HISTORY_ARCHIVE,
|
||||
]
|
||||
|
||||
_CURRENT_SCHEMA_VERSION: int = 6
|
||||
_CURRENT_SCHEMA_VERSION: int = 7
|
||||
|
||||
_MIGRATIONS: dict[int, str] = {
|
||||
1: "\n".join(_SCHEMA_STATEMENTS),
|
||||
@@ -187,10 +187,25 @@ CREATE TABLE IF NOT EXISTS import_runs (
|
||||
-- Index for looking up completed imports by source
|
||||
CREATE INDEX IF NOT EXISTS idx_import_runs_source_status
|
||||
ON import_runs (source_id, status);
|
||||
""",
|
||||
7: """
|
||||
-- Migration 7: Add indexes to import_log table for cursor-based pagination.
|
||||
-- The import_log table is paginated by id (newest first) and filtered by source_id.
|
||||
-- These indexes accelerate pagination queries and maintain consistent ordering.
|
||||
-- See Docs/Backend-Development.md § Database Performance for details.
|
||||
|
||||
-- Index for ordering by id DESC for cursor-based pagination (newest first)
|
||||
CREATE INDEX IF NOT EXISTS idx_import_log_id_desc
|
||||
ON import_log (id DESC);
|
||||
|
||||
-- Composite index for source_id + id DESC ordering (filtered pagination)
|
||||
CREATE INDEX IF NOT EXISTS idx_import_log_source_id_desc
|
||||
ON import_log (source_id, id DESC);
|
||||
""",
|
||||
}
|
||||
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Public API
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user