From 661e3b5212e2649870a200067d0d5d52fa962637 Mon Sep 17 00:00:00 2001 From: Jeff Keen Date: Tue, 16 Apr 2024 23:41:34 -0500 Subject: [PATCH] fix: rescue error from sideloads updated_at calculation, defaulting to the current time --- lib/graphiti/scope.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/graphiti/scope.rb b/lib/graphiti/scope.rb index 0b951260..a759a715 100644 --- a/lib/graphiti/scope.rb +++ b/lib/graphiti/scope.rb @@ -92,16 +92,17 @@ def cache_key_with_version end def updated_at - updated_ats = sideload_resource_proxies.map(&:updated_at) - + updated_time = nil begin + updated_ats = sideload_resource_proxies.map(&:updated_at) updated_ats << @object.maximum(:updated_at) + updated_time = updated_ats.compact.max rescue => e - Graphiti.log("error calculating last_modified_at for #{@resource.class}") + Graphiti.log(["error calculating last_modified_at for #{@resource.class}", :red]) Graphiti.log(e) end - updated_ats.compact.max + return updated_time || Time.now end alias_method :last_modified_at, :updated_at