safety on job

This commit is contained in:
drusepth 2021-10-25 21:06:07 -07:00
parent 877990bc15
commit af9b47839e

View File

@ -6,8 +6,9 @@ class CacheSumAttributeWordCountJob < ApplicationJob
entity_id = args.shift
entity = entity_type.constantize.find_by(id: entity_id)
sum_attribute_word_count = Attribute.where(entity_type: entity_type, entity_id: entity_id).sum(:word_count_cache)
return if entity.nil?
sum_attribute_word_count = Attribute.where(entity_type: entity_type, entity_id: entity_id).sum(:word_count_cache)
update = entity.word_count_updates.find_or_initialize_by(
for_date: DateTime.current,
)