lots of changes

This commit is contained in:
2026-02-04 11:18:33 +00:00
parent d02d95e680
commit 4fdbfb0fb3
30 changed files with 1796 additions and 822 deletions

View File

@@ -126,3 +126,29 @@ export const listByProject = query({
.collect();
},
});
export const getLatestByDataSource = query({
args: {
dataSourceId: v.id("dataSources"),
},
handler: async (ctx, args) => {
const userId = await getAuthUserId(ctx);
if (!userId) return null;
const dataSource = await ctx.db.get(args.dataSourceId);
if (!dataSource) return null;
const project = await ctx.db.get(dataSource.projectId);
if (!project || project.userId !== userId) return null;
const jobs = await ctx.db
.query("analysisJobs")
.withIndex("by_dataSource_createdAt", (q) =>
q.eq("dataSourceId", args.dataSourceId)
)
.order("desc")
.take(1);
return jobs[0] ?? null;
},
});