internal/host: sort public_id descending

The previous sort would run the risk of missing items which
collide on update or create times because of the compound
comparison using strictly less than for both the timestamp
and the public_id. Sorting both descending avoids this issue.
This commit is contained in:
Johan Brandhorst-Satzkorn committed 2024-01-05 07:43:21 -08:00
1 parent a8c360ebf4
commit b3207d8e1c
3 files changed
+14 -14

No files matched your search

+2 -2
View File
@@ -267,7 +267,7 @@ func (r *Repository) listSets(ctx context.Context, catalogId string, opt ...Opti
}
whereClause := "catalog_id = @catalog_id"
args := []any{sql.Named("catalog_id", catalogId)}
order := "create_time desc, public_id asc"
order := "create_time desc, public_id desc"
if opts.withStartPageAfterItem != nil {
args = append(args,
sql.Named("last_item_create_time", opts.withStartPageAfterItem.GetCreateTime()),
@@ -301,7 +301,7 @@ func (r *Repository) listSetsRefresh(ctx context.Context, catalogId string, upda
sql.Named("catalog_id", catalogId),
sql.Named("updated_after_time", updatedAfter),
}
order := "update_time desc, public_id asc"
order := "update_time desc, public_id desc"
if opts.withStartPageAfterItem != nil {
args = append(args,
sql.Named("last_item_update_time", opts.withStartPageAfterItem.GetUpdateTime()),