Module: ArcGISKmzFeatures
- Defined in:
- lib/spatial_features/import/arcgis_kmz_features.rb
Defined Under Namespace
Classes: UpdateError
Instance Method Summary collapse
- #failed_feature_update_jobs ⇒ Object
- #feature_update_error ⇒ Object
- #feature_update_jobs ⇒ Object
- #queue_feature_update!(options = {}) ⇒ Object
- #running_feature_update_jobs ⇒ Object
- #update_features!(options = {}) ⇒ Object
- #updating_features? ⇒ Boolean
Instance Method Details
#failed_feature_update_jobs ⇒ Object
49 50 51 |
# File 'lib/spatial_features/import/arcgis_kmz_features.rb', line 49 def failed_feature_update_jobs feature_update_jobs.where.not(failed_at: nil) end |
#feature_update_error ⇒ Object
41 42 43 |
# File 'lib/spatial_features/import/arcgis_kmz_features.rb', line 41 def feature_update_error (failed_feature_update_jobs.first.try(:last_error) || '').split("\n").first end |
#feature_update_jobs ⇒ Object
53 54 55 |
# File 'lib/spatial_features/import/arcgis_kmz_features.rb', line 53 def feature_update_jobs Delayed::Job.where(queue: delayed_jobs_queue_name) end |
#queue_feature_update!(options = {}) ⇒ Object
33 34 35 |
# File 'lib/spatial_features/import/arcgis_kmz_features.rb', line 33 def queue_feature_update!( = {}) Delayed::Job.enqueue ArcGISUpdateFeaturesJob.new(.merge :spatial_model_type => self.class, :spatial_model_id => self.id), :queue => delayed_jobs_queue_name end |
#running_feature_update_jobs ⇒ Object
45 46 47 |
# File 'lib/spatial_features/import/arcgis_kmz_features.rb', line 45 def running_feature_update_jobs feature_update_jobs.where(failed_at: nil) end |
#update_features!(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/spatial_features/import/arcgis_kmz_features.rb', line 5 def update_features!( = {}) @skip_invalid = [:skip_invalid] @make_valid = [:make_valid] @feature_error_messages = [] kml_array = [] cache_kml = '' Array(arcgis_kmz_url).each do |url| kml_array << open_kmz_url(url) cache_kml << kml_array.last.to_s end if has_spatial_features_hash? new_features_hash = Digest::MD5.hexdigest(cache_kml) if cache_kml.present? if new_features_hash != self.features_hash replace_features(kml_array) update_attributes(:features_hash => new_features_hash) else return false end else replace_features(kml_array) end return true end |
#updating_features? ⇒ Boolean
37 38 39 |
# File 'lib/spatial_features/import/arcgis_kmz_features.rb', line 37 def updating_features? running_feature_update_jobs.exists? end |