developmentseed / developmentseed/sat-api-pg

Fix content-range semantics for the search function.

Open
#32 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
PLpgSQL
Stars
31
Forks
2
PR merge metrics
No merged PRs in 30d

Description

There are 2 issues with the current (temporary) manner in which the `Content-Range` header is set for requests that utilize the [search](https://github.com/developmentseed/sat-api-pg/blob/master/db/src/api/satapi.sql#L20) function.

1. First support needs to be added for the `Prefer` header value `count=exact` which will return the total count of records returned by the dynamic `SELECT` statement when that request header is present. I'm unsure of the most optimal way to accomplish this (a `Count(*) Over()` window function or some other approach).

2. Second, the range prefix `0-10/*` should account for the number of records returned by the current `LIMIT` `OFFSET` value so that it returns the correct value when there are less records than the `LIMIT` in the current page.

Both these are natively supported on PostgREST view endpoints (i.e `items`) but need to be included in the `search` function logic directly.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.