app/models/feature.rb in spatial_features-2.19.0 vs app/models/feature.rb in spatial_features-2.19.1
- old
+ new
@@ -1,5 +1,7 @@
+require_dependency SpatialFeatures::Engine.root.join('app/models/abstract_feature')
+
class Feature < AbstractFeature
class_attribute :automatically_refresh_aggregate
self.automatically_refresh_aggregate = true
class_attribute :lowres_precision
@@ -50,11 +52,11 @@
# Unscope so that newly built AggregateFeatures get their type column set correctly
AbstractFeature.unscoped { where(:id => ids).find_each(&:refresh_aggregate) }
end
def refresh_aggregate
- build_aggregate_feature unless aggregate_feature&.persisted?
- aggregate_feature.refresh
+ aggregate_feature&.destroy # Destroy the existing aggregate feature to ensure its cache key changes when it is refreshed
+ create_aggregate_feature!
end
def automatically_refresh_aggregate?
# Check if there is a spatial model id because nothing prevents is from creating a Feature without one. Depending on
# how you assign a feature to a record, you may end up saving it before assigning it to a record, thereby leaving