fix(sync): honor per-spoon auto-sync settings

This commit is contained in:
Gabriel Brown
2026-07-10 17:15:20 -04:00
parent 57c175aecd
commit bdb2964e34
5 changed files with 231 additions and 3 deletions
+25
View File
@@ -0,0 +1,25 @@
import { v } from 'convex/values';
import { internalMutation } from './_generated/server';
// One-shot backfill: preserve existing automatic fast-forward behavior for
// GitHub spoons now that refreshes honor autoSyncEnabled. Idempotent.
export const backfillAutoSyncDefaults = internalMutation({
args: {},
returns: v.object({ updated: v.number() }),
handler: async (ctx) => {
const settings = await ctx.db.query('spoonSettings').collect();
let updated = 0;
for (const row of settings) {
if (row.autoSyncEnabled) continue;
const spoon = await ctx.db.get(row.spoonId);
if (spoon?.provider !== 'github') continue;
await ctx.db.patch(row._id, {
autoSyncEnabled: true,
updatedAt: Date.now(),
});
updated += 1;
}
return { updated };
},
});