Optimizing api, fixed bug when no tasks are shown
This commit is contained in:
parent
c98cd7648c
commit
bba8bbcd07
|
@ -1,9 +1,11 @@
|
||||||
module BurdenWeb
|
module BurdenWeb
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
def tasks
|
def rake_tasks
|
||||||
Rails.application.load_tasks
|
@rake_tasks ||= begin
|
||||||
Rake.application.tasks.keep_if do |task|
|
Rails.application.load_tasks
|
||||||
task.name =~ /^[a-z0-9_:]+$/
|
Rake.application.tasks.keep_if do |task|
|
||||||
|
task.name =~ /^[a-z0-9_:]+$/
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module BurdenWeb
|
module BurdenWeb
|
||||||
class RunsController < ApplicationController
|
class RunsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@runs = Burden::Storage.run.history(params[:task_id])
|
@runs = Burden.runs.history(params[:task_id])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
module BurdenWeb
|
module BurdenWeb
|
||||||
class TasksController < ApplicationController
|
class TasksController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@tasks = Burden::Storage.run.summary
|
@tasks = Burden.runs.summary
|
||||||
(tasks.map(&:name) - @tasks.map(&:name)).each do |nr_task| # Never runned tasks
|
(rake_tasks.map(&:name) - @tasks.map(&:name)).each do |nr_task| # Never runned tasks
|
||||||
next if ignore? nr_task
|
next if ignore? nr_task
|
||||||
@tasks << Burden::Storage.run.new(
|
@tasks << Burden.runs.new(
|
||||||
name: nr_task
|
name: nr_task
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
module BurdenWeb
|
module BurdenWeb
|
||||||
VERSION = '0.1.1'
|
VERSION = '0.1.2'
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,11 +11,7 @@ require 'burden/version'
|
||||||
require 'burden/wrapper'
|
require 'burden/wrapper'
|
||||||
|
|
||||||
module Burden
|
module Burden
|
||||||
include Config::Helper
|
extend Config::Helper
|
||||||
|
extend Storage::Helper
|
||||||
def wrap(name, &block)
|
extend Wrapper::Helper
|
||||||
Wrapper.new(name, block).execute
|
|
||||||
end
|
|
||||||
|
|
||||||
extend self
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,7 @@ module Burden
|
||||||
ActiveRecord::Base.establish_connection(conf)
|
ActiveRecord::Base.establish_connection(conf)
|
||||||
|
|
||||||
begin
|
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
|
rescue
|
||||||
log_to_stdout(:failed)
|
log_to_stdout(:failed)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,21 +1,23 @@
|
||||||
module Burden
|
module Burden
|
||||||
module Storage
|
module Storage
|
||||||
def run
|
module Helper
|
||||||
case Burden.config.storage
|
def runs
|
||||||
when :active_record, :activerecord
|
@storage_class ||= begin
|
||||||
require 'burden/storage/active_record/run'
|
case Burden.config.storage
|
||||||
Burden::Storage::ActiveRecord::Run
|
when :active_record, :activerecord
|
||||||
when :mongoid
|
require 'burden/storage/active_record/run'
|
||||||
require 'burden/storage/mongoid/run'
|
Burden::Storage::ActiveRecord::Run
|
||||||
Burden::Storage::Mongoid::Run
|
when :mongoid
|
||||||
when :mongo_mapper, :mongomapper
|
require 'burden/storage/mongoid/run'
|
||||||
require 'burden/storage/mongo_mapper/run'
|
Burden::Storage::Mongoid::Run
|
||||||
Burden::Storage::MongoMapper::Run
|
when :mongo_mapper, :mongomapper
|
||||||
else
|
require 'burden/storage/mongo_mapper/run'
|
||||||
raise Exception.new("Unknown storage: #{storage}")
|
Burden::Storage::MongoMapper::Run
|
||||||
|
else
|
||||||
|
raise Exception.new("Unknown storage: #{storage}")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
extend self
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
module Burden
|
module Burden
|
||||||
VERSION = '0.1.1'
|
VERSION = '0.1.2'
|
||||||
end
|
end
|
||||||
|
|
|
@ -54,5 +54,11 @@ module Burden
|
||||||
def save_statistics
|
def save_statistics
|
||||||
Statistics.new(name: name, success: success, execution_time: execution_time, timestamp: timestamp).save
|
Statistics.new(name: name, success: success, execution_time: execution_time, timestamp: timestamp).save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module Helper
|
||||||
|
def wrap(name, &block)
|
||||||
|
Wrapper.new(name, block).execute
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue