Skip to content

Commit

Permalink
fix: wrong images being fetched form database
Browse files Browse the repository at this point in the history
  • Loading branch information
onursagir committed Sep 2, 2024
1 parent 3badc7c commit dc3151a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/twenty-singers-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'web': patch
---

Fixed an issue on the agenda detail page where the wrong cover image would be shown
4 changes: 2 additions & 2 deletions apps/web/src/services/cms/get-event-by-slug.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { db } from '@/drizzle/db';
import { events, files, filesRelatedMorphs } from '@/drizzle/schema';
import { desc, eq } from 'drizzle-orm';
import { and, desc, eq } from 'drizzle-orm';

export async function getEventBySlug(slug: string) {
const [event] = await db
Expand Down Expand Up @@ -29,7 +29,7 @@ export async function getEventBySlug(slug: string) {
.orderBy(events.id, desc(events.publishedAt))
.leftJoin(filesRelatedMorphs, eq(events.id, filesRelatedMorphs.relatedId))
.leftJoin(files, eq(files.id, filesRelatedMorphs.fileId))
.where(eq(events.slug, slug))
.where(and(eq(events.slug, slug), eq(filesRelatedMorphs.relatedType, 'api::event.event')))
.limit(1);

return event;
Expand Down

0 comments on commit dc3151a

Please sign in to comment.