queue_classic_admin 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -7
  3. data/app/assets/javascripts/queue_classic_admin/application.js +0 -1
  4. data/app/assets/javascripts/queue_classic_admin/{queue_classic_later_jobs.js → queue_classic_scheduled_jobs.js} +0 -0
  5. data/app/assets/stylesheets/queue_classic_admin/application.css +1 -1
  6. data/app/assets/stylesheets/queue_classic_admin/{queue_classic_later_jobs.css → queue_classic_scheduled_jobs.css} +0 -0
  7. data/app/controllers/queue_classic_admin/application_controller.rb +11 -3
  8. data/app/controllers/queue_classic_admin/queue_classic_jobs_controller.rb +7 -9
  9. data/app/controllers/queue_classic_admin/queue_classic_scheduled_jobs_controller.rb +33 -0
  10. data/app/helpers/queue_classic_admin/application_helper.rb +0 -6
  11. data/app/helpers/queue_classic_admin/queue_classic_scheduled_jobs_helper.rb +4 -0
  12. data/app/models/queue_classic_admin/job_common.rb +1 -1
  13. data/app/models/queue_classic_admin/queue_classic_job.rb +3 -0
  14. data/app/views/layouts/queue_classic_admin/application.html.erb +1 -3
  15. data/app/views/queue_classic_admin/{queue_classic_later_jobs → queue_classic_scheduled_jobs}/index.html.erb +0 -0
  16. data/app/views/queue_classic_admin/shared/_job_list.html.erb +8 -7
  17. data/config/routes.rb +1 -1
  18. data/lib/queue_classic_admin.rb +0 -1
  19. data/lib/queue_classic_admin/version.rb +1 -1
  20. metadata +8 -24
  21. data/app/assets/stylesheets/scaffold.css +0 -56
  22. data/app/controllers/queue_classic_admin/queue_classic_later_jobs_controller.rb +0 -33
  23. data/app/helpers/queue_classic_admin/queue_classic_later_jobs_helper.rb +0 -4
  24. data/app/models/queue_classic_admin/queue_classic_later_job.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3319df3083270e6c8c83496f0162e6260eeeaaa0
4
- data.tar.gz: 9bf860fe44bc4e710ea2efefeb8e30848e2e2fd9
3
+ metadata.gz: be770c2f38dae73c292915265522e9311a4a8edc
4
+ data.tar.gz: d7f4418257899860ac907f083dcc71d06af53fb0
5
5
  SHA512:
6
- metadata.gz: caf72fb82c582f02ef96932d18544191b3d0776c988b4adc380818d49626f8300519e0fe68e6cf7683b9cd9d30929c178758d1cb3cb25ee7e11228f63a9f73fb
7
- data.tar.gz: 116638af8da5388b2fa82258034fc10d7283fd5f878af500cdf38a80225d9aa71973cffbaedf5a5a59dd9d8543e8b13897616b5cd61298f98e50b1af644d4b8a
6
+ metadata.gz: 1138e8c3b1d45c114d1713c3660f077024660b73fdce7bf91ce23fd76105ed4e574fde65acd80c219b5d823674ff1214af134893405eb3c3e85720ff7485ad9c
7
+ data.tar.gz: 4340000864136623df22517454d0301e654a318956358c2967cb4453993a64e75aa807d303c360cedf77f011c7c8673662fc020320d2fb12dd2e79b2195cd20d
data/README.md CHANGED
@@ -2,16 +2,15 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/QueueClassic/queue_classic_admin.png)](https://travis-ci.org/QueueClassic/queue_classic_admin)
4
4
 
5
- An admin interface for the [queue_classic](https://github.com/ryandotsmith/queue_classic) and [queue_classic-later](https://github.com/dpiddy/queue_classic-later) gems.
5
+ An admin interface for the [queue_classic](https://github.com/QueueClassic/queue_classic) gem.
6
6
 
7
- **IMPORTANT: this branch is for QueueClassic 3. See the [queueclassic-2-support](https://github.com/dpiddy/queue_classic-later/tree/queueclassic-2-support) branch for prior version support.**
7
+ **IMPORTANT**: this branch is for queue_classic 3.1. Support for queue_classic-later has been removed and replaced by queue_classic 3.1's implementation of scheduling instead. See the [queueclassic-2-support](https://github.com/QueueClassic/queue_classic_admin/tree/queueclassic-2-support) and [queueclassic-3-support](https://github.com/QueueClassic/queue_classic_admin/tree/queueclassic-3-support) branches for prior version support.
8
8
 
9
9
  ![qc admin](https://f.cloud.github.com/assets/148622/865030/9b1b2610-f62e-11e2-8908-8c271bfe0f6c.png)
10
10
 
11
-
12
11
  # Features
13
12
 
14
- * Support for [queue_classic-later](https://github.com/dpiddy/queue_classic-later)
13
+ * Support for QueueClassic 3.1's future job scheduling: **enqueue_at()** and **enqueue_in()**
15
14
  * Support for custom columns
16
15
  * Delete entire queues
17
16
  * Delete jobs
@@ -76,9 +75,6 @@ ln -s $PWD/spec/dummy ~/.pow/qc-admin
76
75
  # Run the engine's migration.
77
76
  bundle exec rake db:migrate
78
77
  (cd spec/dummy && bundle exec rake db:schema:dump)
79
-
80
- ln -s $PWD/spec/dummy-no-later ~/.pow/qc-admin-no-later
81
- (cd spec/dummy-no-later && bundle exec rake db:create:all db:migrate)
82
78
  ```
83
79
 
84
80
  Then go to [http://qc-admin.dev/](http://qc-admin.dev/).
@@ -12,5 +12,4 @@
12
12
  //
13
13
  //= require jquery
14
14
  //= require jquery_ujs
15
- //= require twitter/bootstrap
16
15
  //= require_tree .
@@ -9,7 +9,7 @@
9
9
  * compiled file, but it's generally better to create a new file per style scope.
10
10
  *
11
11
  *= require_self
12
- *= require twitter-bootstrap-static/bootstrap
12
+ *= require qc-admin-bootstrap/bootstrap.min
13
13
  *= require_tree .
14
14
  */
15
15
 
@@ -1,9 +1,17 @@
1
1
  module QueueClassicAdmin
2
2
  class ApplicationController < ActionController::Base
3
3
  protected
4
- def filter_jobs(klass)
5
- @klass = klass
6
- @queue_classic_jobs = klass.order("id DESC")
4
+ def filter_jobs
5
+ @queue_classic_jobs = QueueClassicJob.order("id DESC")
6
+
7
+ if self.class == QueueClassicScheduledJobsController
8
+ @scoped_jobs = QueueClassicJob.scheduled
9
+ @queue_classic_jobs = @queue_classic_jobs.scheduled
10
+ else
11
+ @scoped_jobs = QueueClassicJob.ready
12
+ @queue_classic_jobs = @queue_classic_jobs.ready
13
+ end
14
+
7
15
  if params[:q_name].present?
8
16
  @queue_classic_jobs = @queue_classic_jobs.where(q_name: params[:q_name])
9
17
  end
@@ -2,9 +2,9 @@ require_dependency "queue_classic_admin/application_controller"
2
2
 
3
3
  module QueueClassicAdmin
4
4
  class QueueClassicJobsController < ApplicationController
5
- before_filter :get_job, only: [:destroy, :unlock, :custom, :show]
5
+ before_action :get_job, only: [:destroy, :unlock, :custom, :show]
6
+ before_action :filter_jobs, only: [:index, :destroy_all, :unlock_all, :bulk_custom_action]
6
7
  def index
7
- filter_jobs(QueueClassicJob)
8
8
  @queue_classic_jobs = @queue_classic_jobs.paginate(page: params[:page])
9
9
  end
10
10
 
@@ -14,20 +14,18 @@ module QueueClassicAdmin
14
14
  end
15
15
 
16
16
  def destroy_all
17
- filter_jobs(QueueClassicJob).delete_all
17
+ @queue_classic_jobs.delete_all
18
18
  redirect_to queue_classic_jobs_url
19
19
  end
20
20
 
21
21
  def unlock_all
22
- filter_jobs(QueueClassicJob).where('locked_at < ?', 5.minutes.ago).update_all(locked_at: nil)
22
+ @queue_classic_jobs.where('locked_at < ?', 5.minutes.ago).update_all(locked_at: nil)
23
23
  redirect_to queue_classic_jobs_url
24
24
  end
25
25
 
26
26
  def bulk_custom_action
27
- jobs = filter_jobs(QueueClassicJob)
28
-
29
27
  custom_action = QueueClassicAdmin.custom_bulk_actions[params[:custom_action]]
30
- custom_action.action.call(jobs)
28
+ custom_action.action.call(@queue_classic_jobs)
31
29
 
32
30
  redirect_to queue_classic_jobs_url
33
31
  end
@@ -58,11 +56,11 @@ module QueueClassicAdmin
58
56
  @queue_classic_job = QueueClassicJob.find(params[:id])
59
57
  end
60
58
 
61
- def later?
59
+ def scheduled?
62
60
  false
63
61
  end
64
62
 
65
63
  helper_method :index_path
66
- helper_method :later?
64
+ helper_method :scheduled?
67
65
  end
68
66
  end
@@ -0,0 +1,33 @@
1
+ require_dependency "queue_classic_admin/application_controller"
2
+
3
+ module QueueClassicAdmin
4
+ class QueueClassicScheduledJobsController < ApplicationController
5
+ before_action :filter_jobs, only: %i(index destroy_all)
6
+ def index
7
+ @queue_classic_jobs = @queue_classic_jobs.paginate(page: params[:page])
8
+ end
9
+
10
+ def destroy
11
+ @queue_classic_scheduled_job = QueueClassicJob.find(params[:id])
12
+ @queue_classic_scheduled_job.destroy
13
+ redirect_to queue_classic_scheduled_jobs_url
14
+ end
15
+
16
+ def destroy_all
17
+ @queue_classic_jobs.delete_all
18
+ redirect_to queue_classic_jobs_url
19
+ end
20
+
21
+ private
22
+ def index_path(*params)
23
+ queue_classic_scheduled_jobs_path(*params)
24
+ end
25
+
26
+ def scheduled?
27
+ true
28
+ end
29
+
30
+ helper_method :index_path
31
+ helper_method :scheduled?
32
+ end
33
+ end
@@ -1,11 +1,5 @@
1
1
  module QueueClassicAdmin
2
2
  module ApplicationHelper
3
- def has_qc_later?
4
- QC.respond_to?(:enqueue_in) &&
5
- defined?(QC::Later) &&
6
- ActiveRecord::Base.connection.table_exists?(QC::Later::TABLE_NAME)
7
- end
8
-
9
3
  def sortable_column(name, title)
10
4
  opts = {sort: name}
11
5
  opts[:dir] = (params[:dir] == "asc" ? "desc" : "asc")
@@ -0,0 +1,4 @@
1
+ module QueueClassicAdmin
2
+ module QueueClassicScheduledJobsHelper
3
+ end
4
+ end
@@ -3,7 +3,7 @@ require 'will_paginate'
3
3
  module QueueClassicAdmin
4
4
  module JobCommon
5
5
  module ClassMethods
6
- KNOWN_COLUMN = ["id", "q_name", "method", "args", "locked_at", "created_at", "not_before", "locked_by"].freeze
6
+ KNOWN_COLUMN = ["id", "q_name", "method", "args", "locked_at", "created_at", "not_before", "locked_by", 'scheduled_at'].freeze
7
7
  SEARCHABLE_COLUMNS = [ :method, :args ].freeze
8
8
 
9
9
  def queue_counts
@@ -2,5 +2,8 @@ module QueueClassicAdmin
2
2
  class QueueClassicJob < ActiveRecord::Base
3
3
  include JobCommon
4
4
  self.table_name = 'queue_classic_jobs'
5
+
6
+ scope :ready, -> { where("queue_classic_jobs.scheduled_at <= now()") }
7
+ scope :scheduled, -> { where("queue_classic_jobs.scheduled_at > now()") }
5
8
  end
6
9
  end
@@ -29,9 +29,7 @@
29
29
  <div class="container-fluid nav-collapse">
30
30
  <ul class="nav">
31
31
  <li><%= link_to "Jobs", queue_classic_jobs_path %></li>
32
- <% if has_qc_later? %>
33
- <li><%= link_to "Scheduled Jobs", queue_classic_later_jobs_path %></li>
34
- <% end %>
32
+ <li><%= link_to "Scheduled Jobs", queue_classic_scheduled_jobs_path %></li>
35
33
  </ul>
36
34
  </div><!--/.nav-collapse -->
37
35
  </div>
@@ -7,9 +7,10 @@
7
7
 
8
8
  <ul class="nav nav-pills">
9
9
  <li class="<%= q_name_pill_class(nil)%>" >
10
- <a href="<%= index_path %>"><%= "All (#{@klass.count})" %></a>
10
+ <a href="<%= index_path %>"><%= "All (#{@scoped_jobs.count})" %></a>
11
11
  </li>
12
- <% @klass.queue_counts.each do |q_name, count| %>
12
+
13
+ <% @scoped_jobs.queue_counts.each do |q_name, count| %>
13
14
  <li class="<%= q_name_pill_class(q_name) %>">
14
15
  <a href="<%= index_path(q_name: q_name) %>"><%= "#{q_name} (#{count})" %></a>
15
16
  </li>
@@ -26,17 +27,17 @@
26
27
  <%= sortable_column :locked_by, "Locked By" %>
27
28
  <%= sortable_column :method, "Method" %>
28
29
  <%= sortable_column :args, "Arguments" %>
29
- <% if @klass.columns_hash['not_before'] %>
30
+ <% if QueueClassicAdmin::QueueClassicJob.columns_hash['not_before'] %>
30
31
  <th>Run At</th>
31
32
  <% end %>
32
- <% @klass.extra_columns.each do |column| %>
33
+ <% QueueClassicAdmin::QueueClassicJob.extra_columns.each do |column| %>
33
34
  <%= sortable_column column, column.titleize %>
34
35
  <% end %>
35
36
  <th>
36
37
  <%=
37
38
  link_to "Destroy Matching", url_for(params.merge(action: 'destroy_all')), class: 'btn btn-danger', data: {confirm: "Are you sure?", method: :delete}
38
39
  %>
39
- <% unless later? %>
40
+ <% unless scheduled? %>
40
41
  <%=
41
42
  link_to "Unlock Matching > 5 mins", url_for(params.merge(action: 'unlock_all')), class: 'btn btn-danger', data: {confirm: "Are you sure?", method: :put}
42
43
  %>
@@ -80,11 +81,11 @@
80
81
  </td>
81
82
  <td><%= queue_classic_job.method %></td>
82
83
  <td><%= queue_classic_job.arguments.inspect%></td>
83
- <% if @klass.columns_hash['not_before'] %>
84
+ <% if QueueClassicAdmin::QueueClassicJob.columns_hash['not_before'] %>
84
85
  <td><%= queue_classic_job.not_before %></td>
85
86
  <% end %>
86
87
 
87
- <% @klass.extra_columns.each do |column| %>
88
+ <% QueueClassicAdmin::QueueClassicJob.extra_columns.each do |column| %>
88
89
  <td><%= queue_classic_job[column] %></th>
89
90
  <% end %>
90
91
 
@@ -1,5 +1,5 @@
1
1
  QueueClassicAdmin::Engine.routes.draw do
2
- resources :queue_classic_later_jobs do
2
+ resources :queue_classic_scheduled_jobs do
3
3
  collection do
4
4
  delete :destroy_all
5
5
  end
@@ -2,7 +2,6 @@ require "queue_classic_admin/engine"
2
2
  require "queue_classic_admin/custom_action"
3
3
  require 'will_paginate'
4
4
  require "will_paginate-bootstrap"
5
- require 'twitter-bootstrap-rails'
6
5
 
7
6
  module QueueClassicAdmin
8
7
 
@@ -1,3 +1,3 @@
1
1
  module QueueClassicAdmin
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: queue_classic_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Mathieu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-07 00:00:00.000000000 Z
11
+ date: 2015-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.2.0
83
- - !ruby/object:Gem::Dependency
84
- name: twitter-bootstrap-rails
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: sqlite3
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -120,24 +106,22 @@ files:
120
106
  - Rakefile
121
107
  - app/assets/javascripts/queue_classic_admin/application.js
122
108
  - app/assets/javascripts/queue_classic_admin/queue_classic_jobs.js
123
- - app/assets/javascripts/queue_classic_admin/queue_classic_later_jobs.js
109
+ - app/assets/javascripts/queue_classic_admin/queue_classic_scheduled_jobs.js
124
110
  - app/assets/stylesheets/queue_classic_admin/application.css
125
111
  - app/assets/stylesheets/queue_classic_admin/queue_classic_jobs.css
126
- - app/assets/stylesheets/queue_classic_admin/queue_classic_later_jobs.css
127
- - app/assets/stylesheets/scaffold.css
112
+ - app/assets/stylesheets/queue_classic_admin/queue_classic_scheduled_jobs.css
128
113
  - app/controllers/queue_classic_admin/application_controller.rb
129
114
  - app/controllers/queue_classic_admin/queue_classic_jobs_controller.rb
130
- - app/controllers/queue_classic_admin/queue_classic_later_jobs_controller.rb
115
+ - app/controllers/queue_classic_admin/queue_classic_scheduled_jobs_controller.rb
131
116
  - app/helpers/queue_classic_admin/application_helper.rb
132
117
  - app/helpers/queue_classic_admin/queue_classic_jobs_helper.rb
133
- - app/helpers/queue_classic_admin/queue_classic_later_jobs_helper.rb
118
+ - app/helpers/queue_classic_admin/queue_classic_scheduled_jobs_helper.rb
134
119
  - app/models/queue_classic_admin/job_common.rb
135
120
  - app/models/queue_classic_admin/queue_classic_job.rb
136
- - app/models/queue_classic_admin/queue_classic_later_job.rb
137
121
  - app/views/layouts/queue_classic_admin/application.html.erb
138
122
  - app/views/queue_classic_admin/queue_classic_jobs/index.html.erb
139
123
  - app/views/queue_classic_admin/queue_classic_jobs/show.html.erb
140
- - app/views/queue_classic_admin/queue_classic_later_jobs/index.html.erb
124
+ - app/views/queue_classic_admin/queue_classic_scheduled_jobs/index.html.erb
141
125
  - app/views/queue_classic_admin/shared/_job_list.html.erb
142
126
  - config/routes.rb
143
127
  - db/migrate/20130626182618_add_id_to_later.rb
@@ -167,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
151
  version: '0'
168
152
  requirements: []
169
153
  rubyforge_project:
170
- rubygems_version: 2.2.2
154
+ rubygems_version: 2.4.5
171
155
  signing_key:
172
156
  specification_version: 4
173
157
  summary: An admin interface for QueueClassic
@@ -1,56 +0,0 @@
1
- body { background-color: #fff; color: #333; }
2
-
3
- body, p, ol, ul, td {
4
- font-family: verdana, arial, helvetica, sans-serif;
5
- font-size: 13px;
6
- line-height: 18px;
7
- }
8
-
9
- pre {
10
- background-color: #eee;
11
- padding: 10px;
12
- font-size: 11px;
13
- }
14
-
15
- a { color: #000; }
16
- a:visited { color: #666; }
17
- a:hover { color: #fff; background-color:#000; }
18
-
19
- div.field, div.actions {
20
- margin-bottom: 10px;
21
- }
22
-
23
- #notice {
24
- color: green;
25
- }
26
-
27
- .field_with_errors {
28
- padding: 2px;
29
- background-color: red;
30
- display: table;
31
- }
32
-
33
- #error_explanation {
34
- width: 450px;
35
- border: 2px solid red;
36
- padding: 7px;
37
- padding-bottom: 0;
38
- margin-bottom: 20px;
39
- background-color: #f0f0f0;
40
- }
41
-
42
- #error_explanation h2 {
43
- text-align: left;
44
- font-weight: bold;
45
- padding: 5px 5px 5px 15px;
46
- font-size: 12px;
47
- margin: -7px;
48
- margin-bottom: 0px;
49
- background-color: #c00;
50
- color: #fff;
51
- }
52
-
53
- #error_explanation ul li {
54
- font-size: 12px;
55
- list-style: square;
56
- }
@@ -1,33 +0,0 @@
1
- require_dependency "queue_classic_admin/application_controller"
2
-
3
- module QueueClassicAdmin
4
- class QueueClassicLaterJobsController < ApplicationController
5
- def index
6
- filter_jobs(QueueClassicLaterJob)
7
- @queue_classic_jobs = @queue_classic_jobs.paginate(page: params[:page])
8
- end
9
-
10
- def destroy
11
- @queue_classic_later_job = QueueClassicLaterJob.find(params[:id])
12
- @queue_classic_later_job.destroy
13
- redirect_to queue_classic_later_jobs_url
14
- end
15
-
16
- def destroy_all
17
- filter_jobs(QueueClassicLaterJob).delete_all
18
- redirect_to queue_classic_jobs_url
19
- end
20
-
21
- private
22
- def index_path(*params)
23
- queue_classic_later_jobs_path(*params)
24
- end
25
-
26
- def later?
27
- true
28
- end
29
-
30
- helper_method :index_path
31
- helper_method :later?
32
- end
33
- end
@@ -1,4 +0,0 @@
1
- module QueueClassicAdmin
2
- module QueueClassicLaterJobsHelper
3
- end
4
- end
@@ -1,6 +0,0 @@
1
- module QueueClassicAdmin
2
- class QueueClassicLaterJob < ActiveRecord::Base
3
- include JobCommon
4
- self.table_name = 'queue_classic_later_jobs'
5
- end
6
- end