Skip to content

Commit

Permalink
Make field nulalble
Browse files Browse the repository at this point in the history
  • Loading branch information
gantoine committed Jan 11, 2025
1 parent b5d2cad commit e84f7af
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion backend/endpoints/responses/rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class RomSchema(BaseModel):
# Metadata fields
first_release_date: int | None
youtube_video_id: str | None
average_rating: float
average_rating: float | None
alternative_names: list[str]
genres: list[str]
franchises: list[str]
Expand Down
7 changes: 4 additions & 3 deletions backend/models/rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def first_release_date(self) -> int:
return 0

@property
def average_rating(self) -> float:
def average_rating(self) -> float | None:
igdb_rating = (
float(self.igdb_metadata.get("total_rating", 0))
if self.igdb_metadata
Expand All @@ -182,9 +182,10 @@ def average_rating(self) -> float:
if self.moby_metadata
else 0.0
)
ratings = [igdb_rating, moby_rating * 10] # Moby rating is out of 10

return sum(ratings) / len([r for r in ratings if r]) if any(ratings) else 0.0
ratings = [r for r in [igdb_rating, moby_rating * 10] if r != 0.0]

return sum(ratings) / len([r for r in ratings if r]) if any(ratings) else None

@property
def genres(self) -> list[str]:
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/__generated__/models/DetailedRomSchema.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/src/__generated__/models/RomSchema.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/src/__generated__/models/SimpleRomSchema.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e84f7af

Please sign in to comment.