Refactor sync_from_state method in Room model; update parameter types for section_map and function_map to improve clarity and consistency

This commit is contained in:
Yaro Kasear 2025-06-25 11:34:45 -05:00
parent 543494120c
commit eddaa69158
5 changed files with 46 additions and 47 deletions

View file

@ -50,6 +50,7 @@ class Area(db.Model):
# Record real (non-temp) IDs # Record real (non-temp) IDs
try: try:
if raw_id is not None:
parsed_id = int(raw_id) parsed_id = int(raw_id)
if parsed_id >= 0: if parsed_id >= 0:
seen_ids.add(parsed_id) seen_ids.add(parsed_id)

View file

@ -44,6 +44,7 @@ class Brand(db.Model):
submitted_clean.append({"id": raw_id, "name": name}) submitted_clean.append({"id": raw_id, "name": name})
try: try:
if raw_id:
parsed_id = int(raw_id) parsed_id = int(raw_id)
if parsed_id >= 0: if parsed_id >= 0:
seen_ids.add(parsed_id) seen_ids.add(parsed_id)

View file

@ -47,6 +47,7 @@ class Item(db.Model):
continue continue
try: try:
if raw_id:
parsed_id = int(raw_id) parsed_id = int(raw_id)
if parsed_id >= 0: if parsed_id >= 0:
seen_ids.add(parsed_id) seen_ids.add(parsed_id)

View file

@ -44,6 +44,7 @@ class RoomFunction(db.Model):
continue continue
try: try:
if raw_id:
parsed_id = int(raw_id) parsed_id = int(raw_id)
if parsed_id >= 0: if parsed_id >= 0:
seen_ids.add(parsed_id) seen_ids.add(parsed_id)

View file

@ -46,12 +46,7 @@ class Room(db.Model):
} }
@classmethod @classmethod
def sync_from_state( def sync_from_state(cls, submitted_rooms: list[dict], section_map: dict[str, int], function_map: dict[str, int]) -> None:
cls,
submitted_rooms: list[dict],
section_map: dict[int, int],
function_map: dict[int, int]
):
""" """
Syncs the Rooms table with the submitted room list. Syncs the Rooms table with the submitted room list.
Resolves foreign keys using section_map and function_map. Resolves foreign keys using section_map and function_map.