fix(convex): order spoonCommits by committedAt via index so bounding keeps newest
This commit is contained in:
@@ -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']),
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user