feat: Implement data source management and analysis flow, allowing users to add and analyze websites for project opportunities.
This commit is contained in:
@@ -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"),
|
||||
|
||||
Reference in New Issue
Block a user