active_admin_delayed_job 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZGU5M2YyMDhjMGNlOTYzNzM0MzdjNzU1NDIzYjhlNWE3ZjM1ZTEzMA==
5
+ data.tar.gz: !binary |-
6
+ ZmQ4YmMxMzE3NzNmMTEyM2I3YTJhYTFjODE1NTNmYTY0MGEwZDM5YQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MzNlMzZkNTk5NjE1YzEyOTc0NDVjNzVjY2M3YjFmNjFiYWVjYWVjMzdkMjJm
10
+ NzE2ZWJhNTY3NTY3ZjNmOTIyYWE2MWJhY2Y1Y2E2ZjUxM2ZhNDMwNDU4ZDg1
11
+ ZmUxYmQwOTA0ZDc3YjU0ZTkzMmYxNzBlM2U4YzAzZmE5NWU5MTE=
12
+ data.tar.gz: !binary |-
13
+ NmE2NjQ4YTcxNGY4ODJmNzgyMDliOWUxOGQwNDQ5MzFlODhjYmI1ZGU5ZDQ0
14
+ Yjg2MGQzNjYwMDViODI4OWNkODQ3MGRlNmI1Y2Q4YWNmMWJhOTlkYWY3OGI1
15
+ ZDc1Yjg3ZmQ0MTA5MmJjNjgyZjZmN2I0OWE0ZTE4NWZlNGZiNTc=
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ *.rbc
2
+ *.sassc
3
+ .sass-cache
4
+ capybara-*.html
5
+ .rspec
6
+ /.bundle
7
+ /vendor/bundle
8
+ /log/*
9
+ /tmp/*
10
+ /db/*.sqlite3
11
+ /public/system/*
12
+ /coverage/
13
+ /spec/tmp/*
14
+ **.orig
15
+ rerun.txt
16
+ pickle-email-*.html
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+ gemspec
3
+
4
+ group :development, :test do
5
+ gem 'jquery-rails'
6
+ gem 'sqlite3'
7
+ gem 'sass-rails'
8
+ end
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 Darren Rush
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'ActiveAdminDelayedJob'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+
28
+ Bundler::GemHelper.install_tasks
29
+
30
+ require 'rake/testtask'
31
+
32
+ Rake::TestTask.new(:test) do |t|
33
+ t.libs << 'lib'
34
+ t.libs << 'test'
35
+ t.pattern = 'test/**/*_test.rb'
36
+ t.verbose = false
37
+ end
38
+
39
+
40
+ task :default => :test
@@ -0,0 +1,17 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "active_admin_delayed_job"
5
+ s.version = "1.0.0"
6
+ s.authors = ["Michael Bianco", "Darren Rush"]
7
+ s.email = ["mike@cliffsidemedia.com"]
8
+ s.homepage = "http://github.com/iloveitaly/active_admin_delayed_job"
9
+ s.summary = "A plug-and-play controller that lets you monitor and retry jobs easily."
10
+ s.description = "View all, running, failed, and queued jobs. Retry failed jobs."
11
+
12
+ s.files = `git ls-files`.split("\n")
13
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+
15
+ s.add_dependency 'activeadmin'
16
+ s.add_dependency 'delayed_job_active_record'
17
+ end
@@ -0,0 +1,19 @@
1
+ Delayed::Job.class_eval do
2
+
3
+ def state
4
+ return 'failed' unless failed_at.blank?
5
+ return 'running' unless locked_at.nil?
6
+ return 'scheduled' if run_at > created_at
7
+ return 'queued'
8
+ end
9
+
10
+ def retry!
11
+ j = self
12
+ j.run_at = Time.now
13
+ j.last_error = nil
14
+ j.failed_at = nil
15
+ j.attempts = 0
16
+ j.save
17
+ end
18
+
19
+ end
@@ -0,0 +1,77 @@
1
+ ActiveAdmin.register Delayed::Job, :as => "Background Job" do
2
+ menu label: "Background Jobs", title: 'Background Jobs', parent: "Dashboard"
3
+
4
+ actions :index, :show, :update, :edit, :destroy
5
+
6
+ filter :queue
7
+
8
+ batch_action 'Retry' do |selection|
9
+ Delayed::Job.find(selection).each do |job|
10
+ job.retry!
11
+ end
12
+
13
+ redirect_to self.send("#{ActiveAdmin.application.default_namespace}_background_jobs_path"), notice: "Retrying Jobs"
14
+ end
15
+
16
+ member_action :retry, method: :post do
17
+ job = Delayed::Job.find(params[:id])
18
+ job.retry!
19
+
20
+ # TODO there has got to be a better way to get the helper prefix
21
+ redirect_to self.send("#{ActiveAdmin.application.default_namespace}_background_jobs_path"), notice: "Retrying Job"
22
+ end
23
+
24
+ action_item only: :show do
25
+ link_to("Retry Job", self.send("retry_#{ActiveAdmin.application.default_namespace}_background_job_path", resource), method: :post)
26
+ end
27
+
28
+ index do
29
+ selectable_column
30
+ column :id
31
+ column :queue
32
+ column :priority
33
+ column :attempts
34
+
35
+ column :status do |job|
36
+ case job.state
37
+ when 'failed'
38
+ status_tag "Failed:", :error
39
+ span "#{job.last_error[0..100]}"
40
+ when 'running'
41
+ status_tag "Running", :warning
42
+ span "for #{time_ago_in_words(job.locked_at)} @ #{job.locked_by}"
43
+ when 'scheduled'
44
+ status_tag "Scheduled", :ok
45
+ span "for #{time_ago_in_words(job.run_at)} from now"
46
+ else
47
+ status_tag "Queued"
48
+ span "for #{time_ago_in_words(job.created_at)}"
49
+ end
50
+
51
+ end
52
+
53
+ actions defaults: true do |job|
54
+ link_to("Retry Job", self.send("retry_#{ActiveAdmin.application.default_namespace}_background_job_path", job), method: :post)
55
+ end
56
+ end
57
+
58
+ show do |job|
59
+ # customize handler + last_error fields
60
+ attributes_table *(default_attribute_table_rows - [:handler, :last_error]) do
61
+ row(:handler) { simple_format(job.handler) rescue "" }
62
+ row(:last_error) { simple_format(job.last_error) rescue "" }
63
+ end
64
+ end
65
+
66
+ # https://github.com/activeadmin/activeadmin/blob/9cfc45330e5ad31977b3ac7b2ccc1f8d6146c73f/lib/active_admin/views/pages/form.rb
67
+ form do |f|
68
+ f.inputs do
69
+ f.input :priority
70
+ f.input :handler
71
+ f.input :queue
72
+ end
73
+
74
+ f.actions
75
+ end
76
+
77
+ end
@@ -0,0 +1,20 @@
1
+ require 'activeadmin'
2
+
3
+ module ActiveAdminDelayedJob
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace ActiveAdminDelayedJob
6
+ engine_name 'active_admin_delayed_job'
7
+
8
+ initializer :active_admin_delayed_job do
9
+ ActiveAdmin.application.load_paths += Dir[File.dirname(__FILE__) + '/admin']
10
+ end
11
+
12
+ def self.activate
13
+ Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
14
+ Rails.application.config.cache_classes ? require(c) : load(c)
15
+ end
16
+ end
17
+
18
+ config.to_prepare &method(:activate).to_proc
19
+ end
20
+ end
@@ -0,0 +1,4 @@
1
+ require "active_admin_delayed_job/engine"
2
+
3
+ module ActiveAdminDelayedJob
4
+ end
data/readme.md ADDED
@@ -0,0 +1,20 @@
1
+ # Active Admin Delayed Job Controller
2
+ This module adds a plug-and-play controller to your existing Active Admin setup. It allows you to view and manage the delayed jobs in your queue.
3
+
4
+ # Installation
5
+ Add this to your Gemfile
6
+
7
+ ```
8
+ gem 'active_admin_delayed_job', :git => 'git://github.com/drush/active_admin_delayed_job.git'
9
+
10
+ # or from rubygems
11
+
12
+ gem 'active_admin_delayed_job'
13
+ ```
14
+
15
+ ## Features
16
+
17
+ * View all the delayed jobs in your system
18
+ * Filter to All, Running, Failed, and Queued jobs
19
+ * Select and Retry or Delete jobs
20
+
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active_admin_delayed_job
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Bianco
8
+ - Darren Rush
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-10-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activeadmin
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ! '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ! '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: delayed_job_active_record
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ description: View all, running, failed, and queued jobs. Retry failed jobs.
43
+ email:
44
+ - mike@cliffsidemedia.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - Gemfile
51
+ - MIT-LICENSE
52
+ - Rakefile
53
+ - active_admin_delayed_job.gemspec
54
+ - app/models/delayed_job_decorator.rb
55
+ - lib/active_admin_delayed_job.rb
56
+ - lib/active_admin_delayed_job/admin/delayed_jobs.rb
57
+ - lib/active_admin_delayed_job/engine.rb
58
+ - readme.md
59
+ homepage: http://github.com/iloveitaly/active_admin_delayed_job
60
+ licenses: []
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.1.11
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: A plug-and-play controller that lets you monitor and retry jobs easily.
82
+ test_files: []