Skip to content

Commit

Permalink
Sort entries by '-last_modified' in monitor/changes changeset endpoint (
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem authored Jan 9, 2025
1 parent aafe839 commit 078d4d7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,13 @@ def get_changeset(request):
last_modified = (
records_timestamp # The collection 'monitor/changes' is virtual.
)
# Mimic records endpoint and sort by timestamp desc.
sorting = [Sort("last_modified", -1)]
changes = model.get_objects(
filters=filters, limit=limit, include_deleted=include_deleted
filters=filters,
limit=limit,
include_deleted=include_deleted,
sorting=sorting,
)

else:
Expand Down
19 changes: 19 additions & 0 deletions kinto-remote-settings/tests/changes/test_changeset.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,22 @@ def test_filter_by_collection(self):
headers=self.headers,
)
assert len(resp.json["changes"]) == 1

def test_entries_are_sorted_by_timestamp_desc(self):
resp = self.app.get(
self.changeset_uri,
headers=self.headers,
)
data = resp.json
assert data["changes"][0]["collection"] == "certificates"

self.app.post_json(
self.records_uri.format(cid="cfr"), SAMPLE_RECORD, headers=self.headers
)

resp = self.app.get(
self.changeset_uri,
headers=self.headers,
)
data = resp.json
assert data["changes"][0]["collection"] == "cfr"

0 comments on commit 078d4d7

Please sign in to comment.