Added a "Published in the last X days" filter, applied by the backend

GET /api/opportunities takes released_from, an RFC 3339 time, and lists
only the opportunities whose latest release is at or after it. It works
with paging and with changed_after, which keeps the same batch either
way; an invalid value is 400.

The frontend's filter defaults to 7 days, from midnight UK time, and
sends it with every load and catch-up, so a year of opportunities isn't
downloaded to show a week's. Changing the days loads the list again;
Clear filters goes back to 7.
This commit is contained in:
bwilliams committed 2026-10-19 10:05:45 +01:00
1 parent b8244da2e5
commit 746fa0a9c1
19 files changed
+333 -64

No files matched your search

+7 -2
View File
@@ -313,7 +313,8 @@ ON CONFLICT DO NOTHING`
// selectOpportunitiesChangedBetween reads, into opportunityRows, the
// opportunities in the batches created after the first argument and at or
// before the second, once each, ordered as ListOpportunities orders them.
// before the second, once each. ListChangedOpportunities may add AND
// clauses, then orderOpportunitiesChanged.
const selectOpportunitiesChangedBetween = `
SELECT t.*
FROM opportunities t
@@ -322,5 +323,9 @@ WHERE t.uuid IN (
FROM opportunity_change_batch_opportunities bo
JOIN opportunity_change_batches b ON b.id = bo.batch_id
WHERE b.created_at > ? AND b.created_at <= ?
)
)`
// orderOpportunitiesChanged ends selectOpportunitiesChangedBetween, ordering
// as ListOpportunities orders.
const orderOpportunitiesChanged = `
ORDER BY t.latest_release_date DESC, t.uuid`