Optimizing api, fixed bug when no tasks are shown
This commit is contained in:
parent
c98cd7648c
commit
bba8bbcd07
|
@ -1,10 +1,12 @@
|
||||||
module BurdenWeb
|
module BurdenWeb
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
def tasks
|
def rake_tasks
|
||||||
|
@rake_tasks ||= begin
|
||||||
Rails.application.load_tasks
|
Rails.application.load_tasks
|
||||||
Rake.application.tasks.keep_if do |task|
|
Rake.application.tasks.keep_if do |task|
|
||||||
task.name =~ /^[a-z0-9_:]+$/
|
task.name =~ /^[a-z0-9_:]+$/
|
||||||
end
|
end
|
||||||
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,6 +1,8 @@
|
||||||
module Burden
|
module Burden
|
||||||
module Storage
|
module Storage
|
||||||
def run
|
module Helper
|
||||||
|
def runs
|
||||||
|
@storage_class ||= begin
|
||||||
case Burden.config.storage
|
case Burden.config.storage
|
||||||
when :active_record, :activerecord
|
when :active_record, :activerecord
|
||||||
require 'burden/storage/active_record/run'
|
require 'burden/storage/active_record/run'
|
||||||
|
@ -15,7 +17,7 @@ module Burden
|
||||||
raise Exception.new("Unknown storage: #{storage}")
|
raise Exception.new("Unknown storage: #{storage}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
extend self
|
end
|
||||||
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