arroba icon indicating copy to clipboard operation
arroba copied to clipboard

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

Open tesaguri opened this issue 1 year ago • 3 comments

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.

tesaguri avatar Nov 06 '24 03:11 tesaguri

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 avatar Nov 06 '24 15:11 snarfed

Oh and thanks for filing this in the right repo!

snarfed avatar Nov 06 '24 15:11 snarfed

If anyone's wondering about my reference to this, it's because I have an app I've written for myself that "follows" atproto accounts by periodically running listRecords to look for recent Bluesky posts on each individual PDS. Since atproto doesn't specify which way (forward or reverse) is newest-first, I try them both and take whichever has newer records (as measured by sorting them by the AT URIs, which would all be identical up to the point of the alphanumeric record key).

I don't actually need the reverse parameter implemented for users I follow who use Bridgy Fed, though, because those people I'd just follow with ActivityPub instead, and for reverse lookup of my own posts I can use Constellation and look for bridgyOriginalUrl.

IsaacSchemm avatar Sep 27 '25 21:09 IsaacSchemm