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