diff --git a/backend/endpoints/responses/rom.py b/backend/endpoints/responses/rom.py index d4108afd4..e8e219b7c 100644 --- a/backend/endpoints/responses/rom.py +++ b/backend/endpoints/responses/rom.py @@ -121,6 +121,7 @@ class RomSchema(BaseModel): # Metadata fields first_release_date: int | None youtube_video_id: str | None + average_rating: float alternative_names: list[str] genres: list[str] franchises: list[str] diff --git a/backend/models/rom.py b/backend/models/rom.py index d45f877b6..00903300a 100644 --- a/backend/models/rom.py +++ b/backend/models/rom.py @@ -167,9 +167,25 @@ def alternative_names(self) -> list[str]: @property def first_release_date(self) -> int: if self.igdb_metadata: - return self.igdb_metadata.get("first_release_date", 0) + return self.igdb_metadata.get("first_release_date", 0) * 1000 return 0 + @property + def average_rating(self) -> float: + igdb_rating = ( + float(self.igdb_metadata.get("total_rating", 0)) + if self.igdb_metadata + else 0.0 + ) + moby_rating = ( + float(self.moby_metadata.get("moby_score", 0)) + 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 + @property def genres(self) -> list[str]: return ( diff --git a/frontend/src/__generated__/models/DetailedRomSchema.ts b/frontend/src/__generated__/models/DetailedRomSchema.ts index 82a6948c1..4aca7be30 100644 --- a/frontend/src/__generated__/models/DetailedRomSchema.ts +++ b/frontend/src/__generated__/models/DetailedRomSchema.ts @@ -36,6 +36,7 @@ export type DetailedRomSchema = { summary: (string | null); first_release_date: (number | null); youtube_video_id: (string | null); + average_rating: number; alternative_names: Array; genres: Array; franchises: Array; diff --git a/frontend/src/__generated__/models/RomSchema.ts b/frontend/src/__generated__/models/RomSchema.ts index c6f09f7e7..4fa52db13 100644 --- a/frontend/src/__generated__/models/RomSchema.ts +++ b/frontend/src/__generated__/models/RomSchema.ts @@ -29,6 +29,7 @@ export type RomSchema = { summary: (string | null); first_release_date: (number | null); youtube_video_id: (string | null); + average_rating: number; alternative_names: Array; genres: Array; franchises: Array; diff --git a/frontend/src/__generated__/models/SimpleRomSchema.ts b/frontend/src/__generated__/models/SimpleRomSchema.ts index 1fd9787df..9c7ad31e2 100644 --- a/frontend/src/__generated__/models/SimpleRomSchema.ts +++ b/frontend/src/__generated__/models/SimpleRomSchema.ts @@ -31,6 +31,7 @@ export type SimpleRomSchema = { summary: (string | null); first_release_date: (number | null); youtube_video_id: (string | null); + average_rating: number; alternative_names: Array; genres: Array; franchises: Array; diff --git a/frontend/src/components/Details/Title.vue b/frontend/src/components/Details/Title.vue index b32cd0c4a..67539f405 100644 --- a/frontend/src/components/Details/Title.vue +++ b/frontend/src/components/Details/Title.vue @@ -11,7 +11,7 @@ import { useDisplay } from "vuetify"; const props = defineProps<{ rom: DetailedRom }>(); const { smAndDown } = useDisplay(); const releaseDate = new Date( - Number(props.rom.first_release_date) * 1000, + Number(props.rom.first_release_date), ).toLocaleDateString("en-US", { day: "2-digit", month: "short", diff --git a/frontend/src/components/common/Game/FavBtn.vue b/frontend/src/components/common/Game/FavBtn.vue index 6c193790e..26934213c 100644 --- a/frontend/src/components/common/Game/FavBtn.vue +++ b/frontend/src/components/common/Game/FavBtn.vue @@ -88,9 +88,8 @@ async function switchFromFavourites() { @click.stop="switchFromFavourites" class="translucent text-shadow" rouded="0" - size="x-small" + size="small" variant="text" - icon >{{ collectionsStore.isFav(rom) ? "mdi-star" : "mdi-star-outline" }} selectedRoms.value.map((rom) => rom.id)); @@ -170,18 +181,18 @@ onMounted(() => {