snarfed / arroba

Python implementation of Bluesky PDS and AT Protocol, including repo, MST, and sync XRPC methods
https://arroba.readthedocs.io
Creative Commons Zero v1.0 Universal
45 stars 1 forks source link

`com.atproto.repo.listRecords`: implement `reverse` parameter #37

Open tesaguri opened 6 days ago

tesaguri commented 6 days ago

arroba's com.atproto.repo.listRecords seems to return the records in ascending chronological order by default:

$ curl 'https://atproto.brid.gy/xrpc/com.atproto.repo.listRecords?repo=did:plc:xbifsywyv5pka5jlknhv5yv3&collection=app.bsky.feed.post&limit=2' | jq -r '.records[] | .value.createdAt'
2024-09-02T06:39:03.174Z
2024-09-09T04:38:49.409Z

On the other hand, while the documentation of com.atproto.repo.listRecords is not clear about the expected ordering, at least the official Bluesky PDS implementation seems to return the records in descending chronological order by default:

$ curl 'https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=did:plc:ewvi7nxzyoun6zhxrhs64oiz&collection=app.bsky.feed.post&limit=2' | jq '.records[] | .value.createdAt'
2024-08-09T22:00:22.312Z
2024-08-09T21:26:19.045Z

So, I guess arroba should change the default ordering to descending.

snarfed commented 6 days ago

Interesting find, you're digging deep!

You're right that the XRPC method doesn't seem to require a direction, and it has a reverse parameter, which would probably be more useful to implement than just changing the default direction. I'm going to take the liberty of changing this issue to track implementing that parameter. Hope you don't mind.

snarfed commented 6 days ago

Oh and thanks for filing this in the right repo!