feat: Implement data source management and analysis flow, allowing users to add and analyze websites for project opportunities.

This commit is contained in:
2026-02-03 20:35:03 +00:00
parent 885bbbf954
commit c47614bc66
9 changed files with 587 additions and 54 deletions

View File

@@ -19,6 +19,28 @@ export const getLatestByProject = query({
},
});
export const getLatestByDataSource = query({
args: { dataSourceId: v.id("dataSources") },
handler: async (ctx, { dataSourceId }) => {
const userId = await getAuthUserId(ctx);
if (!userId) return null;
const dataSource = await ctx.db.get(dataSourceId);
if (!dataSource) return null;
const project = await ctx.db.get(dataSource.projectId);
if (!project || project.userId !== userId) return null;
return await ctx.db
.query("analyses")
.withIndex("by_dataSource_createdAt", (q) =>
q.eq("dataSourceId", dataSourceId)
)
.order("desc")
.first();
},
});
export const createAnalysis = mutation({
args: {
projectId: v.id("projects"),