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:
1 parent
b8244da2e5
commit
746fa0a9c1
19 files changed
+333
-64
No files matched your search
@@ -1020,7 +1020,9 @@ func TestChangeBatches(t *testing.T) {
|
||||
}
|
||||
changed := func(after string) ([]types.Opportunity, string) {
|
||||
t.Helper()
|
||||
opportunities, latest, err := s.ListChangedOpportunities(ctx, after)
|
||||
opportunities, latest, err := s.ListChangedOpportunities(
|
||||
ctx, after, time.Time{},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -1074,6 +1076,18 @@ func TestChangeBatches(t *testing.T) {
|
||||
t.Errorf("changed opportunity without classifications: %+v", got[1])
|
||||
}
|
||||
|
||||
// releasedFrom leaves out ocds-2 (released day 2), not the batch.
|
||||
got, hash, err := s.ListChangedOpportunities(ctx, first, day(3))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !equal(uuids(got), []string{"ocds-3"}) || hash != second {
|
||||
t.Errorf(
|
||||
"changed from day 3: %v, %q; want [ocds-3], %q",
|
||||
uuids(got), hash, second,
|
||||
)
|
||||
}
|
||||
|
||||
mustSetMarks(t, s, types.OpportunityMarks{
|
||||
UUID: "ocds-1",
|
||||
Skipped: true,
|
||||
@@ -1091,7 +1105,7 @@ func TestChangeBatches(t *testing.T) {
|
||||
t.Errorf("changed after latest: %v, %q; want [], %q", got, again, hash)
|
||||
}
|
||||
|
||||
_, _, err := s.ListChangedOpportunities(ctx, "unknown")
|
||||
_, _, err = s.ListChangedOpportunities(ctx, "unknown", time.Time{})
|
||||
if !errors.Is(err, store.ErrUnknownBatch) {
|
||||
t.Errorf("unknown batch: err %v, want ErrUnknownBatch", err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user