feat(github): index connections by installation + status mutation
This commit is contained in:
@@ -138,6 +138,32 @@ export const upsertConnectionForUser = internalMutation({
|
||||
},
|
||||
});
|
||||
|
||||
export const setConnectionStatusByInstallation = internalMutation({
|
||||
args: {
|
||||
installationId: v.string(),
|
||||
status: v.union(
|
||||
v.literal('active'),
|
||||
v.literal('needs_reauth'),
|
||||
v.literal('revoked'),
|
||||
),
|
||||
},
|
||||
handler: async (ctx, { installationId, status }) => {
|
||||
const connections = await ctx.db
|
||||
.query('gitConnections')
|
||||
.withIndex('by_installation', (q) =>
|
||||
q.eq('installationId', installationId),
|
||||
)
|
||||
.collect();
|
||||
|
||||
const now = Date.now();
|
||||
for (const connection of connections) {
|
||||
await ctx.db.patch(connection._id, { status, updatedAt: now });
|
||||
}
|
||||
|
||||
return { updated: connections.length };
|
||||
},
|
||||
});
|
||||
|
||||
export const createForkSpoonRecord = internalMutation({
|
||||
args: {
|
||||
ownerId: v.id('users'),
|
||||
|
||||
Reference in New Issue
Block a user