fix: work around, log error when datasync can't locate member

This commit is contained in:
Lance Edgar 2024-08-14 09:12:32 -05:00
parent b4f8bb9c93
commit 802c8ab87b

View file

@ -24,11 +24,16 @@
DataSync for Rattail DB DataSync for Rattail DB
""" """
import logging
from sqlalchemy import orm from sqlalchemy import orm
from rattail.datasync import DataSyncImportConsumer from rattail.datasync import DataSyncImportConsumer
log = logging.getLogger(__name__)
class FromCOREAPIToRattail(DataSyncImportConsumer): class FromCOREAPIToRattail(DataSyncImportConsumer):
""" """
Consumer for CORE POS (API) -> Rattail datasync Consumer for CORE POS (API) -> Rattail datasync
@ -69,6 +74,11 @@ class FromCOREAPIToRattail(DataSyncImportConsumer):
else: else:
# import member data from API, into various Rattail tables # import member data from API, into various Rattail tables
member = self.get_host_object(session, change) member = self.get_host_object(session, change)
if not member:
# TODO: should log.warning() instead but for now i
# need to see this in action and further troubleshoot
log.error("CORE member not found for change: %s", change)
continue
self.process_change(session, self.importers['Customer'], self.process_change(session, self.importers['Customer'],
host_object=member) host_object=member)
shoppers = self.importers['CustomerShopper'].get_shoppers_for_member(member) shoppers = self.importers['CustomerShopper'].get_shoppers_for_member(member)