fix(sync): honor per-spoon auto-sync settings
This commit is contained in:
@@ -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 };
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user