Skip to content

Commit

Permalink
don't trigger model callbacks on wc cache updates
Browse files Browse the repository at this point in the history
  • Loading branch information
drusepth committed Dec 2, 2022
1 parent f054db2 commit 077714f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/jobs/cache_attribute_word_count_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def perform(*args)

# If we have a blank/null value, ezpz 0 words
if attribute.nil? || attribute.value.nil? || attribute.value.blank?
attribute.update!(word_count_cache: 0)
attribute.update_column(:word_count_cache, 0)
return
end

Expand All @@ -29,6 +29,6 @@ def perform(*args)
stray_punctuation: 'ignore'
).count(attribute.value)

attribute.update!(word_count_cache: word_count)
attribute.update_column(:word_count_cache, word_count)
end
end
2 changes: 1 addition & 1 deletion lib/tasks/cache.rake
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace :cache do

content_type.order('updated_at DESC').find_each do |entity|
sum_attribute_word_count = Attribute.where(entity_type: content_type.name, entity_id: entity.id).sum(:word_count_cache)
entity.update(cached_word_count: sum_attribute_word_count)
entity.update_column(:cached_word_count, sum_attribute_word_count)
end
end
end
Expand Down

0 comments on commit 077714f

Please sign in to comment.