class Traker::Service

Service that encapsulates main Traker API

Public Class Methods

new() click to toggle source
# File lib/traker/service.rb, line 8
def initialize
  @config = Traker::Config.load
end

Public Instance Methods

pending_tasks() click to toggle source
# File lib/traker/service.rb, line 12
def pending_tasks
  records = Traker::Task.where(name: tasks, environment: @config.env)
  actual = tasks.each_with_object({}) do |name, hash|
    record = records.find { |r| r.name == name }
    hash[name] = record ? record.run_count : 0
  end

  pending = []
  tasks.each do |name|
    actual[name] -= 1
    next if actual[name] >= 0

    pending << name
  end

  pending
end
tasks() click to toggle source
# File lib/traker/service.rb, line 30
def tasks
  @tasks ||= @config.tasks.map { |t| t['name'] }
end