~sircmpwn/sr.ht-dev

1

[PATCH hg.sr.ht] API: improve precision of repository cursors

Details
Message ID
<D2ZDTGV42Z3M.1GXAJZI4Z89WT@cmpwn.com>
DKIM signature
pass
Download raw message
# HG changeset patch
# User Drew DeVault <sir@cmpwn.com>
# Date 1721987994 -7200
#      Fri Jul 26 11:59:54 2024 +0200
# Node ID 9c84d5d778473104fea861f36b6b16a316436fa1
# Parent  d9fc0f61ffddf26171417868763212d46a9be0c9
API: improve precision of repository cursors

Otherwise we run into a problem when a lot of resources are created within the
same second-resolution Unix timestamp, such as when I just scripted a bunch of
repo creation to test pagination locally. Matches a similar approach taken for
git.sr.ht in ee7701a9.

diff -r d9fc0f61ffdd -r 9c84d5d77847 api/graph/model/repository.go
--- a/api/graph/model/repository.go	Sat Mar 30 20:03:00 2024 +0000
+++ b/api/graph/model/repository.go	Fri Jul 26 11:59:54 2024 +0200
@@ -122,7 +122,7 @@
 
 	if cur.Next != "" {
 		ts, _ := strconv.ParseInt(cur.Next, 10, 64)
-		updated := time.Unix(ts, 0)
+		updated := time.UnixMicro(ts).UTC()
 		q = q.Where(database.WithAlias(r.alias, "updated")+"<= ?", updated)
 	}
 	q = q.
Details
Message ID
<c6a6a355-fcb6-4269-87d2-8c4ab9dcadeb@app.fastmail.com>
In-Reply-To
<D2ZDTGV42Z3M.1GXAJZI4Z89WT@cmpwn.com> (view parent)
DKIM signature
pass
Download raw message
Looks like this is the same change as with the other services, so all
good, thanks again!
Reply to thread Export thread (mbox)