misc: Refactor scan process by splitting single function

This change mainly refactors the `scan_platforms` function, moving part
of its logic to `_identify_platform`, `_identify_firmware`, and
`_identify_rom`.

The logic is simpler this way, each smaller function returns `ScanStats`
that can be merged by the caller, and it simplifies future performance
improvements.
This commit is contained in:
Michael Manganiello
2024-07-25 10:24:32 -03:00
parent e7e37f4680
commit 2bfc3c4c7e
3 changed files with 233 additions and 168 deletions

View File

@@ -29,7 +29,7 @@ class DBPlatformsHandler(DBBaseHandler):
@with_roms
def add_platform(
self, platform: Platform, query: Query = None, session: Session = None
) -> Platform | None:
) -> Platform:
platform = session.merge(platform)
session.flush()