Merge pull request #2473 from rommapp/hotfix-platform-slugs

Set platform metadata slugs on models in DB
This commit is contained in:
Georges-Antoine Assi
2025-09-22 22:04:51 -04:00
committed by GitHub
7 changed files with 79 additions and 18 deletions

View File

@@ -0,0 +1,38 @@
"""empty message
Revision ID: 0054_add_platform_metadata_slugs
Revises: 0053_add_hltb_metadata
Create Date: 2025-09-22 21:42:33.654137
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "0054_add_platform_metadata_slugs"
down_revision = "0053_add_hltb_metadata"
branch_labels = None
depends_on = None
def upgrade() -> None:
with op.batch_alter_table("platforms", schema=None) as batch_op:
batch_op.add_column(sa.Column("flashpoint_id", sa.Integer(), nullable=True))
batch_op.add_column(
sa.Column("igdb_slug", sa.String(length=100), nullable=True)
)
batch_op.add_column(
sa.Column("moby_slug", sa.String(length=100), nullable=True)
)
batch_op.add_column(
sa.Column("hltb_slug", sa.String(length=100), nullable=True)
)
def downgrade() -> None:
with op.batch_alter_table("platforms", schema=None) as batch_op:
batch_op.drop_column("hltb_slug")
batch_op.drop_column("moby_slug")
batch_op.drop_column("igdb_slug")
batch_op.drop_column("flashpoint_id")

View File

@@ -16,6 +16,7 @@ class PlatformSchema(BaseModel):
name: str
igdb_slug: str | None
moby_slug: str | None
hltb_slug: str | None
custom_name: str | None = None
igdb_id: int | None = None
sgdb_id: int | None = None
@@ -25,6 +26,7 @@ class PlatformSchema(BaseModel):
ra_id: int | None = None
hasheous_id: int | None = None
tgdb_id: int | None = None
flashpoint_id: int | None = None
category: str | None = None
generation: int | None = None
family_name: str | None = None

View File

@@ -176,8 +176,10 @@ async def scan_platform(
platform_attrs["name"] = platform_attrs["slug"].replace("-", " ").title()
platform_attrs.update(
{
**hasheous_platform,
**hltb_platform,
**flashpoint_platform,
**tgdb_platform,
**hasheous_platform,
**launchbox_platform,
**ra_platform,
**moby_platform,

View File

@@ -1,6 +1,5 @@
from __future__ import annotations
from functools import cached_property
from typing import TYPE_CHECKING
from sqlalchemy import String, func, select
@@ -28,6 +27,10 @@ class Platform(BaseModel):
launchbox_id: Mapped[int | None]
hasheous_id: Mapped[int | None]
tgdb_id: Mapped[int | None]
flashpoint_id: Mapped[int | None]
igdb_slug: Mapped[str | None]
moby_slug: Mapped[str | None]
hltb_slug: Mapped[str | None]
slug: Mapped[str] = mapped_column(String(length=100))
fs_slug: Mapped[str] = mapped_column(String(length=100))
name: Mapped[str] = mapped_column(String(length=400))
@@ -83,21 +86,5 @@ class Platform(BaseModel):
def is_identified(self) -> bool:
return not self.is_unidentified
@cached_property
def igdb_slug(self) -> str | None:
from handler.metadata import meta_igdb_handler
igdb_platform = meta_igdb_handler.get_platform(self.slug)
return igdb_platform.get("igdb_slug", None)
@cached_property
def moby_slug(self) -> str | None:
from handler.metadata import meta_moby_handler
moby_platform = meta_moby_handler.get_platform(self.slug)
return moby_platform.get("moby_slug", None)
def __repr__(self) -> str:
return self.name

View File

@@ -11,6 +11,7 @@ export type PlatformSchema = {
name: string;
igdb_slug: (string | null);
moby_slug: (string | null);
hltb_slug: (string | null);
custom_name?: (string | null);
igdb_id?: (number | null);
sgdb_id?: (number | null);
@@ -20,6 +21,7 @@ export type PlatformSchema = {
ra_id?: (number | null);
hasheous_id?: (number | null);
tgdb_id?: (number | null);
flashpoint_id?: (number | null);
category?: (string | null);
generation?: (number | null);
family_name?: (string | null);

View File

@@ -413,6 +413,26 @@ watch(
<span>{{ currentPlatform.hasheous_id }}</span>
</v-chip>
</a>
<v-chip
v-if="currentPlatform.flashpoint_id"
class="px-0 ml-1 mt-1"
size="small"
title="Flashpoint"
>
<v-avatar class="bg-surface" size="30" rounded="0">
<v-img src="/assets/scrappers/flashpoint.png" />
</v-avatar>
</v-chip>
<v-chip
v-if="currentPlatform.hltb_slug"
class="px-0 ml-1 mt-1"
size="small"
title="HLTB"
>
<v-avatar class="bg-surface" size="30" rounded="0">
<v-img src="/assets/scrappers/hltb.png" />
</v-avatar>
</v-chip>
</v-col>
</v-row>
<v-card class="mt-4 bg-toplayer fill-width" elevation="0">

View File

@@ -249,6 +249,16 @@ function updateOptions({ sortBy }: { sortBy: SortBy }) {
<v-img src="/assets/scrappers/ra.png" />
</v-avatar>
</v-chip>
<v-chip
v-if="item.flashpoint_id"
class="mr-1 pa-0 item-chip"
size="x-small"
title="Flashpoint match"
>
<v-avatar size="20" rounded>
<v-img src="/assets/scrappers/flashpoint.png" />
</v-avatar>
</v-chip>
<v-chip
v-if="item.hltb_id"
class="mr-1 pa-0 item-chip"