doorcontrol: Add some more debug logging in update_doors task
All checks were successful
Ruff / ruff (push) Successful in 1m14s
Test / test (push) Successful in 3m48s

This commit is contained in:
Adam Goldsmith 2024-09-01 21:36:24 -04:00
parent ee48d286c2
commit b056eb04ed

View File

@ -208,11 +208,14 @@ class DoorMember:
def update_door(door: Door, dry_run: bool = False): def update_door(door: Door, dry_run: bool = False):
logger.info(f"Updating {door}")
logger.debug(f"Fetching members from database for {door}")
members = [ members = [
DoorMember.from_membershipworks_member(membershipworks_member, door) DoorMember.from_membershipworks_member(membershipworks_member, door)
for membershipworks_member in (Member.objects.with_is_active()).all() for membershipworks_member in (Member.objects.with_is_active()).all()
] ]
logger.debug(f"Fetching cardholders from {door}")
cardholders = { cardholders = {
member.membershipworks_id: member member.membershipworks_id: member
for member in [ for member in [
@ -221,11 +224,13 @@ def update_door(door: Door, dry_run: bool = False):
] ]
} }
logger.debug(f"Fetching credentials from {door}")
existing_door_credentials = { existing_door_credentials = {
Credential.from_hex(c.attrib["rawCardNumber"]) Credential.from_hex(c.attrib["rawCardNumber"])
for c in door.controller.get_credentials() for c in door.controller.get_credentials()
} }
logger.debug(f"Syncing members with {door}")
# TODO: can I combine requests? # TODO: can I combine requests?
for member in members: for member in members:
# cardholder did not exist, so add them # cardholder did not exist, so add them