From d438ae270e599a4a2f0b8cef17d7cb3fa84595e7 Mon Sep 17 00:00:00 2001 From: jbukhari Date: Tue, 30 Jul 2024 18:37:51 -0400 Subject: [PATCH] Last update cleared check fix (#140) * account for records that were created and updated since last export * ignore update cleared check if callback success --- dlx_dl/scripts/sync/__init__.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dlx_dl/scripts/sync/__init__.py b/dlx_dl/scripts/sync/__init__.py index 0dec0f1..cde82b0 100644 --- a/dlx_dl/scripts/sync/__init__.py +++ b/dlx_dl/scripts/sync/__init__.py @@ -176,10 +176,12 @@ def run(**kwargs): if last_exported['time'] > dl_last_updated: flag = 'UPDATE' + print(f'Last update not cleared in DL yet ({flag}) ({args.type}# {last_exported["record_id"]} @ {last_exported["time"]})') except AssertionError as e: if last_exported['export_type'] == 'NEW': # last record not in DL yet flag = 'NEW' + print(f'Last new record has been imported to DL but is awaiting search indexing ({flag}) ({args.type}# {last_exported["record_id"]} @ {last_exported["time"]})') else: raise Exception(f'Last updated record not found by DL search API: {last_dl_record["record_type"]} {last_exported["record_id"]}') @@ -198,13 +200,14 @@ def run(**kwargs): if callback_data['results'][0]['success'] == False: # the last export was exported succesfully, but failed on import to DL. proceed with export pass - else: - # the last export has been imported to DL but is awaiting search indexing - print(f'last new record has been imported to DL but is awaiting search indexing ({flag}) ({args.type}# {last_exported["record_id"]} @ {last_exported["time"]})') + elif flag == 'NEW': + # the record has been imported to DL but isn't searchable yet exit() + else: + # the record was exported and imported to DL succesfully, but DL did not record the update in + # the 005 field. this can happen if there were no changes to be made to the DL record. + warn(f'Possible redundant export not recorded in DL: {flag} {args.type}# {last_exported["record_id"]}') else: - # the last export has not been imported by DL yet - print(f'last update not cleared in DL yet ({flag}) ({args.type}# {last_exported["record_id"]} @ {last_exported["time"]})') exit() # cycle through records in batches