1
0
Fork 0

Optimizing api, fixed bug when no tasks are shown

This commit is contained in:
Gregory Eremin 2013-06-10 16:32:25 +04:00
parent c98cd7648c
commit bba8bbcd07
9 changed files with 39 additions and 33 deletions

View File

@ -1,6 +1,7 @@
module BurdenWeb
class ApplicationController < ActionController::Base
def tasks
def rake_tasks
@rake_tasks ||= begin
Rails.application.load_tasks
Rake.application.tasks.keep_if do |task|
task.name =~ /^[a-z0-9_:]+$/
@ -8,3 +9,4 @@ module BurdenWeb
end
end
end
end

View File

@ -1,7 +1,7 @@
module BurdenWeb
class RunsController < ApplicationController
def index
@runs = Burden::Storage.run.history(params[:task_id])
@runs = Burden.runs.history(params[:task_id])
end
end
end

View File

@ -1,10 +1,10 @@
module BurdenWeb
class TasksController < ApplicationController
def index
@tasks = Burden::Storage.run.summary
(tasks.map(&:name) - @tasks.map(&:name)).each do |nr_task| # Never runned tasks
@tasks = Burden.runs.summary
(rake_tasks.map(&:name) - @tasks.map(&:name)).each do |nr_task| # Never runned tasks
next if ignore? nr_task
@tasks << Burden::Storage.run.new(
@tasks << Burden.runs.new(
name: nr_task
)
end

View File

@ -1,3 +1,3 @@
module BurdenWeb
VERSION = '0.1.1'
VERSION = '0.1.2'
end

View File

@ -11,11 +11,7 @@ require 'burden/version'
require 'burden/wrapper'
module Burden
include Config::Helper
def wrap(name, &block)
Wrapper.new(name, block).execute
end
extend self
extend Config::Helper
extend Storage::Helper
extend Wrapper::Helper
end

View File

@ -16,7 +16,7 @@ module Burden
ActiveRecord::Base.establish_connection(conf)
begin
Storage.run.create(name: name, success: success, execution_time: execution_time, timestamp: timestamp)
Burden.runs.create(name: name, success: success, execution_time: execution_time, timestamp: timestamp)
rescue
log_to_stdout(:failed)
end

View File

@ -1,6 +1,8 @@
module Burden
module Storage
def run
module Helper
def runs
@storage_class ||= begin
case Burden.config.storage
when :active_record, :activerecord
require 'burden/storage/active_record/run'
@ -15,7 +17,7 @@ module Burden
raise Exception.new("Unknown storage: #{storage}")
end
end
extend self
end
end
end
end

View File

@ -1,3 +1,3 @@
module Burden
VERSION = '0.1.1'
VERSION = '0.1.2'
end

View File

@ -54,5 +54,11 @@ module Burden
def save_statistics
Statistics.new(name: name, success: success, execution_time: execution_time, timestamp: timestamp).save
end
module Helper
def wrap(name, &block)
Wrapper.new(name, block).execute
end
end
end
end