remove stale native tasks on marketplace sync
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -80,6 +80,7 @@ export {
|
||||
updateTask,
|
||||
deleteTask,
|
||||
upsertNativeTask,
|
||||
deleteNativeTasksNotIn,
|
||||
} from './queries/tasks';
|
||||
|
||||
export {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { eq, or, and, isNull, sql } from 'drizzle-orm';
|
||||
import { eq, or, and, isNull, notInArray, sql } from 'drizzle-orm';
|
||||
import { db } from '../db';
|
||||
import { tasks } from '../schema/agent-items';
|
||||
|
||||
@@ -73,6 +73,15 @@ export async function deleteTask(id: number) {
|
||||
await db.delete(tasks).where(eq(tasks.id, id));
|
||||
}
|
||||
|
||||
export async function deleteNativeTasksNotIn(dirNames: string[]) {
|
||||
if (dirNames.length === 0) return [];
|
||||
const deleted = await db
|
||||
.delete(tasks)
|
||||
.where(and(eq(tasks.scope, 'native'), notInArray(tasks.dirName, dirNames)))
|
||||
.returning({ dirName: tasks.dirName });
|
||||
return deleted;
|
||||
}
|
||||
|
||||
export async function upsertNativeTask(data: Omit<TaskInsert, 'scope' | 'userId'>) {
|
||||
const existing = await db
|
||||
.select({ id: tasks.id })
|
||||
|
||||
Reference in New Issue
Block a user