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:
parent
543494120c
commit
eddaa69158
5 changed files with 46 additions and 47 deletions
|
@ -50,9 +50,10 @@ class Area(db.Model):
|
||||||
|
|
||||||
# Record real (non-temp) IDs
|
# Record real (non-temp) IDs
|
||||||
try:
|
try:
|
||||||
parsed_id = int(raw_id)
|
if raw_id is not None:
|
||||||
if parsed_id >= 0:
|
parsed_id = int(raw_id)
|
||||||
seen_ids.add(parsed_id)
|
if parsed_id >= 0:
|
||||||
|
seen_ids.add(parsed_id)
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,10 @@ class Brand(db.Model):
|
||||||
submitted_clean.append({"id": raw_id, "name": name})
|
submitted_clean.append({"id": raw_id, "name": name})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
parsed_id = int(raw_id)
|
if raw_id:
|
||||||
if parsed_id >= 0:
|
parsed_id = int(raw_id)
|
||||||
seen_ids.add(parsed_id)
|
if parsed_id >= 0:
|
||||||
|
seen_ids.add(parsed_id)
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -47,9 +47,10 @@ class Item(db.Model):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
parsed_id = int(raw_id)
|
if raw_id:
|
||||||
if parsed_id >= 0:
|
parsed_id = int(raw_id)
|
||||||
seen_ids.add(parsed_id)
|
if parsed_id >= 0:
|
||||||
|
seen_ids.add(parsed_id)
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,10 @@ class RoomFunction(db.Model):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
parsed_id = int(raw_id)
|
if raw_id:
|
||||||
if parsed_id >= 0:
|
parsed_id = int(raw_id)
|
||||||
seen_ids.add(parsed_id)
|
if parsed_id >= 0:
|
||||||
|
seen_ids.add(parsed_id)
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -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.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue