Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion apps/scan/src/services/db/resources/origin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ export const upsertOrigin = async (

const originId = upsertedOrigin.id;

// Deduplicate ogImages by URL to prevent unique constraint violations
const uniqueOgImages = [...new Map(origin.ogImages.map(img => [img.url, img])).values()];

await Promise.all(
origin.ogImages.map(({ url, height, width, title, description }) =>
uniqueOgImages.map(({ url, height, width, title, description }) =>
tx.ogImage.upsert({
where: {
originId_url: {
Expand Down