good_job 1.3.2 → 1.3.3

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
  SHA256:
3
- metadata.gz: ff96dcfb5fdd4d48310e8af09ac8785a6d76810f5433b27d3a80c3d3cd8c9d81
4
- data.tar.gz: e69150fe9a19b21dcada1cccec6d120146131746b09f2633da7320d4cbedee0f
3
+ metadata.gz: d48414f6b03482087018157412c87afb3fdb70929a292294f7db2e14309c31fd
4
+ data.tar.gz: dd221c88385350fff14b593a6504bc98adeae44893d523c90949332a81eb6fd9
5
5
  SHA512:
6
- metadata.gz: 782b425219f7538517be26275ced947759e7691b485832f288b4f13df5e112d678b0cc0a1b8589b64f87823b88210f8af6af453dfc36dcdc7bb37a5a9288837b
7
- data.tar.gz: 57e8f1b790a9d52c6e3774b5a6fdb61a4f43503a0ee3f018a9ad85d39aca9dc2994d2298607bbb48d9fd0d57861de56ef02506b791bd2fa52561910b6d73a586
6
+ metadata.gz: 77ab00b0cd0772641a402205856d5c03c675dc2edc769e5fed8909636fc2c4a69b033da98a7d0ae09a7ac1fc3f40dd5dc4ff637b3d13e4c290acb9a40bc51ead
7
+ data.tar.gz: 1777e663267f7e626d7f5ebf5b61b156e83b7bcf9234addddabeb10ef1054c05f8602ca0111c1abe4de9fb53b32aafac4df5d88e1c7c0147e0f1a7cbdc57219d
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [v1.3.3](https://github.com/bensheldon/good_job/tree/v1.3.3) (2020-12-01)
4
+
5
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v1.3.2...v1.3.3)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - UI: Admin UI with filters and space efficient layout [\#173](https://github.com/bensheldon/good_job/pull/173) ([zealot128](https://github.com/zealot128))
10
+
3
11
  ## [v1.3.2](https://github.com/bensheldon/good_job/tree/v1.3.2) (2020-11-12)
4
12
 
5
13
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v1.3.1...v1.3.2)
@@ -147,6 +155,7 @@
147
155
  **Merged pull requests:**
148
156
 
149
157
  - stop depending on all rails libs [\#104](https://github.com/bensheldon/good_job/pull/104) ([thilo](https://github.com/thilo))
158
+ - Use more ActiveRecord in Lockable and not connection.execute [\#102](https://github.com/bensheldon/good_job/pull/102) ([bensheldon](https://github.com/bensheldon))
150
159
 
151
160
  ## [v1.2.2](https://github.com/bensheldon/good_job/tree/v1.2.2) (2020-08-27)
152
161
 
@@ -167,7 +176,6 @@
167
176
 
168
177
  **Merged pull requests:**
169
178
 
170
- - Use more ActiveRecord in Lockable and not connection.execute [\#102](https://github.com/bensheldon/good_job/pull/102) ([bensheldon](https://github.com/bensheldon))
171
179
  - Run CI tests on Ruby 2.5, 2.6, and 2.7 [\#101](https://github.com/bensheldon/good_job/pull/101) ([arku](https://github.com/arku))
172
180
  - Return to using executor.wrap around Scheduler execution task [\#99](https://github.com/bensheldon/good_job/pull/99) ([bensheldon](https://github.com/bensheldon))
173
181
  - Fix Ruby 2.7 keyword arguments warning [\#98](https://github.com/bensheldon/good_job/pull/98) ([arku](https://github.com/arku))
@@ -1,8 +1,57 @@
1
1
  module GoodJob
2
2
  class DashboardsController < GoodJob::BaseController
3
- def index
4
- @jobs = GoodJob::Job.display_all(after_scheduled_at: params[:after_scheduled_at], after_id: params[:after_id])
3
+ class JobFilter
4
+ attr_accessor :params
5
+
6
+ def initialize(params)
7
+ @params = params
8
+ end
9
+
10
+ def last
11
+ @_last ||= jobs.last
12
+ end
13
+
14
+ def jobs
15
+ sql = GoodJob::Job.display_all(after_scheduled_at: params[:after_scheduled_at], after_id: params[:after_id])
5
16
  .limit(params.fetch(:limit, 10))
17
+ if params[:job_class] # rubocop:disable Style/IfUnlessModifier
18
+ sql = sql.where("serialized_params->>'job_class' = ?", params[:job_class])
19
+ end
20
+ if params[:state]
21
+ case params[:state]
22
+ when 'finished'
23
+ sql = sql.finished
24
+ when 'unfinished'
25
+ sql = sql.unfinished
26
+ when 'errors'
27
+ sql = sql.where.not(error: nil)
28
+ end
29
+ end
30
+ sql
31
+ end
32
+
33
+ def states
34
+ {
35
+ 'finished' => GoodJob::Job.finished.count,
36
+ 'unfinished' => GoodJob::Job.unfinished.count,
37
+ 'errors' => GoodJob::Job.where.not(error: nil).count,
38
+ }
39
+ end
40
+
41
+ def job_classes
42
+ GoodJob::Job.group("serialized_params->>'job_class'").count
43
+ end
44
+
45
+ def to_query(override)
46
+ {
47
+ state: params[:state],
48
+ job_class: params[:job_class],
49
+ }.merge(override).delete_if { |_, v| v.nil? }.to_query
50
+ end
51
+ end
52
+
53
+ def index
54
+ @filter = JobFilter.new(params)
6
55
 
7
56
  job_data = GoodJob::Job.connection.exec_query Arel.sql(<<~SQL.squish)
8
57
  SELECT *
@@ -2,13 +2,36 @@
2
2
  <%= render 'shared/chart', chart_data: @chart %>
3
3
  </div>
4
4
 
5
- <% if @jobs.present? %>
6
- <%= render 'shared/jobs_table', jobs: @jobs %>
5
+ <div class='card mb-2'>
6
+ <div class='card-body d-flex flex-wrap'>
7
+ <div class='mr-4'>
8
+ <small>Filter by job class</small>
9
+ <br>
10
+ <% @filter.job_classes.each do |name, count| %>
11
+ <a href='<%= request.path + "?#{@filter.to_query(job_class: name)}" %>' class='btn btn-sm btn-outline-secondary <%= "active" if params[:job_class] == name %>'>
12
+ <%= name %> (<%= count %>)
13
+ </a>
14
+ <% end %>
15
+ </div>
16
+ <div>
17
+ <small>Filter by state</small>
18
+ <br>
19
+ <% @filter.states.each do |name, count| %>
20
+ <a href='<%= request.path + "?#{@filter.to_query(state: name)}" %>' class='btn btn-sm btn-outline-secondary <%= "active" if params[:state] == name %>'>
21
+ <%= name %> (<%= count %>)
22
+ </a>
23
+ <% end %>
24
+ </div>
25
+ </div>
26
+ </div>
27
+
28
+ <% if @filter.jobs.present? %>
29
+ <%= render 'shared/jobs_table', jobs: @filter.jobs %>
7
30
 
8
31
  <nav aria-label="Job pagination">
9
32
  <ul class="pagination">
10
33
  <li class="page-item">
11
- <%= link_to({ after_scheduled_at: (@jobs.last.scheduled_at || @jobs.last.created_at), after_id: @jobs.last.id }, class: "page-link") do %>
34
+ <%= link_to({ after_scheduled_at: (@filter.last.scheduled_at || @filter.last.created_at), after_id: @filter.last.id }, class: "page-link") do %>
12
35
  Next jobs <span aria-hidden="true">&raquo;</span>
13
36
  <% end %>
14
37
  </li>
@@ -18,7 +18,7 @@
18
18
  </head>
19
19
  <body>
20
20
  <nav class="navbar navbar-expand-lg navbar-light bg-light">
21
- <div class="container">
21
+ <div class="container-fluid">
22
22
  <%= link_to "GoodJob 👍", root_path, class: 'navbar-brand mb-0 h1' %>
23
23
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
24
24
  <span class="navbar-toggler-icon"></span>
@@ -48,7 +48,7 @@
48
48
  </div>
49
49
  </nav>
50
50
 
51
- <div class="container">
51
+ <div class="container-fluid">
52
52
  <div class="card border-warning text-dark my-3">
53
53
  <div class="card-body">
54
54
  <p class="card-text">🚧 GoodJob's dashboard is a work in progress. Please contribute ideas and code on <a href="https://github.com/bensheldon/good_job/issues" target="_blank" rel="nofollow noopener noreferrer">Github</a>.</p>
@@ -1,5 +1,5 @@
1
1
  <div class="table-responsive">
2
- <table class="table table-bordered table-hover">
2
+ <table class="table table-bordered table-hover table-sm">
3
3
  <thead>
4
4
  <th>GoodJob ID</th>
5
5
  <th>ActiveJob ID</th>
@@ -1,4 +1,4 @@
1
1
  module GoodJob
2
2
  # GoodJob gem version.
3
- VERSION = '1.3.2'.freeze
3
+ VERSION = '1.3.3'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: good_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Sheldon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-12 00:00:00.000000000 Z
11
+ date: 2020-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob