Class: AnalysisTask
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- AnalysisTask
- Defined in:
- app/models/dataset/analysis_task.rb
Overview
An analysis task run on a dataset
While the processing is actually occurring in a delayed job, we need a way for those delayed jobs to readily communicate with users via the web front-end. This model is how they do so.
Instance Attribute Summary (collapse)
-
- (DateTime) created_at
The time at which this task was started.
-
- (Dataset) dataset
The dataset to which this task belongs (belongs_to).
-
- (Boolean) failed
True if this job has failed.
-
- (DateTime) finished_at
The time at which this task was finished.
-
- (String) job_type
The class name of the job this task contains.
-
- (String) name
The name of this task.
-
- (Download) result_file
The results of this analysis task, if available.
Class Method Summary (collapse)
-
+ (Class) job_class(class_name)
Convert class_name to a class object.
Instance Method Summary (collapse)
-
- (Class) job_class
Convert #job_type into a class object.
Instance Attribute Details
- (DateTime) created_at
The time at which this task was started
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/models/dataset/analysis_task.rb', line 26 class AnalysisTask < ActiveRecord::Base validates :name, :presence => true validates :dataset_id, :presence => true validates :job_type, :presence => true belongs_to :dataset has_one :result_file, :class_name => 'Download', :dependent => :destroy attr_accessible :name, :dataset, :job_type scope :finished, where('finished_at IS NOT NULL') scope :not_finished, where('finished_at IS NULL') scope :active, not_finished.where(:failed => false) scope :failed, not_finished.where(:failed => true) # Convert class_name to a class object # # @api public # @param [String] class_name the class name to convert # @return [Class] the job class # @example Call the view_path method for ExportCitations # AnalysisTask.job_class('ExportCitations').view_path(...) def self.job_class(class_name) # Never let the 'Base' class match class_name = 'Jobs::Analysis::' + class_name raise ArgumentError if class_name == 'Jobs::Analysis::Base' begin klass = class_name.constantize raise ArgumentError unless klass.is_a?(Class) rescue NameError raise ArgumentError end klass end # Convert #job_type into a class object # # @api public # @return [Class] the job class # @example Call the view_path method for this task # task.job_class.view_path(...) def job_class self.class.job_class(job_type) end end |
- (Dataset) dataset
The dataset to which this task belongs (belongs_to)
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/models/dataset/analysis_task.rb', line 26 class AnalysisTask < ActiveRecord::Base validates :name, :presence => true validates :dataset_id, :presence => true validates :job_type, :presence => true belongs_to :dataset has_one :result_file, :class_name => 'Download', :dependent => :destroy attr_accessible :name, :dataset, :job_type scope :finished, where('finished_at IS NOT NULL') scope :not_finished, where('finished_at IS NULL') scope :active, not_finished.where(:failed => false) scope :failed, not_finished.where(:failed => true) # Convert class_name to a class object # # @api public # @param [String] class_name the class name to convert # @return [Class] the job class # @example Call the view_path method for ExportCitations # AnalysisTask.job_class('ExportCitations').view_path(...) def self.job_class(class_name) # Never let the 'Base' class match class_name = 'Jobs::Analysis::' + class_name raise ArgumentError if class_name == 'Jobs::Analysis::Base' begin klass = class_name.constantize raise ArgumentError unless klass.is_a?(Class) rescue NameError raise ArgumentError end klass end # Convert #job_type into a class object # # @api public # @return [Class] the job class # @example Call the view_path method for this task # task.job_class.view_path(...) def job_class self.class.job_class(job_type) end end |
- (Boolean) failed
True if this job has failed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/models/dataset/analysis_task.rb', line 26 class AnalysisTask < ActiveRecord::Base validates :name, :presence => true validates :dataset_id, :presence => true validates :job_type, :presence => true belongs_to :dataset has_one :result_file, :class_name => 'Download', :dependent => :destroy attr_accessible :name, :dataset, :job_type scope :finished, where('finished_at IS NOT NULL') scope :not_finished, where('finished_at IS NULL') scope :active, not_finished.where(:failed => false) scope :failed, not_finished.where(:failed => true) # Convert class_name to a class object # # @api public # @param [String] class_name the class name to convert # @return [Class] the job class # @example Call the view_path method for ExportCitations # AnalysisTask.job_class('ExportCitations').view_path(...) def self.job_class(class_name) # Never let the 'Base' class match class_name = 'Jobs::Analysis::' + class_name raise ArgumentError if class_name == 'Jobs::Analysis::Base' begin klass = class_name.constantize raise ArgumentError unless klass.is_a?(Class) rescue NameError raise ArgumentError end klass end # Convert #job_type into a class object # # @api public # @return [Class] the job class # @example Call the view_path method for this task # task.job_class.view_path(...) def job_class self.class.job_class(job_type) end end |
- (DateTime) finished_at
The time at which this task was finished
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/models/dataset/analysis_task.rb', line 26 class AnalysisTask < ActiveRecord::Base validates :name, :presence => true validates :dataset_id, :presence => true validates :job_type, :presence => true belongs_to :dataset has_one :result_file, :class_name => 'Download', :dependent => :destroy attr_accessible :name, :dataset, :job_type scope :finished, where('finished_at IS NOT NULL') scope :not_finished, where('finished_at IS NULL') scope :active, not_finished.where(:failed => false) scope :failed, not_finished.where(:failed => true) # Convert class_name to a class object # # @api public # @param [String] class_name the class name to convert # @return [Class] the job class # @example Call the view_path method for ExportCitations # AnalysisTask.job_class('ExportCitations').view_path(...) def self.job_class(class_name) # Never let the 'Base' class match class_name = 'Jobs::Analysis::' + class_name raise ArgumentError if class_name == 'Jobs::Analysis::Base' begin klass = class_name.constantize raise ArgumentError unless klass.is_a?(Class) rescue NameError raise ArgumentError end klass end # Convert #job_type into a class object # # @api public # @return [Class] the job class # @example Call the view_path method for this task # task.job_class.view_path(...) def job_class self.class.job_class(job_type) end end |
- (String) job_type
The class name of the job this task contains
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/models/dataset/analysis_task.rb', line 26 class AnalysisTask < ActiveRecord::Base validates :name, :presence => true validates :dataset_id, :presence => true validates :job_type, :presence => true belongs_to :dataset has_one :result_file, :class_name => 'Download', :dependent => :destroy attr_accessible :name, :dataset, :job_type scope :finished, where('finished_at IS NOT NULL') scope :not_finished, where('finished_at IS NULL') scope :active, not_finished.where(:failed => false) scope :failed, not_finished.where(:failed => true) # Convert class_name to a class object # # @api public # @param [String] class_name the class name to convert # @return [Class] the job class # @example Call the view_path method for ExportCitations # AnalysisTask.job_class('ExportCitations').view_path(...) def self.job_class(class_name) # Never let the 'Base' class match class_name = 'Jobs::Analysis::' + class_name raise ArgumentError if class_name == 'Jobs::Analysis::Base' begin klass = class_name.constantize raise ArgumentError unless klass.is_a?(Class) rescue NameError raise ArgumentError end klass end # Convert #job_type into a class object # # @api public # @return [Class] the job class # @example Call the view_path method for this task # task.job_class.view_path(...) def job_class self.class.job_class(job_type) end end |
- (String) name
The name of this task
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/models/dataset/analysis_task.rb', line 26 class AnalysisTask < ActiveRecord::Base validates :name, :presence => true validates :dataset_id, :presence => true validates :job_type, :presence => true belongs_to :dataset has_one :result_file, :class_name => 'Download', :dependent => :destroy attr_accessible :name, :dataset, :job_type scope :finished, where('finished_at IS NOT NULL') scope :not_finished, where('finished_at IS NULL') scope :active, not_finished.where(:failed => false) scope :failed, not_finished.where(:failed => true) # Convert class_name to a class object # # @api public # @param [String] class_name the class name to convert # @return [Class] the job class # @example Call the view_path method for ExportCitations # AnalysisTask.job_class('ExportCitations').view_path(...) def self.job_class(class_name) # Never let the 'Base' class match class_name = 'Jobs::Analysis::' + class_name raise ArgumentError if class_name == 'Jobs::Analysis::Base' begin klass = class_name.constantize raise ArgumentError unless klass.is_a?(Class) rescue NameError raise ArgumentError end klass end # Convert #job_type into a class object # # @api public # @return [Class] the job class # @example Call the view_path method for this task # task.job_class.view_path(...) def job_class self.class.job_class(job_type) end end |
- (Download) result_file
The results of this analysis task, if available
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/models/dataset/analysis_task.rb', line 26 class AnalysisTask < ActiveRecord::Base validates :name, :presence => true validates :dataset_id, :presence => true validates :job_type, :presence => true belongs_to :dataset has_one :result_file, :class_name => 'Download', :dependent => :destroy attr_accessible :name, :dataset, :job_type scope :finished, where('finished_at IS NOT NULL') scope :not_finished, where('finished_at IS NULL') scope :active, not_finished.where(:failed => false) scope :failed, not_finished.where(:failed => true) # Convert class_name to a class object # # @api public # @param [String] class_name the class name to convert # @return [Class] the job class # @example Call the view_path method for ExportCitations # AnalysisTask.job_class('ExportCitations').view_path(...) def self.job_class(class_name) # Never let the 'Base' class match class_name = 'Jobs::Analysis::' + class_name raise ArgumentError if class_name == 'Jobs::Analysis::Base' begin klass = class_name.constantize raise ArgumentError unless klass.is_a?(Class) rescue NameError raise ArgumentError end klass end # Convert #job_type into a class object # # @api public # @return [Class] the job class # @example Call the view_path method for this task # task.job_class.view_path(...) def job_class self.class.job_class(job_type) end end |
Class Method Details
+ (Class) job_class(class_name)
Convert class_name to a class object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/models/dataset/analysis_task.rb', line 48 def self.job_class(class_name) # Never let the 'Base' class match class_name = 'Jobs::Analysis::' + class_name raise ArgumentError if class_name == 'Jobs::Analysis::Base' begin klass = class_name.constantize raise ArgumentError unless klass.is_a?(Class) rescue NameError raise ArgumentError end klass end |
Instance Method Details
- (Class) job_class
Convert #job_type into a class object
69 70 71 |
# File 'app/models/dataset/analysis_task.rb', line 69 def job_class self.class.job_class(job_type) end |