diff --git a/Gemfile.lock b/Gemfile.lock index 8a64e4d..1810bee 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/app/models/services/export_to_graph.rb b/app/models/services/export_to_graph.rb index d9189af..9ac3029 100644 --- a/app/models/services/export_to_graph.rb +++ b/app/models/services/export_to_graph.rb @@ -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? @@ -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. @@ -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? @@ -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 diff --git a/db/neo4j/schema.yml b/db/neo4j/schema.yml index 097e824..00c5a0c 100644 --- a/db/neo4j/schema.yml +++ b/db/neo4j/schema.yml @@ -40,6 +40,7 @@ - '20240323194853' - '20240323195422' - '20240325234413' +- '20240412021416' - '20240522013044' - '20240607210627' - '20240615023034'