From f5ab3c399abc65e2cd6f1e25b250eee45a17dfcd Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 17 Dec 2019 20:29:04 -0600 Subject: [PATCH] fix silly misthought --- app/jobs/cache_most_used_attribute_categories_job.rb | 7 ++++--- app/jobs/cache_most_used_attribute_fields_job.rb | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/jobs/cache_most_used_attribute_categories_job.rb b/app/jobs/cache_most_used_attribute_categories_job.rb index 15cc8bf9..c2f6985a 100644 --- a/app/jobs/cache_most_used_attribute_categories_job.rb +++ b/app/jobs/cache_most_used_attribute_categories_job.rb @@ -15,11 +15,12 @@ class CacheMostUsedAttributeCategoriesJob < ApplicationJob puts "Suggestion count: #{suggestions}" suggestions.each do |suggestion, weight| - AttributeCategorySuggestion.find_or_create_by!( + suggestion = AttributeCategorySuggestion.find_or_create_by!( entity_type: entity_type, - suggestion: suggestion, - weight: weight + suggestion: suggestion ) + suggestion.weight = weight + suggestion.save! end end end diff --git a/app/jobs/cache_most_used_attribute_fields_job.rb b/app/jobs/cache_most_used_attribute_fields_job.rb index 98c0c335..12ae8def 100644 --- a/app/jobs/cache_most_used_attribute_fields_job.rb +++ b/app/jobs/cache_most_used_attribute_fields_job.rb @@ -21,12 +21,13 @@ class CacheMostUsedAttributeFieldsJob < ApplicationJob puts "Suggestion count: #{suggestions}" suggestions.each do |suggestion, weight| - AttributeFieldSuggestion.find_or_create_by!( + suggestion = AttributeFieldSuggestion.find_or_initialize_by( entity_type: entity_type, category_label: category_label, - suggestion: suggestion, - weight: weight + suggestion: suggestion ) + suggestion.weight = weight + suggestion.save! end end end