fix(convex): order spoonCommits by committedAt via index so bounding keeps newest

This commit is contained in:
Gabriel Brown
2026-07-11 14:41:31 -04:00
parent 9067d16734
commit bce6769277
3 changed files with 57 additions and 4 deletions
+1
View File
@@ -186,6 +186,7 @@ const applicationTables = {
updatedAt: v.number(),
})
.index('by_spoon_side', ['spoonId', 'side'])
.index('by_spoon_side_committed', ['spoonId', 'side', 'committedAt'])
.index('by_owner', ['ownerId'])
.index('by_sha', ['spoonId', 'sha'])
.index('by_committed', ['spoonId', 'committedAt']),
+4 -4
View File
@@ -17,7 +17,7 @@ export const listForSpoon = query({
if (side) {
return await ctx.db
.query('spoonCommits')
.withIndex('by_spoon_side', (q) =>
.withIndex('by_spoon_side_committed', (q) =>
q.eq('spoonId', spoonId).eq('side', side),
)
.order('desc')
@@ -27,14 +27,14 @@ export const listForSpoon = query({
const [upstream, fork] = await Promise.all([
ctx.db
.query('spoonCommits')
.withIndex('by_spoon_side', (q) =>
.withIndex('by_spoon_side_committed', (q) =>
q.eq('spoonId', spoonId).eq('side', 'upstream'),
)
.order('desc')
.take(take),
ctx.db
.query('spoonCommits')
.withIndex('by_spoon_side', (q) =>
.withIndex('by_spoon_side_committed', (q) =>
q.eq('spoonId', spoonId).eq('side', 'fork'),
)
.order('desc')
@@ -56,7 +56,7 @@ export const listInternal = internalQuery({
handler: async (ctx, { spoonId, ownerId, side, limit }) => {
const rows = await ctx.db
.query('spoonCommits')
.withIndex('by_spoon_side', (q) =>
.withIndex('by_spoon_side_committed', (q) =>
q.eq('spoonId', spoonId).eq('side', side),
)
.order('desc')