dev vouch dev on at. thats about it atvouch.dev
8
fork

Configure Feed

Select the types of activity you want to include in your feed.

appview: order vouches by original_created_at

Luna 833862d9 afb10a35

+30 -9
+3 -3
appview/lib/atvouch/vouch.ex
··· 56 56 57 57 from(v in __MODULE__, 58 58 where: v.creator_did == ^did, 59 - order_by: [asc: v.at_uri], 59 + order_by: fragment("unixepoch(original_created_at) DESC"), 60 60 limit: ^limit, 61 61 offset: ^offset 62 62 ) ··· 80 80 81 81 from(v in __MODULE__, 82 82 where: v.target_did == ^did, 83 - order_by: [asc: v.at_uri], 83 + order_by: fragment("unixepoch(original_created_at) DESC"), 84 84 limit: ^limit, 85 85 offset: ^offset 86 86 ) ··· 102 102 def paginated(limit, offset) do 103 103 import Ecto.Query 104 104 105 - from(v in __MODULE__, order_by: [asc: v.at_uri], limit: ^limit, offset: ^offset) 105 + from(v in __MODULE__, order_by: fragment("unixepoch(original_created_at) DESC"), limit: ^limit, offset: ^offset) 106 106 |> Atvouch.Repo.replica().all() 107 107 end 108 108 end
+27 -6
appview/test/atvouch/xrpc_vouches_test.exs
··· 63 63 end 64 64 65 65 describe "GET /xrpc/dev.atvouch.graph.getCurrentUserVouches" do 66 - test "returns vouches created by the authenticated user" do 66 + test "returns vouches created by the authenticated user, newest first" do 67 67 conn = 68 68 conn(:get, "/xrpc/dev.atvouch.graph.getCurrentUserVouches") 69 69 |> put_req_header("authorization", "Bearer valid-token:did:plc:alice") ··· 74 74 assert is_list(body["vouches"]) 75 75 assert length(body["vouches"]) == 2 76 76 77 + # Should be ordered by original_created_at DESC (newest first) 78 + # Carol vouch is 2026-03-02, Bob vouch is 2026-03-01 77 79 uris = Enum.map(body["vouches"], & &1["uri"]) 78 - assert "at://did:plc:alice/dev.atvouch.graph.vouch/did:plc:bob" in uris 79 - assert "at://did:plc:alice/dev.atvouch.graph.vouch/did:plc:carol" in uris 80 + assert uris == [ 81 + "at://did:plc:alice/dev.atvouch.graph.vouch/did:plc:carol", 82 + "at://did:plc:alice/dev.atvouch.graph.vouch/did:plc:bob" 83 + ] 80 84 81 85 vouch = Enum.find(body["vouches"], &(&1["uri"] =~ "did:plc:bob")) 82 86 assert vouch["creatorDid"] == "did:plc:alice" ··· 340 344 }) 341 345 342 346 # Alice now has 3 remote vouches, fetch with limit=2 347 + # Ordered by original_created_at DESC: eve (03-06), carol (03-05), bob (03-03) 343 348 conn1 = 344 349 conn(:get, "/xrpc/dev.atvouch.graph.getRemoteVouches?limit=2") 345 350 |> put_req_header("authorization", "Bearer valid-token:did:plc:alice") ··· 350 355 cursor = body1["cursor"] 351 356 assert cursor 352 357 358 + # First page should have the two newest 359 + uris1 = Enum.map(body1["vouches"], & &1["uri"]) 360 + assert uris1 == [ 361 + "at://did:plc:eve/dev.atvouch.graph.vouch/did:plc:alice", 362 + "at://did:plc:carol/dev.atvouch.graph.vouch/did:plc:alice" 363 + ] 364 + 353 365 conn2 = 354 366 conn(:get, "/xrpc/dev.atvouch.graph.getRemoteVouches?limit=2&cursor=#{cursor}") 355 367 |> put_req_header("authorization", "Bearer valid-token:did:plc:alice") ··· 359 371 assert length(body2["vouches"]) == 1 360 372 refute body2["cursor"] 361 373 362 - uris1 = Enum.map(body1["vouches"], & &1["uri"]) 374 + # Last page should have the oldest 363 375 uris2 = Enum.map(body2["vouches"], & &1["uri"]) 364 - assert MapSet.disjoint?(MapSet.new(uris1), MapSet.new(uris2)) 376 + assert uris2 == ["at://did:plc:bob/dev.atvouch.graph.vouch/did:plc:alice"] 365 377 end 366 378 367 379 test "no cursor when all results fit in one page" do ··· 404 416 end 405 417 406 418 describe "GET /xrpc/dev.atvouch.graph.getEntireGraph" do 407 - test "returns all vouches with default limit" do 419 + test "returns all vouches with default limit, newest first" do 408 420 conn = 409 421 conn(:get, "/xrpc/dev.atvouch.graph.getEntireGraph") 410 422 |> Atvouch.Router.call(@opts) ··· 413 425 body = Jason.decode!(conn.resp_body) 414 426 assert length(body["vouches"]) == 3 415 427 refute body["cursor"] 428 + 429 + # Should be ordered by original_created_at DESC (newest first) 430 + # Bob→Alice is 2026-03-03, Alice→Carol is 2026-03-02, Alice→Bob is 2026-03-01 431 + uris = Enum.map(body["vouches"], & &1["uri"]) 432 + assert uris == [ 433 + "at://did:plc:bob/dev.atvouch.graph.vouch/did:plc:alice", 434 + "at://did:plc:alice/dev.atvouch.graph.vouch/did:plc:carol", 435 + "at://did:plc:alice/dev.atvouch.graph.vouch/did:plc:bob" 436 + ] 416 437 end 417 438 418 439 test "returns total count of vouches" do