Move to threads based system.
This commit is contained in:
@@ -22,6 +22,13 @@ const syncStatus = v.union(
|
||||
v.literal('merged'),
|
||||
);
|
||||
|
||||
const syncDecision = v.union(
|
||||
v.literal('auto_synced'),
|
||||
v.literal('thread_created'),
|
||||
v.literal('ignored'),
|
||||
v.literal('failed'),
|
||||
);
|
||||
|
||||
export const listRecent = query({
|
||||
args: { limit: v.optional(v.number()) },
|
||||
handler: async (ctx, { limit }) => {
|
||||
@@ -52,6 +59,7 @@ export const createInternal = internalMutation({
|
||||
args: {
|
||||
spoonId: v.id('spoons'),
|
||||
ownerId: v.id('users'),
|
||||
threadId: v.optional(v.id('threads')),
|
||||
kind: syncKind,
|
||||
status: syncStatus,
|
||||
upstreamFrom: v.optional(v.string()),
|
||||
@@ -60,6 +68,7 @@ export const createInternal = internalMutation({
|
||||
aiAssessment: v.optional(v.string()),
|
||||
mergeRequestUrl: v.optional(v.string()),
|
||||
error: v.optional(v.string()),
|
||||
decision: v.optional(syncDecision),
|
||||
},
|
||||
handler: async (ctx, args): Promise<Id<'syncRuns'>> => {
|
||||
const now = Date.now();
|
||||
@@ -74,6 +83,7 @@ export const createInternal = internalMutation({
|
||||
export const patchInternal = internalMutation({
|
||||
args: {
|
||||
syncRunId: v.id('syncRuns'),
|
||||
threadId: v.optional(v.id('threads')),
|
||||
status: v.optional(syncStatus),
|
||||
upstreamFrom: v.optional(v.string()),
|
||||
upstreamTo: v.optional(v.string()),
|
||||
@@ -81,9 +91,11 @@ export const patchInternal = internalMutation({
|
||||
aiAssessment: v.optional(v.string()),
|
||||
mergeRequestUrl: v.optional(v.string()),
|
||||
error: v.optional(v.string()),
|
||||
decision: v.optional(syncDecision),
|
||||
},
|
||||
handler: async (ctx, args) => {
|
||||
const patch: Partial<Doc<'syncRuns'>> = { updatedAt: Date.now() };
|
||||
if (args.threadId !== undefined) patch.threadId = args.threadId;
|
||||
if (args.status !== undefined) patch.status = args.status;
|
||||
if (args.upstreamFrom !== undefined) patch.upstreamFrom = args.upstreamFrom;
|
||||
if (args.upstreamTo !== undefined) patch.upstreamTo = args.upstreamTo;
|
||||
@@ -95,6 +107,7 @@ export const patchInternal = internalMutation({
|
||||
patch.mergeRequestUrl = args.mergeRequestUrl;
|
||||
}
|
||||
if (args.error !== undefined) patch.error = args.error;
|
||||
if (args.decision !== undefined) patch.decision = args.decision;
|
||||
await ctx.db.patch(args.syncRunId, patch);
|
||||
return { success: true };
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user