Skip to content

Commit

Permalink
Removed conditional update, only when values changed. The current cod…
Browse files Browse the repository at this point in the history
…e *might* do this, logic is unclear.
  • Loading branch information
sfisher committed Oct 8, 2024
1 parent 9a41960 commit 215b35c
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions ezidapp/management/commands/proc-link-checker-update.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,15 @@ def run(self):
si2 = ezidapp.models.identifier.SearchIdentifier.objects.get(
identifier=si.identifier
)
# get before values for OpenSearchDoc for link/issues
before_link_is_broken = si2.linkIsBroken
before_has_issues = si2.hasIssues

si2.linkIsBroken = newValue
si2.computeHasIssues()

# only update if the record is "dirty" and the values have changed
if before_link_is_broken != si2.linkIsBroken or before_has_issues != si2.hasIssues:
si2.updateTime = int(time.time())
si2.save(update_fields=["updateTime", "linkIsBroken", "hasIssues"])
open_s = OpenSearchDoc(identifier=si2)
open_s.update_link_issues(link_is_broken=si2.linkIsBroken,
has_issues=si2.hasIssues,
update_time=si2.updateTime)
si2.updateTime = int(time.time())
si2.save(update_fields=["updateTime", "linkIsBroken", "hasIssues"])
open_s = OpenSearchDoc(identifier=si2)
open_s.update_link_issues(link_is_broken=si2.linkIsBroken,
has_issues=si2.hasIssues,
update_time=si2.updateTime)
except ezidapp.models.identifier.SearchIdentifier.DoesNotExist:
log.exception('SearchIdentifier.DoesNotExist')
except opensearchpy.exceptions.OpenSearchException as e:
Expand Down

0 comments on commit 215b35c

Please sign in to comment.