From af9b47839ef26a6ebc4eb3386017c19a9759ce71 Mon Sep 17 00:00:00 2001 From: drusepth Date: Mon, 25 Oct 2021 21:06:07 -0700 Subject: [PATCH] safety on job --- app/jobs/cache_sum_attribute_word_count_job.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/jobs/cache_sum_attribute_word_count_job.rb b/app/jobs/cache_sum_attribute_word_count_job.rb index e8d8ebd4..63dad69a 100644 --- a/app/jobs/cache_sum_attribute_word_count_job.rb +++ b/app/jobs/cache_sum_attribute_word_count_job.rb @@ -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, )