queue_classic_admin 0.0.13 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +12 -2
- data/app/controllers/queue_classic_admin/application_controller.rb +1 -1
- data/app/controllers/queue_classic_admin/queue_classic_jobs_controller.rb +6 -1
- data/app/models/queue_classic_admin/job_common.rb +11 -5
- data/app/views/queue_classic_admin/queue_classic_jobs/show.html.erb +15 -0
- data/app/views/queue_classic_admin/shared/_job_list.html.erb +22 -12
- data/config/routes.rb +1 -0
- data/db/migrate/20130627175128_add_created_column.rb +5 -3
- data/lib/queue_classic_admin/version.rb +1 -1
- data/lib/queue_classic_admin.rb +1 -0
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af3e82cb0e74c8f07092805d70faac50787c24a1
|
4
|
+
data.tar.gz: a96d62309d29728cebc1431416adadab9518f870
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e3107691428b831903a91f6789019bf1cc1337c0a9be62ffb74efe55f57136efdbe406c5ed7ba83b2eb0b6b0e9c06df6e51b004ff1907b068e3408e14b8a5c9
|
7
|
+
data.tar.gz: 96031b1f2af02a9d50b5c11c21e9a4fef5ded8bc7ab1c8cf82ecd4d8b3268eb74e01e9aeef51b4c76fbbfa0d5abff343e424ce0e9c7439a3bac89fc70afc2a80
|
data/README.md
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
|
5
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.
|
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.**
|
8
|
+
|
7
9
|

|
8
10
|
|
9
11
|
|
@@ -13,6 +15,7 @@ An admin interface for the [queue_classic](https://github.com/ryandotsmith/queue
|
|
13
15
|
* Support for custom columns
|
14
16
|
* Delete entire queues
|
15
17
|
* Delete jobs
|
18
|
+
* Search
|
16
19
|
|
17
20
|
|
18
21
|
# Install
|
@@ -53,14 +56,21 @@ end
|
|
53
56
|
|
54
57
|
# Development
|
55
58
|
|
59
|
+
```bash
|
60
|
+
git clone git@github.com:rainforestapp/queue_classic_admin.git
|
61
|
+
```
|
62
|
+
|
56
63
|
You can develop with POW by configuring it like so:
|
57
64
|
|
58
65
|
```bash
|
59
66
|
ln -s $PWD/spec/dummy ~/.pow/qc-admin
|
60
|
-
(cd spec/dummy && rake db:create:all db:migrate)
|
67
|
+
(cd spec/dummy && bundle exec rake db:create:all db:migrate)
|
68
|
+
# Run the engine's migration.
|
69
|
+
bundle exec rake db:migrate
|
70
|
+
(cd spec/dummy && bundle exec rake db:schema:dump)
|
61
71
|
|
62
72
|
ln -s $PWD/spec/dummy-no-later ~/.pow/qc-admin-no-later
|
63
|
-
(cd spec/dummy-no-later && rake db:create:all db:migrate)
|
73
|
+
(cd spec/dummy-no-later && bundle exec rake db:create:all db:migrate)
|
64
74
|
```
|
65
75
|
|
66
76
|
Then go to [http://qc-admin.dev/](http://qc-admin.dev/).
|
@@ -11,7 +11,7 @@ module QueueClassicAdmin
|
|
11
11
|
@queue_classic_jobs = @queue_classic_jobs.search(params[:search])
|
12
12
|
end
|
13
13
|
if params[:sort].present?
|
14
|
-
@queue_classic_jobs = @queue_classic_jobs.reorder("#{params[:sort]} #{params[:dir]}")
|
14
|
+
@queue_classic_jobs = @queue_classic_jobs.reorder("#{params[:sort]} #{params[:dir]} NULLS LAST")
|
15
15
|
end
|
16
16
|
@queue_classic_jobs
|
17
17
|
end
|
@@ -2,7 +2,7 @@ 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]
|
5
|
+
before_filter :get_job, only: [:destroy, :unlock, :custom, :show]
|
6
6
|
def index
|
7
7
|
filter_jobs(QueueClassicJob)
|
8
8
|
@queue_classic_jobs = @queue_classic_jobs.paginate(page: params[:page])
|
@@ -29,6 +29,11 @@ module QueueClassicAdmin
|
|
29
29
|
redirect_to :back
|
30
30
|
end
|
31
31
|
|
32
|
+
def show
|
33
|
+
query = "SELECT * FROM pg_catalog.pg_locks lock JOIN pg_catalog.pg_stat_activity stat ON lock.pid = stat.pid WHERE lock.pid = #{@queue_classic_job.locked_by.to_i}"
|
34
|
+
@locks = QueueClassicJob.connection.execute(query)
|
35
|
+
end
|
36
|
+
|
32
37
|
def custom
|
33
38
|
custom_action = QueueClassicAdmin.custom_actions[params[:custom_action]]
|
34
39
|
custom_action.action.call(@queue_classic_job)
|
@@ -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"].freeze
|
6
|
+
KNOWN_COLUMN = ["id", "q_name", "method", "args", "locked_at", "created_at", "not_before", "locked_by"].freeze
|
7
7
|
SEARCHABLE_COLUMNS = [ :method, :args ].freeze
|
8
8
|
|
9
9
|
def queue_counts
|
@@ -19,18 +19,24 @@ module QueueClassicAdmin
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def search(query)
|
22
|
-
sql = searchable_columns.
|
23
|
-
|
24
|
-
|
22
|
+
sql = searchable_columns.map do |field|
|
23
|
+
unless field == :args && args_is_json?
|
24
|
+
"#{field} LIKE :query"
|
25
|
+
end
|
26
|
+
end.reject(&:nil?).join(" OR ")
|
25
27
|
|
26
28
|
wildcard_query = ["%", query, "%"].join
|
27
29
|
relation.where(sql, query: wildcard_query)
|
28
30
|
end
|
31
|
+
|
32
|
+
def args_is_json?
|
33
|
+
self.column_types["args"].type == :json
|
34
|
+
end
|
29
35
|
end
|
30
36
|
|
31
37
|
module InstanceMethods
|
32
38
|
def arguments
|
33
|
-
if self.class.
|
39
|
+
if self.class.args_is_json?
|
34
40
|
args
|
35
41
|
else
|
36
42
|
MultiJson.decode(args)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<h1>Details for job #<%= @queue_classic_job.id %></h1>
|
2
|
+
<% @queue_classic_job.attributes.each do |attr, value| %>
|
3
|
+
<p>
|
4
|
+
<strong><%= attr %></strong>: <%= value %>
|
5
|
+
</p>
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
<h2>Locks</h2>
|
9
|
+
<% if @locks.count == 0 %>
|
10
|
+
There are no locks related.
|
11
|
+
<% end %>
|
12
|
+
<% @locks.each do |lock| %>
|
13
|
+
<hr>
|
14
|
+
<%= lock %>
|
15
|
+
<% end %>
|
@@ -23,6 +23,7 @@
|
|
23
23
|
<%= sortable_column :id, "ID" %>
|
24
24
|
<%= sortable_column :created_at, "Enqueued At" %>
|
25
25
|
<%= sortable_column :locked_at, "Locked At" %>
|
26
|
+
<%= sortable_column :locked_by, "Locked By" %>
|
26
27
|
<%= sortable_column :method, "Method" %>
|
27
28
|
<%= sortable_column :args, "Arguments" %>
|
28
29
|
<% if @klass.columns_hash['not_before'] %>
|
@@ -48,25 +49,32 @@
|
|
48
49
|
<% @queue_classic_jobs.each do |queue_classic_job| %>
|
49
50
|
<tr>
|
50
51
|
<td><%= queue_classic_job.q_name %></td>
|
51
|
-
<td><%= queue_classic_job.id %></td>
|
52
|
+
<td><%= link_to queue_classic_job.id, queue_classic_job %></td>
|
52
53
|
<td>
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
<% if queue_classic_job.respond_to?(:created_at) %>
|
55
|
+
<%= time_ago_in_words queue_classic_job.created_at %>
|
56
|
+
<br/>
|
57
|
+
<small>
|
58
|
+
(<%= queue_classic_job.created_at %>)
|
59
|
+
</small>
|
60
|
+
<% else %>
|
61
|
+
—
|
62
|
+
<% end %>
|
58
63
|
</td>
|
59
64
|
<td>
|
60
65
|
<% if queue_classic_job[:locked_at].nil? %>
|
61
|
-
|
66
|
+
—
|
62
67
|
<% else %>
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
+
<%= time_ago_in_words queue_classic_job.locked_at %>
|
69
|
+
<br/>
|
70
|
+
<small>
|
71
|
+
(<%= queue_classic_job.locked_at %>)
|
72
|
+
</small>
|
68
73
|
<% end %>
|
69
74
|
</td>
|
75
|
+
<td>
|
76
|
+
<%= queue_classic_job[:locked_by] %>
|
77
|
+
</td>
|
70
78
|
<td><%= queue_classic_job.method %></td>
|
71
79
|
<td><%= queue_classic_job.arguments.inspect%></td>
|
72
80
|
<% if @klass.columns_hash['not_before'] %>
|
@@ -78,10 +86,12 @@
|
|
78
86
|
<% end %>
|
79
87
|
|
80
88
|
<td>
|
89
|
+
<%= link_to 'Details', queue_classic_job_path(queue_classic_job), class: 'btn btn-info' %>
|
81
90
|
<%= link_to 'Destroy', queue_classic_job, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %>
|
82
91
|
<% if queue_classic_job[:locked_at] %>
|
83
92
|
<%= link_to 'Unlock', unlock_queue_classic_job_path(queue_classic_job), method: :post, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %>
|
84
93
|
<% end %>
|
94
|
+
|
85
95
|
<% QueueClassicAdmin.custom_actions.each do |slug, action| %>
|
86
96
|
<%= link_to action.name, custom_queue_classic_job_path(queue_classic_job, custom_action: slug), method: :post, class: "btn btn-danger" %>
|
87
97
|
<% end %>
|
data/config/routes.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
class AddCreatedColumn < ActiveRecord::Migration
|
2
2
|
def up
|
3
|
-
%w(queue_classic_later_jobs
|
4
|
-
if ActiveRecord::Base.connection.table_exists?(
|
3
|
+
%w(queue_classic_later_jobs).each do |table|
|
4
|
+
if ActiveRecord::Base.connection.table_exists?(table)
|
5
5
|
execute "ALTER TABLE #{table} ADD COLUMN created_at TIMESTAMP NOT NULL DEFAULT now();"
|
6
|
+
else
|
7
|
+
say "Skiping migration because table #{table} does not exist"
|
6
8
|
end
|
7
9
|
end
|
8
10
|
end
|
9
11
|
|
10
12
|
def down
|
11
|
-
%w(queue_classic_later_jobs
|
13
|
+
%w(queue_classic_later_jobs).each do |table|
|
12
14
|
remove_column table, :created_at
|
13
15
|
end
|
14
16
|
end
|
data/lib/queue_classic_admin.rb
CHANGED
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.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Mathieu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.0.9
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 4.0.9
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: queue_classic
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '3.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '3.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pg
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
|
-
type: :
|
90
|
+
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- app/models/queue_classic_admin/queue_classic_later_job.rb
|
137
137
|
- app/views/layouts/queue_classic_admin/application.html.erb
|
138
138
|
- app/views/queue_classic_admin/queue_classic_jobs/index.html.erb
|
139
|
+
- app/views/queue_classic_admin/queue_classic_jobs/show.html.erb
|
139
140
|
- app/views/queue_classic_admin/queue_classic_later_jobs/index.html.erb
|
140
141
|
- app/views/queue_classic_admin/shared/_job_list.html.erb
|
141
142
|
- config/routes.rb
|