Skip to content

Commit af9b478

Browse files
committed
safety on job
1 parent 877990b commit af9b478

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

app/jobs/cache_sum_attribute_word_count_job.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ def perform(*args)
66
entity_id = args.shift
77

88
entity = entity_type.constantize.find_by(id: entity_id)
9-
sum_attribute_word_count = Attribute.where(entity_type: entity_type, entity_id: entity_id).sum(:word_count_cache)
9+
return if entity.nil?
1010

11+
sum_attribute_word_count = Attribute.where(entity_type: entity_type, entity_id: entity_id).sum(:word_count_cache)
1112
update = entity.word_count_updates.find_or_initialize_by(
1213
for_date: DateTime.current,
1314
)

0 commit comments

Comments
 (0)