Skip to content

Commit

Permalink
fix: add original article to event routes
Browse files Browse the repository at this point in the history
  • Loading branch information
seelengxd committed Sep 23, 2024
1 parent f394f24 commit 7594a73
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/src/events/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def retrieve_event(
Event.categories,
),
selectinload(Event.analysises, Analysis.category),
selectinload(Event.original_article),
)
)
if not event:
Expand Down
1 change: 1 addition & 0 deletions backend/src/events/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def get_events(
event_query = (
select(Event)
.options(selectinload(Event.categories))
.options(selectinload(Event.original_article))
.where(Event.id.in_(relevant_ids))
)
if limit is not None:
Expand Down
14 changes: 14 additions & 0 deletions backend/src/events/schemas.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
from datetime import datetime
from pydantic import BaseModel, ConfigDict
from src.categories.schemas import CategoryDTO
from src.events.models import ArticleSource


class ArticleDTO(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: int
title: str
summary: str
body: str
url: str
source: ArticleSource
date: datetime
image_url: str


class MiniEventDTO(BaseModel):
Expand All @@ -12,6 +25,7 @@ class MiniEventDTO(BaseModel):
date: datetime

categories: list[CategoryDTO]
original_article: ArticleDTO


class AnalysisDTO(BaseModel):
Expand Down

0 comments on commit 7594a73

Please sign in to comment.