Skip to content

Commit

Permalink
Merge pull request #23 from culturecode/rails-6
Browse files Browse the repository at this point in the history
Rails 6
  • Loading branch information
rywall committed Jun 11, 2021
2 parents 682cf58 + eaa79be commit 5003e3d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/models/abstract_feature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def feature_bounds
end

def cache_derivatives(*args)
self.class.where(:id => self.id).cache_derivatives(*args)
self.class.default_scoped.where(:id => self.id).cache_derivatives(*args)
end

def kml(options = {})
Expand Down
5 changes: 3 additions & 2 deletions app/models/feature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ def self.without_aggregate_refresh

def self.refresh_aggregates
# Find one feature from each spatial model and trigger the aggregate feature refresh
ids = select('MAX(id)')
.where.not(:spatial_model_type => nil, :spatial_model_id => nil)
ids = where.not(:spatial_model_type => nil)
.where.not(:spatial_model_id => nil)
.group('spatial_model_type, spatial_model_id')
.pluck('MAX(id)')

# Unscope so that newly built AggregateFeatures get their type column set correctly
AbstractFeature.unscoped { where(:id => ids).find_each(&:refresh_aggregate) }
Expand Down
4 changes: 2 additions & 2 deletions spatial_features.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Gem::Specification.new do |s|
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
s.test_files = Dir["test/**/*"]

s.add_runtime_dependency "rails", '>= 4.2', '< 6.0'
s.add_runtime_dependency "rails", '>= 4.2', '< 7.0'
s.add_runtime_dependency "delayed_job_active_record", '~> 4.1'
s.add_runtime_dependency "rgeo-shapefile", '~> 3.0'
s.add_runtime_dependency "rubyzip", '>= 1.0.0'
s.add_runtime_dependency "nokogiri", '~> 1.6'
s.add_runtime_dependency "chroma", "~> 0.1.0"

s.add_development_dependency "pg", '~> 0'
s.add_development_dependency "pg", '~> 1'
s.add_development_dependency "rspec", '~> 3.5'
end
4 changes: 2 additions & 2 deletions spec/support/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def create_record_with_polygon(klass, *coordinates)
record.features << build_polygon(coords)
end

record.update_attributes :features_hash => 'some new value'
record.update! :features_hash => 'some new value'

SpatialFeatures.cache_proximity(*Feature.pluck(:spatial_model_type).uniq.collect(&:constantize)) # automatically update spatial cache

Expand Down Expand Up @@ -61,7 +61,7 @@ def create_record_with_point(klass, *coordinates)
record.features << build_point(coords)
end

record.update_attributes :features_hash => 'some new value'
record.update! :features_hash => 'some new value'

SpatialFeatures.cache_proximity(*Feature.pluck(:spatial_model_type).uniq.collect(&:constantize)) # automatically update spatial cache

Expand Down

0 comments on commit 5003e3d

Please sign in to comment.