Snapshot listing pages should use backend pagination instead of loading all snapshots
- Dominant language
- JavaScript
- Stars
- 400
- Forks
- 89
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 146
Description
All snapshot listing pages currently load every snapshot at once (up to a hardcoded limit of 1000) and do all filtering client-side. This doesn't scale for instances or devices that accumulate a lot of snapshots over time, especially with auto-snapshots enabled.
## Current state
The backend already supports cursor-based pagination on all three snapshot endpoints, and the frontend API wrappers already accept `cursor` and `limit` parameters. The page components just don't use them.
* **Instance snapshots** (`pages/instance/VersionHistory/Snapshots/index.vue`): Calls `SnapshotApi.getInstanceSnapshots(this.instance.id)` with no pagination params. Loads all snapshots, filters "All/User/Auto" in memory.
* **Device snapshots** (`pages/device/VersionHistory/Snapshots/index.vue`): Calls `ApplicationApi.getSnapshots(this.device.application.id, null, null, ssFilter)` with cursor and limit as null. Loads all snapshots.
* **Application snapshots** (`pages/application/Snapshots.vue`): Same pattern, `ApplicationApi.getSnapshots(this.application.id, null, null, null)`. Loads everything.
## Backend support (already in place)
* `GET /api/v1/projects/:instanceId/snapshots`: Supports `cursor` and `limit`, returns `{ meta: { next_cursor }, count, snapshots }`
* `GET /api/v1/devices/:deviceId/snapshots`: Same pagination support
* `GET /api/v1/applications/:applicationId/snapshots`: Same pagination support, plus `deviceId`/`instanceId` filtering. Though the `meta` field in the response is currently commented out.
All three default to a limit of 1000 when no limit is provided.
## What needs to happen
* Wire up the frontend snapshot pages to actually use pagination (pass `cursor`/`limit` to the API calls, handle `next_cursor` for loading more)
* Move the "All/User/Auto" snapshot type filtering to the backend instead of doing it client-side
* Fix the application snapshots endpoint response to include `meta` (currently commented out)
* Add proper `PaginationParams` to the OpenAPI schemas for these endpoints (they're missing from the schema definitions even though the functionality exists)
Contributor guide
Assessment
This issue has not been assessed yet.