que-web 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8584792cba68d7f6e00a6e4852a676fff5620cb
4
- data.tar.gz: eab83486882b4aed634b029f532083c054a437c2
3
+ metadata.gz: f5a47f1b59dd8d5fa25e4518fefc06e52a168cd6
4
+ data.tar.gz: 688a7ece0571223c6555980c6c2f8d5915e0ff32
5
5
  SHA512:
6
- metadata.gz: 199fd0f8f74f1860ad539575a15f5625f73c49dba9f43a873354395c08d2689cdcecac05d1c530da475eab95b5053bc85060d517c8f87b4e9d9fc1c2cafad0a9
7
- data.tar.gz: 4bdbe7d0e610f7f55893132f11decbaa4fda2f2bcaafd3ec394680ba6e1473cb78fef0447ab29e8e11332b430250365fe3fd0f157de89bc76f51c59b7a10219d
6
+ metadata.gz: 70385e07ff8aef1cddbb0174bed6011e12451a501820196e65fb3f86a977adf35cd564239c48fb0a716fc56909153e9a4c93acfcf9b49069120f548066d7beac
7
+ data.tar.gz: 9ee7f320ac3ab905389bb7d377106de5c04f84c8c7d1f15baf5c7ec7261efa61cbfbae5d3a0de9f4d37c5da37c961677fd5631e6f8a2624ae0ff5857cef09cee
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ### 0.7.0 - 2018-02-02
2
+ #### Added:
3
+ - Delete All and Reschedule All ([#39](https://github.com/statianzo/que-web/pull/39))
4
+
5
+ #### Docs:
6
+ - Upgrade vulnerable rack version in example
7
+
1
8
  ### 0.4.0 - 2015-04-09
2
9
  #### Added:
3
10
  - Indicate when a job is past due #2
data/README.md CHANGED
@@ -4,11 +4,6 @@ que-web is a web UI to the [Que](https://github.com/chanks/que) job queue.
4
4
 
5
5
  ![Que Web](https://raw.githubusercontent.com/statianzo/que-web/master/doc/queweb.png)
6
6
 
7
-
8
- <a target='_blank' rel='nofollow' href='https://app.codesponsor.io/link/AitzkUqcdsSnujfFtmVhTLXR/statianzo/que-web'>
9
- <img alt='Sponsor' width='888' height='68' src='https://app.codesponsor.io/embed/AitzkUqcdsSnujfFtmVhTLXR/statianzo/que-web.svg' />
10
- </a>
11
-
12
7
  ## Installation
13
8
 
14
9
  Add this line to your application's Gemfile:
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: ../../
2
+ remote: ../..
3
3
  specs:
4
- que-web (0.3.2)
4
+ que-web (0.7.0)
5
5
  erubis
6
6
  que (~> 0.8)
7
7
  sinatra
@@ -10,17 +10,19 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  erubis (2.7.0)
13
- pg (0.18.1)
14
- que (0.9.1)
15
- rack (1.6.0)
16
- rack-protection (1.5.3)
13
+ mustermann (1.0.1)
14
+ pg (1.0.0)
15
+ que (0.14.2)
16
+ rack (2.0.4)
17
+ rack-protection (2.0.0)
17
18
  rack
18
- sequel (4.19.0)
19
- sinatra (1.4.5)
20
- rack (~> 1.4)
21
- rack-protection (~> 1.4)
22
- tilt (~> 1.3, >= 1.3.4)
23
- tilt (1.4.1)
19
+ sequel (5.5.0)
20
+ sinatra (2.0.0)
21
+ mustermann (~> 1.0)
22
+ rack (~> 2.0)
23
+ rack-protection (= 2.0.0)
24
+ tilt (~> 2.0)
25
+ tilt (2.0.8)
24
26
 
25
27
  PLATFORMS
26
28
  ruby
@@ -29,3 +31,6 @@ DEPENDENCIES
29
31
  pg
30
32
  que-web!
31
33
  sequel
34
+
35
+ BUNDLED WITH
36
+ 1.15.3
data/lib/que/web.rb CHANGED
@@ -76,6 +76,28 @@ module Que
76
76
  redirect request.referrer, 303
77
77
  end
78
78
 
79
+ put "/jobs" do
80
+ query = case params[:scope]
81
+ when 'scheduled'
82
+ SQL[:reschedule_all_scheduled_jobs]
83
+ when 'failing'
84
+ SQL[:reschedule_all_failing_jobs]
85
+ else
86
+ halt 400, "Unrecognized scope '#{params[:scope]}'. Valid scopes are: scheduled, failing"
87
+ end
88
+
89
+ run_at = Time.now
90
+ updated_rows = Que.execute query, [run_at]
91
+
92
+ if updated_rows.empty?
93
+ set_flash "warning", "No jobs rescheduled"
94
+ else
95
+ set_flash "info", "#{updated_rows.count} jobs rescheduled for #{run_at}"
96
+ end
97
+
98
+ redirect request.referrer, 303
99
+ end
100
+
79
101
  delete "/jobs/:id" do |id|
80
102
  job_id = id.to_i
81
103
  if job_id > 0
@@ -92,6 +114,27 @@ module Que
92
114
  redirect request.referrer, 303
93
115
  end
94
116
 
117
+ delete "/jobs" do
118
+ query = case params[:scope]
119
+ when 'scheduled'
120
+ SQL[:delete_all_scheduled_jobs]
121
+ when 'failing'
122
+ SQL[:delete_all_failing_jobs]
123
+ else
124
+ halt 400, "Unrecognized scope '#{params[:scope]}'. Valid scopes are: scheduled, failing"
125
+ end
126
+
127
+ updated_rows = Que.execute query
128
+
129
+ if updated_rows.empty?
130
+ set_flash "warning", "No jobs deleted"
131
+ else
132
+ set_flash "info", "#{updated_rows.count} jobs deleted"
133
+ end
134
+
135
+ redirect request.referrer, 303
136
+ end
137
+
95
138
  def get_pager(record_count)
96
139
  page = (params[:page] || 1).to_i
97
140
  Pager.new(page, PAGE_SIZE, record_count)
data/lib/que/web/sql.rb CHANGED
@@ -4,6 +4,41 @@ lock_job_sql = <<-SQL.freeze
4
4
  WHERE job_id = $1::bigint
5
5
  SQL
6
6
 
7
+ lock_all_failing_jobs_sql = <<-SQL.freeze
8
+ SELECT job_id, pg_try_advisory_lock(job_id) AS locked
9
+ FROM que_jobs
10
+ WHERE error_count > 0
11
+ SQL
12
+
13
+ lock_all_scheduled_jobs_sql = <<-SQL.freeze
14
+ SELECT job_id, pg_try_advisory_lock(job_id) AS locked
15
+ FROM que_jobs
16
+ WHERE error_count = 0
17
+ SQL
18
+
19
+ def reschedule_all_jobs_query(scope)
20
+ <<-SQL.freeze
21
+ WITH target AS (#{scope})
22
+ UPDATE que_jobs
23
+ SET run_at = $1::timestamptz
24
+ FROM target
25
+ WHERE target.locked
26
+ AND target.job_id = que_jobs.job_id
27
+ RETURNING pg_advisory_unlock(target.job_id)
28
+ SQL
29
+ end
30
+
31
+ def delete_jobs_query(scope)
32
+ <<-SQL.freeze
33
+ WITH target AS (#{scope})
34
+ DELETE FROM que_jobs
35
+ USING target
36
+ WHERE target.locked
37
+ AND target.job_id = que_jobs.job_id
38
+ RETURNING pg_advisory_unlock(target.job_id)
39
+ SQL
40
+ end
41
+
7
42
  Que::Web::SQL = {
8
43
  dashboard_stats: <<-SQL.freeze,
9
44
  SELECT count(*) AS total,
@@ -45,14 +80,9 @@ Que::Web::SQL = {
45
80
  LIMIT $1::int
46
81
  OFFSET $2::int
47
82
  SQL
48
- delete_job: <<-SQL.freeze,
49
- WITH target AS (#{lock_job_sql})
50
- DELETE FROM que_jobs
51
- USING target
52
- WHERE target.locked
53
- AND target.job_id = que_jobs.job_id
54
- RETURNING pg_advisory_unlock(target.job_id)
55
- SQL
83
+ delete_job: delete_jobs_query(lock_job_sql),
84
+ delete_all_scheduled_jobs: delete_jobs_query(lock_all_scheduled_jobs_sql),
85
+ delete_all_failing_jobs: delete_jobs_query(lock_all_failing_jobs_sql),
56
86
  reschedule_job: <<-SQL.freeze,
57
87
  WITH target AS (#{lock_job_sql})
58
88
  UPDATE que_jobs
@@ -62,6 +92,8 @@ Que::Web::SQL = {
62
92
  AND target.job_id = que_jobs.job_id
63
93
  RETURNING pg_advisory_unlock(target.job_id)
64
94
  SQL
95
+ reschedule_all_scheduled_jobs: reschedule_all_jobs_query(lock_all_scheduled_jobs_sql),
96
+ reschedule_all_failing_jobs: reschedule_all_jobs_query(lock_all_failing_jobs_sql),
65
97
  fetch_job: <<-SQL.freeze,
66
98
  SELECT *
67
99
  FROM que_jobs
data/que-web.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "que-web"
7
- spec.version = "0.6.3"
7
+ spec.version = "0.7.0"
8
8
  spec.authors = ["Jason Staten"]
9
9
  spec.email = ["jstaten07@gmail.com"]
10
10
  spec.summary = %q{A web interface for the que queue}
@@ -40,6 +40,7 @@
40
40
  .dashboard-value {
41
41
  font-size: 5em;
42
42
  line-height: 1em;
43
+ color: black;
43
44
  }
44
45
 
45
46
  table {
@@ -75,3 +76,7 @@ i.subtle {
75
76
  .search {
76
77
  margin-top: 15px;
77
78
  }
79
+
80
+ .pagination {
81
+ margin-top: 10px;
82
+ }
@@ -53,7 +53,24 @@
53
53
  </div>
54
54
  </div>
55
55
  <div class="row">
56
- <div class="small-12 columns">
56
+ <div class="small-8 columns">
57
57
  <%== erb :_pager %>
58
58
  </div>
59
+ <% if @list.total > 0 %>
60
+ <div class="small-4 columns text-right">
61
+ <form action="<%= link_to "jobs" %>" method="post" class="form-inline"
62
+ onsubmit="return confirm('Retry all <%= @list.total %> jobs?');">
63
+ <input type="hidden" name="_method" value="put" />
64
+ <input type="hidden" name="scope" value="failing" />
65
+ <button class="button small" title="Retry All Immediately"><i class="fa fa-refresh"></i> Retry All</button>
66
+ </form>
67
+ &nbsp;
68
+ <form action="<%= link_to "jobs" %>" method="post" class="form-inline"
69
+ onsubmit="return confirm('Delete all <%= @list.total %> jobs?');">
70
+ <input type="hidden" name="_method" value="delete" />
71
+ <input type="hidden" name="scope" value="failing" />
72
+ <button class="button small alert" title="Delete All"><i class="fa fa-trash"></i> Delete All</button>
73
+ </form>
74
+ </div>
75
+ <% end %>
59
76
  </div>
data/web/views/index.erb CHANGED
@@ -10,7 +10,7 @@
10
10
  <a class="small-12 large-4 columns" href="<%= link_to 'running' %>">
11
11
  <div class="dashboard-stat running">
12
12
  <div class="cell">
13
- <h2>Running<h2>
13
+ <h2>Running</h2>
14
14
  <span class="dashboard-value">
15
15
  <%= @dashboard.running %>
16
16
  </span>
@@ -20,7 +20,7 @@
20
20
  <a class="small-12 large-4 columns" href="<%= link_to 'scheduled' %>">
21
21
  <div class="dashboard-stat scheduled">
22
22
  <div class="cell">
23
- <h2>Scheduled<h2>
23
+ <h2>Scheduled</h2>
24
24
  <span class="dashboard-value">
25
25
  <%= @dashboard.scheduled %>
26
26
  </span>
@@ -30,7 +30,7 @@
30
30
  <a class="small-12 large-4 columns" href="<%= link_to 'failing' %>">
31
31
  <div class="dashboard-stat failing">
32
32
  <div class="cell">
33
- <h2>Failing<h2>
33
+ <h2>Failing</h2>
34
34
  <span class="dashboard-value">
35
35
  <%= @dashboard.failing %>
36
36
  </span>
@@ -48,7 +48,24 @@
48
48
  </div>
49
49
  </div>
50
50
  <div class="row">
51
- <div class="small-12 columns">
51
+ <div class="small-8 columns">
52
52
  <%== erb :_pager %>
53
53
  </div>
54
+ <% if @list.total > 0 %>
55
+ <div class="small-4 columns text-right">
56
+ <form action="<%= link_to "jobs" %>" method="post" class="form-inline"
57
+ onsubmit="return confirm('Run all <%= @list.total %> jobs now?');">
58
+ <input type="hidden" name="_method" value="put" />
59
+ <input type="hidden" name="scope" value="scheduled" />
60
+ <button class="button small" title="Run All Immediately"><i class="fa fa-play-circle"></i> Run All</button>
61
+ </form>
62
+ &nbsp;
63
+ <form action="<%= link_to "jobs" %>" method="post" class="form-inline"
64
+ onsubmit="return confirm('Delete all <%= @list.total %> jobs?');">
65
+ <input type="hidden" name="_method" value="delete" />
66
+ <input type="hidden" name="scope" value="scheduled" />
67
+ <button class="button small alert" title="Delete All"><i class="fa fa-trash"></i> Delete All</button>
68
+ </form>
69
+ </div>
70
+ <% end %>
54
71
  </div>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: que-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Staten
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-13 00:00:00.000000000 Z
11
+ date: 2018-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: que
@@ -177,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  version: '0'
178
178
  requirements: []
179
179
  rubyforge_project:
180
- rubygems_version: 2.6.11
180
+ rubygems_version: 2.6.14
181
181
  signing_key:
182
182
  specification_version: 4
183
183
  summary: A web interface for the que queue