Skip to content

Commit

Permalink
Last update cleared check fix (#140)
Browse files Browse the repository at this point in the history
* account for records that were created and updated since last export

* ignore update cleared check if callback success
  • Loading branch information
jbukhari authored Jul 30, 2024
1 parent 043be05 commit d438ae2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions dlx_dl/scripts/sync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}')

Expand All @@ -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
Expand Down

0 comments on commit d438ae2

Please sign in to comment.