Skip to content

Commit

Permalink
Merge pull request #182 from identity-research-lab/hotfix-export-to-g…
Browse files Browse the repository at this point in the history
…raph-typo

Fix race condition with reaping orphaned codes
  • Loading branch information
CoralineAda authored Dec 2, 2024
2 parents 57262a1 + 7c02bd8 commit 5e39463
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ GEM
racc (~> 1.4)
orm_adapter (0.5.0)
ostruct (0.6.0)
pg (1.5.7)
pg (1.5.9)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
Expand Down
10 changes: 6 additions & 4 deletions app/models/services/export_to_graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def populate_codes
context = question.context.name
persona.codes = []

# Clean up any Codes that are no longer associated with a Persona.
Code.reap_orphans

response.raw_codes.compact.uniq.each do |name|
if code = Code.find_or_create_by(name: name, context: context)
next unless code.valid?
Expand All @@ -49,8 +52,6 @@ def populate_codes
end
end

# Clean up any Codes that are no longer associated with a Persona.
Code.reap_orphans
end

# Creates Identity nodes and connects them to the associated Persona.
Expand All @@ -62,6 +63,9 @@ def populate_identities
context = question.context.name
persona.identities = []

# Clean up any Identities that are no longer associated with a Persona.
Identity.reap_orphans

response.raw_codes.compact.uniq.each do |name|
if identity = Identity.find_or_create_by(name: name.strip, context: context)
next unless identity.valid?
Expand All @@ -70,8 +74,6 @@ def populate_identities
end
end

# Clean up any Identities that are no longer associated with a Persona.
Identity.reap_orphans
end

end
Expand Down
1 change: 1 addition & 0 deletions db/neo4j/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
- '20240323194853'
- '20240323195422'
- '20240325234413'
- '20240412021416'
- '20240522013044'
- '20240607210627'
- '20240615023034'
Expand Down

0 comments on commit 5e39463

Please sign in to comment.