feat: Implement analysis job tracking with progress timeline and enhanced data source status management.

This commit is contained in:
2026-02-03 22:43:27 +00:00
parent c47614bc66
commit 358f2a42dd
22 changed files with 2251 additions and 219 deletions

View File

@@ -32,8 +32,17 @@ export const createProject = mutation({
const userId = await getAuthUserId(ctx);
if (!userId) throw new Error("Unauthorized");
// If setting as default, unset other defaults? For now assume handled by UI or logic
// Actually simplicity: just create.
if (args.isDefault) {
const existingDefaults = await ctx.db
.query("projects")
.withIndex("by_owner", (q) => q.eq("userId", userId))
.collect();
for (const project of existingDefaults) {
if (project.isDefault) {
await ctx.db.patch(project._id, { isDefault: false });
}
}
}
return await ctx.db.insert("projects", {
userId,
@@ -44,6 +53,36 @@ export const createProject = mutation({
},
});
export const updateProject = mutation({
args: { projectId: v.id("projects"), name: v.string(), isDefault: v.boolean() },
handler: async (ctx, args) => {
const userId = await getAuthUserId(ctx);
if (!userId) throw new Error("Unauthorized");
const project = await ctx.db.get(args.projectId);
if (!project || project.userId !== userId) {
throw new Error("Project not found or unauthorized");
}
if (args.isDefault) {
const existingDefaults = await ctx.db
.query("projects")
.withIndex("by_owner", (q) => q.eq("userId", userId))
.collect();
for (const item of existingDefaults) {
if (item.isDefault && item._id !== args.projectId) {
await ctx.db.patch(item._id, { isDefault: false });
}
}
}
await ctx.db.patch(args.projectId, {
name: args.name,
isDefault: args.isDefault,
});
},
});
export const toggleDataSourceConfig = mutation({
args: { projectId: v.id("projects"), sourceId: v.id("dataSources"), selected: v.boolean() },
handler: async (ctx, args) => {