Module: SpatialFeatures::QueuedSpatialProcessing
- Extended by:
- ActiveSupport::Concern
- Included in:
- FeatureImport
- Defined in:
- lib/spatial_features/has_spatial_features/queued_spatial_processing.rb
Defined Under Namespace
Classes: SpatialProcessingJob
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.update_cached_status(record, method_name, state) ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 6
def self.update_cached_status(record, method_name, state)
return unless record.has_attribute?(:spatial_processing_status_cache)
cache = record.spatial_processing_status_cache
cache[method_name] = state
record.spatial_processing_status_cache = cache
record.update_column(:spatial_processing_status_cache, cache) if record.will_save_change_to_spatial_processing_status_cache?
end
|
Instance Method Details
#clear_feature_update_error_status ⇒ Object
#delay_update_features!(*args, priority: priority_offset + 0, **kwargs) ⇒ Object
25
26
27
|
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 25
def delay_update_features!(*args, priority: priority_offset + 0, **kwargs)
queue_spatial_task('update_features!', *args, priority:, **kwargs)
end
|
#failed_feature_update_jobs ⇒ Object
81
82
83
|
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 81
def failed_feature_update_jobs
spatial_processing_jobs('update_features!').where.not(failed_at: nil)
end
|
#feature_update_error ⇒ Object
69
70
71
|
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 69
def feature_update_error
(failed_feature_update_jobs.first.try(:last_error) || '').split("\n").first
end
|
#queue_update_spatial_cache(*args, priority: priority_offset + 1, **kwargs) ⇒ Object
21
22
23
|
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 21
def queue_update_spatial_cache(*args, priority: priority_offset + 1, **kwargs)
queue_spatial_task('update_spatial_cache', *args, priority:, **kwargs)
end
|
#queued_feature_update_jobs ⇒ Object
77
78
79
|
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 77
def queued_feature_update_jobs
spatial_processing_jobs('update_features!').where(failed_at: nil, locked_at: nil)
end
|
#running_feature_update_jobs ⇒ Object
73
74
75
|
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 73
def running_feature_update_jobs
spatial_processing_jobs('update_features!').where(failed_at: nil).where.not(locked_at: nil)
end
|
#spatial_processing_jobs(method_name = nil) ⇒ Object
85
86
87
|
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 85
def spatial_processing_jobs(method_name = nil)
Delayed::Job.where('queue LIKE ?', "#{spatial_processing_queue_name}#{method_name}%")
end
|
#spatial_processing_status(method_name, use_cache: true) ⇒ Object
48
49
50
51
52
53
|
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 48
def spatial_processing_status(method_name, use_cache: true)
if has_attribute?(:spatial_processing_status_cache)
update_spatial_processing_status(method_name) unless use_cache
spatial_processing_status_cache[method_name.to_s]&.to_sym
end
end
|
#spatial_processing_status_cache ⇒ Object
15
16
17
18
19
|
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 15
def spatial_processing_status_cache
value = super
return {} unless value.is_a?(Hash)
return value
end
|
#update_spatial_processing_status(method_name) ⇒ Object
#updating_features?(**options) ⇒ Boolean
29
30
31
32
33
34
35
36
|
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 29
def updating_features?(**options)
case spatial_processing_status(:update_features!, **options)
when :queued, :processing
true
else
false
end
end
|
#updating_features_failed? ⇒ Boolean
44
45
46
|
# File 'lib/spatial_features/has_spatial_features/queued_spatial_processing.rb', line 44
def updating_features_failed?
spatial_processing_status(:update_features!) == :failure
end
|