Sha256: ad9605c39897de228a71408d0c62130f778d746f0902c629e15950ca7ea1e4d1

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

# -*- encoding: utf-8 -*-

require "enumerize"
require "default_value_for"
require "active_model_serializers"

require "task-manager/api_constraints"
require "task-manager/engine"
require "task-manager/deadline_calculator"
require "task-manager/deadline_validator"

module TaskManager

  # 创建计划任务
  #
  # 首先,获取所有需要生成计划任务的计划,参见{TaskManager::Plan.active}。
  # 然后调用{TaskManager::Plan#generate_tasks}生成计划任务。
  def self.generate_tasks
    Plan.active.collect(&:generate_tasks).flatten
  end

  # 找到刚刚过期的计划任务,然后调用{TaskManager::Task#expire}。
  def self.expire_tasks
    tasks = Task.just_expired
    tasks.each(&:expire)

    tasks
  end

  # 通知任务执行者,任务即将到期。参见{TaskManager::Task#remind}
  def self.remind_assignees_of_expiring_tasks
    tasks = Task.remindable
    tasks.each(&:remind)

    tasks
  end

  def self.finish_autocompletable_tasks
    Task.autocompletable.just_expired.each(&:finish)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
task-manager-0.1.7 lib/task-manager.rb
task-manager-0.1.6 lib/task-manager.rb