Skip to content

Commit

Permalink
Replace existing attached relationships when time_attached is missing…
Browse files Browse the repository at this point in the history
… or different

If replace isn't used, a second relationship is created to the node.
  • Loading branch information
mprahl committed Jul 16, 2019
1 parent 8b22693 commit 70b5799
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions scrapers/errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,18 @@ def update_neo4j(self, advisories):
""".format(advisory['id'], nvr)
log.info('Getting the time build {0} was added to advisory {1}'.format(
nvr, advisory['id']))
time_attached = self.teiid.query(sql)

adv.attached_builds.connect(build, {'time_attached': time_attached})
time_attached_result = self.teiid.query(sql)
if time_attached_result:
time_attached = time_attached_result[0].get('created_at')
else:
time_attached = None

attached_rel = adv.attached_builds.relationship(build)
if attached_rel:
if attached_rel.time_attached != time_attached:
adv.attached_builds.replace(build, {'time_attached': time_attached})
else:
adv.attached_builds.connect(build, {'time_attached': time_attached})

assigned_to = User.get_or_create({'username': advisory['assigned_to'].split('@')[0]})[0]
adv.conditional_connect(adv.assigned_to, assigned_to)
Expand Down

0 comments on commit 70b5799

Please sign in to comment.