Skip to content

Extend GET /v3/harvests: status filter + guaranteed newest-first sort #242

@Zalfsten

Description

@Zalfsten

Background

The GET /v3/harvests endpoint currently supports only an rdi filter and basic offset pagination (skip/limit). The API client's list_harvests() method has been updated to the target signature but raises NotImplementedError until the server supports the required features.

Required server-side changes

1. Status filter

Add an optional status query parameter:

GET /v3/harvests?status=RUNNING
GET /v3/harvests?status=FAILED&rdi=my-rdi

Accepted values: RUNNING, COMPLETED, FAILED, CANCELLED.

2. Guaranteed newest-first sort order

Results must be sorted by started_at descending (newest first). The current CouchDB query order is unspecified. A dashboard showing "recent harvests" depends on this guarantee.

Target API client signature

async def list_harvests(
    self,
    rdi: str | None = None,
    status: HarvestStatus | None = None,
    limit: int = 20,
    offset: int = 0,
) -> list[HarvestResult]:
    ...

Use case

A middleware dashboard (Django app) will display a list of recent harvest runs with status indicators. Clicking a run shows the detail view. For this:

  • The list must be ordered newest-first so the dashboard can show the last N runs.
  • Status filtering enables dedicated views (e.g. "all currently running harvests", "failed harvests today").

Affected server-side code

File Change
middleware/api/src/middleware/api/api/v3/harvests.py Add status query param; enforce sort order
middleware/api/src/middleware/api/business_logic/harvest_manager.py Pass status filter to doc store
middleware/api/src/middleware/api/document_store/__init__.py Add status to list_harvests signature
middleware/api/src/middleware/api/document_store/couchdb.py CouchDB query: filter by status, sort by started_at DESC

Once implemented, remove the NotImplementedError from api_client.list_harvests() and add the query parameters to the HTTP call.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions