X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/9ac2a7d67db543a0356bdcc7c3ca37920086eae1..4f03b29b3efb42a48c3f397942d5b618b89390eb:/services/api/app/models/pipeline_instance.rb diff --git a/services/api/app/models/pipeline_instance.rb b/services/api/app/models/pipeline_instance.rb index bc10523a36..f84c4a310f 100644 --- a/services/api/app/models/pipeline_instance.rb +++ b/services/api/app/models/pipeline_instance.rb @@ -10,6 +10,7 @@ class PipelineInstance < ArvadosModel before_validation :bootstrap_components before_validation :update_state before_validation :verify_status + before_validation :update_timestamps_when_state_changes before_create :set_state_before_save before_save :set_state_before_save @@ -112,30 +113,6 @@ class PipelineInstance < ArvadosModel end end - def dependency_search(haystack) - if haystack.is_a? String - if (re = haystack.match /^([0-9a-f]{32}(\+[^,]+)*)+/) - {re[1] => true} - else - {} - end - elsif haystack.is_a? Array - deps = {} - haystack.each do |value| - deps.merge! dependency_search(value) - end - deps - elsif haystack.respond_to? :keys - deps = {} - haystack.each do |key, value| - deps.merge! dependency_search(value) - end - deps - else - {} - end - end - def verify_status changed_attributes = self.changed @@ -160,4 +137,17 @@ class PipelineInstance < ArvadosModel end end + def update_timestamps_when_state_changes + return if not (state_changed? or new_record?) + + case state + when RunningOnServer, RunningOnClient + self.started_at ||= db_current_time + when Failed, Complete + current_time = db_current_time + self.started_at ||= current_time + self.finished_at ||= current_time + end + end + end