Skip to content

Commit

Permalink
Actually save things. See #452
Browse files Browse the repository at this point in the history
  • Loading branch information
breyten committed Jan 24, 2024
1 parent 9c25261 commit 54df2c6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ocd_backend/extractors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ def check_if_most_recent(self, provider, site_name, id, report_dict):
old_item = self.session.query(ItemHash).filter(ItemHash.item_id == item_id).first()
if old_item:
old_item.item_hash = new_hash
self.session.commit()
new_item = ItemHash(item_id=item_id, item_hash=new_hash)
self.session.add(new_item)
self.session.commit()
self.session.flush()
if old_item:
return (old_item.item_hash == new_hash)
else:
new_item = ItemHash(item_id=item_id, item_hash=new_hash)
self.session.commit()
return True
return False

def run(self):
"""Starts the extraction process.
Expand Down

0 comments on commit 54df2c6

Please sign in to comment.