Skip to content

Commit

Permalink
fix: include search for collections with same foreign id in search wi…
Browse files Browse the repository at this point in the history
…th excludeExisting
  • Loading branch information
dinkelspiel committed May 6, 2024
1 parent 7a372a4 commit 4ac9ebb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions app/api/import/search/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,21 @@ export const GET = async (request: NextRequest) => {
for (const media of [...openLibrary, ...tmdb]) {
const existing = await prisma.entry.findFirst({
where: {
foreignId: media.foreignId.toString(),
category: media.category,
OR: [
{
foreignId: media.foreignId.toString(),
category: media.category,
},
{
collection: {
foreignId: media.foreignId.toString(),
category: media.category,
},
},
],
},
});
console.log(existing);

if (!existing) {
finalMedia.push(media);
Expand Down
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ model Collection {
foreignId String
posterPath String
backdropPath String
type Category
category Category
entries Entry[]
createdAt DateTime @default(now())
Expand Down

0 comments on commit 4ac9ebb

Please sign in to comment.