mirror of
https://github.com/rommapp/romm.git
synced 2026-03-03 02:17:01 +00:00
some code cleaning
This commit is contained in:
@@ -29,10 +29,8 @@ class DBHandler:
|
||||
self.cur = self.conn.cursor()
|
||||
|
||||
|
||||
def create_platform_table(self,
|
||||
igdb_id: str, sgdb_id: str,
|
||||
slug: str, name: str,
|
||||
path_logo: str) -> None:
|
||||
def regenerate_platform_table(self, igdb_id: str, sgdb_id: str,
|
||||
slug: str, name: str, path_logo: str) -> None:
|
||||
try:
|
||||
self.cur.execute(f"""
|
||||
create table if not exists {self.DATABASE}.{self.PLATFORM_TABLE}
|
||||
@@ -52,11 +50,8 @@ class DBHandler:
|
||||
raise HTTPException(status_code=500, detail=f"Can't truncate platform table. {e}")
|
||||
|
||||
|
||||
def create_rom_table(self,
|
||||
igdb_id: str, sgdb_id: str,
|
||||
platform_igdb_id: str, platform_sgdb_id: str,
|
||||
filename: str, name: str,
|
||||
path_cover: str) -> None:
|
||||
def regenerate_rom_table(self, igdb_id: str, sgdb_id: str, platform_igdb_id: str, platform_sgdb_id: str,
|
||||
filename: str, name: str, path_cover: str) -> None:
|
||||
try:
|
||||
self.cur.execute(f"""
|
||||
create table if not exists {self.DATABASE}.{self.ROM_TABLE}
|
||||
|
||||
@@ -13,7 +13,8 @@ from utils import fs, fastapi
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
origins = fastapi.allow_cors(app)
|
||||
fastapi.allow_cors(app)
|
||||
|
||||
igdbh: IGDBHandler = IGDBHandler()
|
||||
dbh: DBHandler = DBHandler()
|
||||
|
||||
@@ -35,7 +36,6 @@ async def scan(overwrite: bool=False):
|
||||
platforms: list = []
|
||||
|
||||
for slug in fs.get_platforms():
|
||||
# Fetch platforms details from igdb
|
||||
igdb_id, name, url_logo = igdbh.get_platform_details(slug)
|
||||
sgdb_id: str = ""
|
||||
|
||||
@@ -48,9 +48,8 @@ async def scan(overwrite: bool=False):
|
||||
|
||||
platforms.append(Platform(*details))
|
||||
|
||||
# Create tables if not exists, truncate them if exists.
|
||||
dbh.create_platform_table(*asdict(Platform()).keys())
|
||||
# Write platforms in database
|
||||
dbh.regenerate_platform_table(*asdict(Platform()).keys())
|
||||
|
||||
dbh.write_platforms(platforms)
|
||||
|
||||
return {'msg': 'success'}
|
||||
|
||||
Reference in New Issue
Block a user