Module: Mutx::Tasks

Defined in:
lib/mutx/tasks/task.rb,
lib/mutx/tasks/tasks.rb,
lib/mutx/tasks/custom/param.rb,
lib/mutx/tasks/custom/params.rb

Defined Under Namespace

Modules: Custom Classes: Task

Class Method Summary collapse

Class Method Details

.delete!(task_id) ⇒ Object



137
138
139
140
141
142
143
144
145
146
147
# File 'lib/mutx/tasks/tasks.rb', line 137

def self.delete! task_id
  if self.exist_task? task_id
    Mutx::Database::MongoConnector.delete_task task_id
    success = true
    message = "Task deleted!"
  else
    success = false
    message = "Could not find task with id '#{task_id}'"
  end
  {success:success, message:message}
end

.exist?(task_id) ⇒ Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/mutx/tasks/tasks.rb', line 125

def self.exist? task_id
    self.exist_task? task_id
end

.exist_task?(task_id) ⇒ Boolean

Returns:

  • (Boolean)


121
122
123
# File 'lib/mutx/tasks/tasks.rb', line 121

def self.exist_task? task_id
  !Mutx::Database::MongoConnector.task_data_for(task_id).nil?
end

.is_there_running_executions_for?(task_name) ⇒ Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/mutx/tasks/tasks.rb', line 129

def self.is_there_running_executions_for? task_name
    self.number_of_running_executions_for_task(task_name)>0
end

.is_there_task_with?(name, type = nil) ⇒ Boolean

unless existing_tasks_ids.empty?

  existing_tasks_ids.each do |task_id|
    # task = Mutx::Tasks::Task.get(task_id)
    # task.deactivate!
    Mutx::Tasks.delete! task_id
  end
end

end

Returns:

  • (Boolean)


91
92
93
# File 'lib/mutx/tasks/tasks.rb', line 91

def self.is_there_task_with? name, type=nil
  self.task_id_for name, type
end

.number_of_running_executions_for_task(task_name) ⇒ Object



133
134
135
# File 'lib/mutx/tasks/tasks.rb', line 133

def self.number_of_running_executions_for_task task_name
  Mutx::Database::MongoConnector.running_for_task(task_name).size
end

.reset!Object



149
150
151
152
153
154
# File 'lib/mutx/tasks/tasks.rb', line 149

def self.reset!
  Mutx::Support::Log.debug "Resetting tasks status" if Mutx::Support::Log
  self.running_tasks.each do |task|
    Mutx::Tasks::Task.get(task["_id"]).set_ready!
  end
end

.running_tasksArray

Returns the ids for running tasks

Returns:

  • (Array)

    of task ids



113
114
115
# File 'lib/mutx/tasks/tasks.rb', line 113

def self.running_tasks
  Mutx::Database::MongoConnector.running_tasks
end

.running_testsObject



117
118
119
# File 'lib/mutx/tasks/tasks.rb', line 117

def self.running_tests
  Mutx::Database::MongoConnector.running_tests
end

.task_id_for(task_name, type = nil) ⇒ Fixnum

Returns the id for given task name

Parameters:

  • task (String)

    name

Returns:

  • (Fixnum)

    task id



106
107
108
109
# File 'lib/mutx/tasks/tasks.rb', line 106

def self.task_id_for(task_name, type=nil)
  Mutx::Support::Log.debug "Tasks:Getting task id for #{task_name}" if Mutx::Support::Log
  Mutx::Database::MongoConnector.task_id_for(task_name, type)
end

.tasks(type = nil) ⇒ Array

Returns a list of tasks id

Parameters:

  • type (Boolean) (defaults to: nil)

    or not

Returns:

  • (Array)

    a list of task ids



98
99
100
101
# File 'lib/mutx/tasks/tasks.rb', line 98

def self.tasks type=nil
  Mutx::Support::Log.debug "Tasks:Getting all tasks ids" if Mutx::Support::Log
  Mutx::Database::MongoConnector.tasks(type)
end