api: fix timezone issue in repo pagination
As lists of repositories are sorted and paginated by their "updated" timestamp, a cursor carries such a timestamp, so that the next query can pick up where the last one left off. However, the passing of this timestamp is broken on systems that do not run on UTC. Go translates time values to the system's timezone, but this timezone information gets lost when handing the value to postgres, presumably because the column type is "timestamp without time zone". Avoid the issue by converting the parsed timestamp back to UTC right away.
This commit is contained in:
parent
a063090a89
commit
ee7701a9eb
|
@ -103,7 +103,7 @@ func (r *Repository) QueryWithCursor(ctx context.Context,
|
|||
|
||||
if cur.Next != "" {
|
||||
ts, _ := strconv.ParseInt(cur.Next, 10, 64)
|
||||
updated := time.UnixMicro(ts)
|
||||
updated := time.UnixMicro(ts).UTC()
|
||||
q = q.Where(database.WithAlias(r.alias, "updated")+"<= ?", updated)
|
||||
}
|
||||
q = q.
|
||||
|
|
Loading…
Reference in New Issue