~sircmpwn/sr.ht-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH] API: improve precision of repository cursors

Details
Message ID
<b4c9a996d7a574f5f2e8.1721988393@taiga>
DKIM signature
pass
Download raw message
Patch: +2 -2
# 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]
Details
Message ID
<D2ZDYN55KYPW.2DPQEYEUAQ2O6@cmpwn.com>
In-Reply-To
<b4c9a996d7a574f5f2e8.1721988393@taiga> (view parent)
DKIM signature
pass
Download raw message
Sorry, this v2 is for hg.sr.ht.

I forgot how to send patches via email with hg, relearning it with an
audience
Details
Message ID
<ecce488c-6e37-4c83-97f6-d904b634a641@app.fastmail.com>
In-Reply-To
<D2ZDYN55KYPW.2DPQEYEUAQ2O6@cmpwn.com> (view parent)
DKIM signature
pass
Download raw message
> 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.
Reply to thread Export thread (mbox)