a
This commit is contained in:
@@ -122,6 +122,28 @@ export const upsertBatch = mutation({
|
||||
});
|
||||
created += 1;
|
||||
}
|
||||
|
||||
const seenExisting = await ctx.db
|
||||
.query("seenUrls")
|
||||
.withIndex("by_project_url", (q) =>
|
||||
q.eq("projectId", args.projectId).eq("url", opp.url)
|
||||
)
|
||||
.first();
|
||||
|
||||
if (seenExisting) {
|
||||
await ctx.db.patch(seenExisting._id, {
|
||||
lastSeenAt: now,
|
||||
source: "opportunities",
|
||||
});
|
||||
} else {
|
||||
await ctx.db.insert("seenUrls", {
|
||||
projectId: args.projectId,
|
||||
url: opp.url,
|
||||
firstSeenAt: now,
|
||||
lastSeenAt: now,
|
||||
source: "opportunities",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return { created, updated };
|
||||
|
||||
Reference in New Issue
Block a user