From e3a7684865fe877fca0bdc0ec1870dbaf77bb472 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 18 Jul 2022 16:56:35 +0200 Subject: [PATCH] sync only wb devices --- ereuse_devicehub/resources/device/sync.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ereuse_devicehub/resources/device/sync.py b/ereuse_devicehub/resources/device/sync.py index df02d451..46850303 100644 --- a/ereuse_devicehub/resources/device/sync.py +++ b/ereuse_devicehub/resources/device/sync.py @@ -115,6 +115,7 @@ class Sync: - A flag stating if the device is new or it already existed in the DB. """ + # if device.serial_number == 'b8oaas048286': assert inspect(component).transient, 'Component should not be synced from DB' # if not is a DataStorage, then need build a new one if component.t in DEVICES_ALLOW_DUPLICITY: @@ -126,7 +127,7 @@ class Sync: try: if component.hid: db_component = Device.query.filter_by( - hid=component.hid, owner_id=g.user.id + hid=component.hid, owner_id=g.user.id, placeholder=None ).one() assert isinstance( db_component, Device @@ -185,18 +186,24 @@ class Sync: if device.system_uuid: with suppress(ResourceNotFound): db_device = Computer.query.filter_by( - system_uuid=device.system_uuid, owner_id=g.user.id, active=True + system_uuid=device.system_uuid, + owner_id=g.user.id, + active=True, + placeholder=None, ).one() # if no there are any Computer by uuid search by hid if not db_device and device.hid: with suppress(ResourceNotFound): db_device = Device.query.filter_by( - hid=device.hid, owner_id=g.user.id, active=True + hid=device.hid, + owner_id=g.user.id, + active=True, + placeholder=None, ).one() elif device.hid: with suppress(ResourceNotFound): db_device = Device.query.filter_by( - hid=device.hid, owner_id=g.user.id, active=True + hid=device.hid, owner_id=g.user.id, active=True, placeholder=None ).one() if db_device and db_device.allocated: