* Re-implement pagination and paginate crawlconfig revs First step toward simplifying pagination to set us up for sorting and filtering of list endpoints. This commit removes fastapi-pagination as a dependency. * Migrate all HttpUrl seeds to Seeds This commit also updates the frontend to always use Seeds and to fix display issues resulting from the change. * Filter and sort crawls and workflows Crawls: - Filter by createdBy (via userid param) - Filter by state (comma-separated string for multiple values) - Filter by first_seed, name, description - Sort by started, finished, fileSize, firstSeed - Sort descending by default to match frontend Workflows: - Filter by createdBy (formerly userid) and modifiedBy - Filter by first_seed, name, description - Sort by created, modified, firstSeed, lastCrawlTime * Add crawlconfigs search-values API endpoint and test
11 lines
265 B
Python
11 lines
265 B
Python
"""API pagination"""
|
|
from typing import Any, List, Optional
|
|
|
|
|
|
DEFAULT_PAGE_SIZE = 1_000
|
|
|
|
|
|
def paginated_format(items: Optional[List[Any]], total: int, page: int = 1):
|
|
"""Return items in paged format."""
|
|
return {"items": items, "total": total, "page": page}
|