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:
1 parent
a8c360ebf4
commit
b3207d8e1c
3 files changed
+14
-14
No files matched your search
@@ -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()),
|
||||
|
||||
Reference in new issue
Block a user