Skip to content

Commit

Permalink
Deleted method
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitri committed Dec 19, 2024
1 parent 54811be commit 4b3dc2e
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions services/sources/publisher_backlist_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def delete_work(self, record_metadata_dict):
record_uuid_str = str(record.uuid)
edition = self.db_manager.session.query(Edition).filter(Edition.dcdw_uuids.contains([record_uuid_str])).first()
work = self.db_manager.session.query(Work).filter(Work.id == edition.work_id).first()
if self.has_only_one_edition(work):
if len(work.editions) == 1:
work_uuid_str = str(work.uuid)
es_work_resp = Search(index=os.environ['ELASTICSEARCH_INDEX']).query('match', uuid=work_uuid_str)
self.db_manager.session.query(Work).filter(Work.id == edition.work_id).delete()
Expand All @@ -80,11 +80,6 @@ def delete_work(self, record_metadata_dict):
logger.exception('Work/Edition does not exist or failed to delete work: {work.id}')
finally:
self.db_manager.session.close()

def has_only_one_edition(self, work):
if len(work.editions) > 1:
return False
return True

def delete_pub_backlist_edition_only(self, record_uuid_str, work):
edition = self.db_manager.session.query(Edition) \
Expand Down

0 comments on commit 4b3dc2e

Please sign in to comment.