Skip to content

Implement sorting and filtering in the API #7

@frawleykid

Description

@frawleykid

The Ace Archive API currently supports paging through artifacts, but not sorting or filtering them. We should add that.

The API will look like this:

  • Add a query param called dir with possible values asc or desc. You can't specify dir without sort, since the default sort order is unspecified.
  • Add a query param called sort with a single possible value of year, which sorts by from_year. If omitted, the default unspecified sort order is used (which currently sorts lexicographically by artifact ID). Sorting by year should sort by year first, then by ID, to make the sort stable.
  • Add a query param called identities, which accepts the identity to filter by. It also accepts multiple comma-separated values.
  • Add a query param called people, which accepts the person to filter by. It also accepts multiple comma-separated values.
  • Add a query param called decades, which accepts the decade to filter by. It also accepts multiple comma-separated values.
  • Add a new endpoint GET /identities/ that returns a fill list of identities that currently appear in artifacts. This does not need to be paginated.

Changing the sort order, sort direction, or filters will invalidate the pagination cursor. To enforce this, the current sort/filter params should be used to construct a 32-bit hash that is stored in the cursor. We don't need to be able to reconstruct the sort/filter params from the cursor—only tell if they've changed.

This initial implementation does not need to support passing different kinds of filters at the same time. That would complicate the implementation, and is probably unnecessary given the small size of the dataset. Trying to pass multiple filter params should return 400 Bad Request with an error type as documented here.

Make sure you update the OpenAPI document as well as the implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions