# HG changeset patch
# User Drew DeVault <sir@cmpwn.com>
# Date 1721987994 -7200
# Fri Jul 26 11:59:54 2024 +0200
# Node ID b4c9a996d7a574f5f2e84fec02e348cc393eefec
# 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 --git a/api/graph/model/repository.go b/api/graph/model/repository.go
--- a/api/graph/model/repository.go
+++ b/api/graph/model/repository.go
@@ -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.
@@ -146,7 +146,7 @@
if len(repos) > cur.Count {
cur = &model.Cursor{
Count: cur.Count,
- Next: strconv.FormatInt(repos[len(repos)-1].Updated.Unix(), 10),
+ Next: strconv.FormatInt(repos[len(repos)-1].Updated.UnixMicro(), 10),
Search: cur.Search,
}
repos = repos[:cur.Count]
Sorry, this v2 is for hg.sr.ht.
I forgot how to send patches via email with hg, relearning it with an
audience
> Sorry, this v2 is for hg.sr.ht.
>
> I forgot how to send patches via email with hg, relearning it with an
> audience
You should see me every time I have to delve back into Go for hgsrht,
searching online for stuff like "how do I split a string" :D
Anyway, all good, thanks again.