fix(db): add stable tiebreaker to search pagination

Without a deterministic tiebreaker on skill ID, offset-based pagination
through large groups of skills with identical star counts produced
non-deterministic ordering. This caused ~1,516 skills to be missed
during Meilisearch sync (192,311 sent but only 190,795 unique indexed).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
airano
2026-02-17 04:16:26 +03:30
parent 2d37a5c16e
commit 31f5df0900

View File

@@ -164,7 +164,7 @@ export const skillQueries = {
? and(eq(skillCategories.categoryId, category), ...conditions) ? and(eq(skillCategories.categoryId, category), ...conditions)
: eq(skillCategories.categoryId, category) : eq(skillCategories.categoryId, category)
) )
.orderBy(primaryOrder, desc(secondaryColumn)) .orderBy(primaryOrder, desc(secondaryColumn), asc(skills.id))
.limit(limit) .limit(limit)
.offset(offset); .offset(offset);
@@ -175,7 +175,7 @@ export const skillQueries = {
.select() .select()
.from(skills) .from(skills)
.where(conditions.length > 0 ? and(...conditions) : undefined) .where(conditions.length > 0 ? and(...conditions) : undefined)
.orderBy(primaryOrder, desc(secondaryColumn)) .orderBy(primaryOrder, desc(secondaryColumn), asc(skills.id))
.limit(limit) .limit(limit)
.offset(offset); .offset(offset);