rocketjob_mission_control 2.1.1 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/app/assets/stylesheets/rocket_job_mission_control/callout.scss +1 -1
  4. data/app/assets/stylesheets/rocket_job_mission_control/worker_processes.scss +2 -2
  5. data/app/controllers/rocket_job_mission_control/active_workers_controller.rb +15 -0
  6. data/app/controllers/rocket_job_mission_control/dirmon_entries/index_filters_controller.rb +8 -13
  7. data/app/controllers/rocket_job_mission_control/dirmon_entries_controller.rb +3 -14
  8. data/app/controllers/rocket_job_mission_control/jobs/failures_controller.rb +6 -11
  9. data/app/controllers/rocket_job_mission_control/jobs/index_filters_controller.rb +35 -14
  10. data/app/controllers/rocket_job_mission_control/jobs_controller.rb +12 -15
  11. data/app/controllers/rocket_job_mission_control/servers/index_filters_controller.rb +49 -0
  12. data/app/controllers/rocket_job_mission_control/servers_controller.rb +93 -0
  13. data/app/datatables/rocket_job_mission_control/abstract_datatable.rb +62 -0
  14. data/app/datatables/rocket_job_mission_control/active_workers_datatable.rb +47 -0
  15. data/app/datatables/rocket_job_mission_control/completed_jobs_datatable.rb +1 -1
  16. data/app/datatables/rocket_job_mission_control/dirmon_entries_datatable.rb +10 -72
  17. data/app/datatables/rocket_job_mission_control/interrupted_jobs_datatable.rb +1 -1
  18. data/app/datatables/rocket_job_mission_control/jobs_datatable.rb +16 -91
  19. data/app/datatables/rocket_job_mission_control/queued_jobs_datatable.rb +1 -1
  20. data/app/datatables/rocket_job_mission_control/running_jobs_datatable.rb +23 -12
  21. data/app/datatables/rocket_job_mission_control/scheduled_jobs_datatable.rb +1 -1
  22. data/app/datatables/rocket_job_mission_control/servers_datatable.rb +67 -0
  23. data/app/helpers/rocket_job_mission_control/{workers_helper.rb → servers_helper.rb} +9 -9
  24. data/app/models/job_failures.rb +3 -16
  25. data/app/models/rocket_job_mission_control/query.rb +51 -0
  26. data/app/views/layouts/rocket_job_mission_control/partials/_header.html.haml +3 -3
  27. data/app/views/layouts/rocket_job_mission_control/partials/_sidebar.html.haml +2 -2
  28. data/app/views/rocket_job_mission_control/{active_processes → active_workers}/index.html.haml +3 -3
  29. data/app/views/rocket_job_mission_control/dirmon_entries/_properties.html.haml +7 -18
  30. data/app/views/rocket_job_mission_control/dirmon_entries/_status.html.haml +0 -5
  31. data/app/views/rocket_job_mission_control/dirmon_entries/show.html.haml +4 -3
  32. data/app/views/rocket_job_mission_control/jobs/_status.html.haml +22 -17
  33. data/app/views/rocket_job_mission_control/jobs/edit.html.haml +1 -1
  34. data/app/views/rocket_job_mission_control/jobs/exceptions.html.haml +29 -0
  35. data/app/views/rocket_job_mission_control/jobs/failures/index.html.haml +7 -7
  36. data/app/views/rocket_job_mission_control/jobs/show.html.haml +23 -11
  37. data/app/views/rocket_job_mission_control/servers/_actions.html.haml +9 -0
  38. data/app/views/rocket_job_mission_control/servers/_sidebar.html.haml +20 -0
  39. data/app/views/rocket_job_mission_control/{workers → servers}/index.html.haml +9 -9
  40. data/app/views/rocket_job_mission_control/{workers → servers}/index_filters/paused.html.haml +8 -8
  41. data/app/views/rocket_job_mission_control/{workers → servers}/index_filters/running.html.haml +8 -8
  42. data/app/views/rocket_job_mission_control/{workers → servers}/index_filters/starting.html.haml +8 -8
  43. data/app/views/rocket_job_mission_control/{workers → servers}/index_filters/stopping.html.haml +8 -8
  44. data/config/locales/en.yml +2 -2
  45. data/config/routes.rb +7 -6
  46. data/lib/rocket_job_mission_control/engine.rb +0 -12
  47. data/lib/rocket_job_mission_control/version.rb +1 -1
  48. data/spec/controllers/dirmon_entries/index_filters_controller_spec.rb +2 -4
  49. data/spec/controllers/dirmon_entries_controller_spec.rb +15 -72
  50. data/spec/controllers/jobs/index_filters_controller_spec.rb +1 -1
  51. data/spec/controllers/workers/index_filters_controller_spec.rb +9 -9
  52. data/spec/controllers/workers_controller_spec.rb +47 -47
  53. data/spec/dummy/config/mongoid.yml +88 -0
  54. data/spec/dummy/config/symmetric-encryption.yml +8 -0
  55. data/spec/dummy/log/test.log +89072 -0
  56. data/spec/helpers/servers_helper_spec.rb +16 -0
  57. data/spec/spec_helper.rb +3 -0
  58. metadata +31 -45
  59. data/app/controllers/rocket_job_mission_control/active_processes_controller.rb +0 -27
  60. data/app/controllers/rocket_job_mission_control/workers/index_filters_controller.rb +0 -50
  61. data/app/controllers/rocket_job_mission_control/workers_controller.rb +0 -93
  62. data/app/datatables/rocket_job_mission_control/active_processes_datatable.rb +0 -79
  63. data/app/datatables/rocket_job_mission_control/workers_datatable.rb +0 -127
  64. data/app/interactors/rocket_job_mission_control/dirmon_entries/search.rb +0 -19
  65. data/app/interactors/rocket_job_mission_control/jobs/search.rb +0 -19
  66. data/app/interactors/rocket_job_mission_control/workers/search.rb +0 -19
  67. data/app/views/rocket_job_mission_control/workers/_actions.html.haml +0 -9
  68. data/app/views/rocket_job_mission_control/workers/_sidebar.html.haml +0 -20
  69. data/spec/dummy/config/mongo.yml +0 -15
  70. data/spec/helpers/workers_helper_spec.rb +0 -16
  71. data/spec/interactors/jobs/search_spec.rb +0 -35
@@ -0,0 +1,16 @@
1
+ require 'rails_helper'
2
+
3
+ module RocketJobMissionControl
4
+ RSpec.describe ServersHelper, type: :helper do
5
+ describe '#server_card_class' do
6
+ context 'when the server is a zombie' do
7
+ let(:server) { spy(zombie?: true) }
8
+
9
+ it 'returns the correct class' do
10
+ expect(helper.server_card_class(server)).to eq('callout-zombie')
11
+ end
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,4 @@
1
+ require 'rocketjob'
1
2
  # Given that it is always loaded, you are encouraged to keep this file as
2
3
  # light-weight as possible. Requiring heavyweight dependencies from this file
3
4
  # will add to the boot time of your test suite on EVERY test run, even for an
@@ -79,3 +80,5 @@ RSpec.configure do |config|
79
80
  Kernel.srand config.seed
80
81
  =end
81
82
  end
83
+
84
+ RocketJob::Config.load!('test', 'spec/dummy/config/mongoid.yml', 'spec/dummy/config/symmetric-encryption.yml')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocketjob_mission_control
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 3.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Cloutier
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-07-13 00:00:00.000000000 Z
13
+ date: 2017-01-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -84,34 +84,20 @@ dependencies:
84
84
  version: '3.2'
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: rocketjob
87
- requirement: !ruby/object:Gem::Requirement
88
- requirements:
89
- - - "~>"
90
- - !ruby/object:Gem::Version
91
- version: '2.0'
92
- type: :runtime
93
- prerelease: false
94
- version_requirements: !ruby/object:Gem::Requirement
95
- requirements:
96
- - - "~>"
97
- - !ruby/object:Gem::Version
98
- version: '2.0'
99
- - !ruby/object:Gem::Dependency
100
- name: haml
101
87
  requirement: !ruby/object:Gem::Requirement
102
88
  requirements:
103
89
  - - ">="
104
90
  - !ruby/object:Gem::Version
105
- version: '0'
91
+ version: 3.0.0.beta3
106
92
  type: :runtime
107
93
  prerelease: false
108
94
  version_requirements: !ruby/object:Gem::Requirement
109
95
  requirements:
110
96
  - - ">="
111
97
  - !ruby/object:Gem::Version
112
- version: '0'
98
+ version: 3.0.0.beta3
113
99
  - !ruby/object:Gem::Dependency
114
- name: kaminari
100
+ name: haml
115
101
  requirement: !ruby/object:Gem::Requirement
116
102
  requirements:
117
103
  - - ">="
@@ -163,16 +149,17 @@ files:
163
149
  - app/assets/stylesheets/rocket_job_mission_control/jobs.scss
164
150
  - app/assets/stylesheets/rocket_job_mission_control/jquery.bootstrap-touchspin.scss
165
151
  - app/assets/stylesheets/rocket_job_mission_control/worker_processes.scss
166
- - app/controllers/rocket_job_mission_control/active_processes_controller.rb
152
+ - app/controllers/rocket_job_mission_control/active_workers_controller.rb
167
153
  - app/controllers/rocket_job_mission_control/application_controller.rb
168
154
  - app/controllers/rocket_job_mission_control/dirmon_entries/index_filters_controller.rb
169
155
  - app/controllers/rocket_job_mission_control/dirmon_entries_controller.rb
170
156
  - app/controllers/rocket_job_mission_control/jobs/failures_controller.rb
171
157
  - app/controllers/rocket_job_mission_control/jobs/index_filters_controller.rb
172
158
  - app/controllers/rocket_job_mission_control/jobs_controller.rb
173
- - app/controllers/rocket_job_mission_control/workers/index_filters_controller.rb
174
- - app/controllers/rocket_job_mission_control/workers_controller.rb
175
- - app/datatables/rocket_job_mission_control/active_processes_datatable.rb
159
+ - app/controllers/rocket_job_mission_control/servers/index_filters_controller.rb
160
+ - app/controllers/rocket_job_mission_control/servers_controller.rb
161
+ - app/datatables/rocket_job_mission_control/abstract_datatable.rb
162
+ - app/datatables/rocket_job_mission_control/active_workers_datatable.rb
176
163
  - app/datatables/rocket_job_mission_control/completed_jobs_datatable.rb
177
164
  - app/datatables/rocket_job_mission_control/dirmon_entries_datatable.rb
178
165
  - app/datatables/rocket_job_mission_control/interrupted_jobs_datatable.rb
@@ -180,22 +167,20 @@ files:
180
167
  - app/datatables/rocket_job_mission_control/queued_jobs_datatable.rb
181
168
  - app/datatables/rocket_job_mission_control/running_jobs_datatable.rb
182
169
  - app/datatables/rocket_job_mission_control/scheduled_jobs_datatable.rb
183
- - app/datatables/rocket_job_mission_control/workers_datatable.rb
170
+ - app/datatables/rocket_job_mission_control/servers_datatable.rb
184
171
  - app/helpers/rocket_job_mission_control/application_helper.rb
185
172
  - app/helpers/rocket_job_mission_control/dirmon_entries_helper.rb
186
173
  - app/helpers/rocket_job_mission_control/jobs_helper.rb
187
174
  - app/helpers/rocket_job_mission_control/pagination_helper.rb
175
+ - app/helpers/rocket_job_mission_control/servers_helper.rb
188
176
  - app/helpers/rocket_job_mission_control/slices_helper.rb
189
- - app/helpers/rocket_job_mission_control/workers_helper.rb
190
- - app/interactors/rocket_job_mission_control/dirmon_entries/search.rb
191
- - app/interactors/rocket_job_mission_control/jobs/search.rb
192
- - app/interactors/rocket_job_mission_control/workers/search.rb
193
177
  - app/models/job_failures.rb
194
178
  - app/models/job_sanitizer.rb
179
+ - app/models/rocket_job_mission_control/query.rb
195
180
  - app/views/layouts/rocket_job_mission_control/application.html.haml
196
181
  - app/views/layouts/rocket_job_mission_control/partials/_header.html.haml
197
182
  - app/views/layouts/rocket_job_mission_control/partials/_sidebar.html.haml
198
- - app/views/rocket_job_mission_control/active_processes/index.html.haml
183
+ - app/views/rocket_job_mission_control/active_workers/index.html.haml
199
184
  - app/views/rocket_job_mission_control/dirmon_entries/_form.html.haml
200
185
  - app/views/rocket_job_mission_control/dirmon_entries/_properties.html.haml
201
186
  - app/views/rocket_job_mission_control/dirmon_entries/_sidebar.html.haml
@@ -211,6 +196,7 @@ files:
211
196
  - app/views/rocket_job_mission_control/jobs/_sidebar.html.haml
212
197
  - app/views/rocket_job_mission_control/jobs/_status.html.haml
213
198
  - app/views/rocket_job_mission_control/jobs/edit.html.haml
199
+ - app/views/rocket_job_mission_control/jobs/exceptions.html.haml
214
200
  - app/views/rocket_job_mission_control/jobs/failures/_pagination.html.haml
215
201
  - app/views/rocket_job_mission_control/jobs/failures/index.html.haml
216
202
  - app/views/rocket_job_mission_control/jobs/index.html.haml
@@ -222,13 +208,13 @@ files:
222
208
  - app/views/rocket_job_mission_control/jobs/index_filters/running.html.haml
223
209
  - app/views/rocket_job_mission_control/jobs/index_filters/scheduled.html.haml
224
210
  - app/views/rocket_job_mission_control/jobs/show.html.haml
225
- - app/views/rocket_job_mission_control/workers/_actions.html.haml
226
- - app/views/rocket_job_mission_control/workers/_sidebar.html.haml
227
- - app/views/rocket_job_mission_control/workers/index.html.haml
228
- - app/views/rocket_job_mission_control/workers/index_filters/paused.html.haml
229
- - app/views/rocket_job_mission_control/workers/index_filters/running.html.haml
230
- - app/views/rocket_job_mission_control/workers/index_filters/starting.html.haml
231
- - app/views/rocket_job_mission_control/workers/index_filters/stopping.html.haml
211
+ - app/views/rocket_job_mission_control/servers/_actions.html.haml
212
+ - app/views/rocket_job_mission_control/servers/_sidebar.html.haml
213
+ - app/views/rocket_job_mission_control/servers/index.html.haml
214
+ - app/views/rocket_job_mission_control/servers/index_filters/paused.html.haml
215
+ - app/views/rocket_job_mission_control/servers/index_filters/running.html.haml
216
+ - app/views/rocket_job_mission_control/servers/index_filters/starting.html.haml
217
+ - app/views/rocket_job_mission_control/servers/index_filters/stopping.html.haml
232
218
  - config/locales/en.yml
233
219
  - config/routes.rb
234
220
  - lib/rocket_job_mission_control/engine.rb
@@ -253,18 +239,18 @@ files:
253
239
  - spec/dummy/config/initializers/secret_token.rb
254
240
  - spec/dummy/config/initializers/session_store.rb
255
241
  - spec/dummy/config/initializers/wrap_parameters.rb
256
- - spec/dummy/config/mongo.yml
242
+ - spec/dummy/config/mongoid.yml
257
243
  - spec/dummy/config/routes.rb
258
244
  - spec/dummy/config/secrets.yml
245
+ - spec/dummy/config/symmetric-encryption.yml
259
246
  - spec/dummy/db/test.sqlite3
260
247
  - spec/dummy/log/development.log
261
248
  - spec/dummy/log/test.log
262
249
  - spec/helpers/application_helper_spec.rb
263
250
  - spec/helpers/jobs_helper_spec.rb
264
251
  - spec/helpers/pagination_helper_spec.rb
252
+ - spec/helpers/servers_helper_spec.rb
265
253
  - spec/helpers/slices_helper_spec.rb
266
- - spec/helpers/workers_helper_spec.rb
267
- - spec/interactors/jobs/search_spec.rb
268
254
  - spec/models/job_failures_spec.rb
269
255
  - spec/models/job_sanitizer_spec.rb
270
256
  - spec/rails_helper.rb
@@ -293,12 +279,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
293
279
  version: '0'
294
280
  required_rubygems_version: !ruby/object:Gem::Requirement
295
281
  requirements:
296
- - - ">="
282
+ - - ">"
297
283
  - !ruby/object:Gem::Version
298
- version: '0'
284
+ version: 1.3.1
299
285
  requirements: []
300
286
  rubyforge_project:
301
- rubygems_version: 2.5.1
287
+ rubygems_version: 2.6.8
302
288
  signing_key:
303
289
  specification_version: 4
304
290
  summary: Enterprise Batch Processing System for Ruby.
@@ -319,9 +305,10 @@ test_files:
319
305
  - spec/dummy/config/initializers/secret_token.rb
320
306
  - spec/dummy/config/initializers/session_store.rb
321
307
  - spec/dummy/config/initializers/wrap_parameters.rb
322
- - spec/dummy/config/mongo.yml
308
+ - spec/dummy/config/mongoid.yml
323
309
  - spec/dummy/config/routes.rb
324
310
  - spec/dummy/config/secrets.yml
311
+ - spec/dummy/config/symmetric-encryption.yml
325
312
  - spec/dummy/config.ru
326
313
  - spec/dummy/db/test.sqlite3
327
314
  - spec/dummy/log/development.log
@@ -330,9 +317,8 @@ test_files:
330
317
  - spec/helpers/application_helper_spec.rb
331
318
  - spec/helpers/jobs_helper_spec.rb
332
319
  - spec/helpers/pagination_helper_spec.rb
320
+ - spec/helpers/servers_helper_spec.rb
333
321
  - spec/helpers/slices_helper_spec.rb
334
- - spec/helpers/workers_helper_spec.rb
335
- - spec/interactors/jobs/search_spec.rb
336
322
  - spec/models/job_failures_spec.rb
337
323
  - spec/models/job_sanitizer_spec.rb
338
324
  - spec/rails_helper.rb
@@ -1,27 +0,0 @@
1
- module RocketJobMissionControl
2
- class ActiveProcessesController < RocketJobMissionControl::ApplicationController
3
- def index
4
- # The list of workers actively processing jobs
5
- # [Array[Array<worker_name [String], job [RocketJob::Job], slice_id [String]]]
6
- sorted = true
7
- busy = []
8
- # Need paused, failed or aborted since workers may still be working on active slices
9
- RocketJob::Job.where(state: [:running, :paused, :failed, :aborted]).sort(:worker_name).collect do |job|
10
- if job.respond_to?(:input) && job.sub_state == :processing
11
- sorted = false
12
- job.input.each('state' => 'running') do |slice|
13
- busy << {worker_name: slice.worker_name, klass: job.class.name, description: job.description, started_at: slice.started_at, id: job.id}
14
- end
15
- elsif job.running?
16
- busy << {worker_name: job.worker_name, klass: job.class.name, description: job.description, started_at: job.started_at, id: job.id}
17
- end
18
- end
19
- @busy = sorted ? busy : busy.sort_by { |h| h[:worker_name] }
20
-
21
- respond_to do |format|
22
- format.html
23
- format.json { render(json: ActiveProcessesDatatable.new(view_context, @busy)) }
24
- end
25
- end
26
- end
27
- end
@@ -1,50 +0,0 @@
1
- module RocketJobMissionControl
2
- module Workers
3
- class IndexFiltersController < RocketJobMissionControl::ApplicationController
4
- before_filter :load_workers
5
- before_filter :show_sidebar
6
-
7
- def starting
8
- @workers = @workers.where(state: :starting)
9
- respond_to do |format|
10
- format.html
11
- format.json { render(json: WorkersDatatable.new(view_context, @workers)) }
12
- end
13
- end
14
-
15
- def running
16
- @workers = @workers.where(state: :running)
17
- respond_to do |format|
18
- format.html
19
- format.json { render(json: WorkersDatatable.new(view_context, @workers)) }
20
- end
21
- end
22
-
23
- def paused
24
- @workers = @workers.where(state: :paused)
25
- respond_to do |format|
26
- format.html
27
- format.json { render(json: WorkersDatatable.new(view_context, @workers)) }
28
- end
29
- end
30
-
31
- def stopping
32
- @workers = @workers.where(state: :stopping)
33
- respond_to do |format|
34
- format.html
35
- format.json { render(json: WorkersDatatable.new(view_context, @workers)) }
36
- end
37
- end
38
-
39
- private
40
-
41
- def load_workers
42
- @workers = RocketJob::Worker.sort(:name)
43
- end
44
-
45
- def show_sidebar
46
- @workers_sidebar = true
47
- end
48
- end
49
- end
50
- end
@@ -1,93 +0,0 @@
1
- module RocketJobMissionControl
2
- class WorkersController < RocketJobMissionControl::ApplicationController
3
- before_filter :find_worker, only: [:stop, :pause, :resume, :destroy]
4
- before_filter :show_sidebar
5
-
6
- def index
7
- @workers = RocketJob::Worker.sort(:name)
8
- respond_to do |format|
9
- format.html
10
- format.json { render(json: WorkersDatatable.new(view_context, @workers)) }
11
- end
12
- end
13
-
14
- VALID_STATES = {
15
- stop_all: 'stopped',
16
- pause_all: 'paused',
17
- resume_all: 'resumed',
18
- destroy_zombies: 'destroyed if zombified',
19
- }
20
-
21
- def update_all
22
- worker_action = params[:worker_action].to_sym
23
- if VALID_STATES.keys.include?(worker_action)
24
- RocketJob::Worker.send(worker_action.to_sym)
25
- flash[:notice] = t(:success, scope: [:worker, :update_all], worker_action: VALID_STATES[worker_action])
26
- else
27
- flash[:alert] = t(:invalid, scope: [:worker, :update_all])
28
- end
29
-
30
- respond_to do |format|
31
- format.html { redirect_to workers_path }
32
- end
33
- end
34
-
35
- def stop
36
- if @worker.stop!
37
- flash[:notice] = t(:success, scope: [:worker, :stop])
38
- else
39
- flash[:alert] = t(:failure, scope: [:worker, :stop])
40
- end
41
-
42
- respond_to do |format|
43
- format.html { redirect_to workers_path }
44
- end
45
- end
46
-
47
- def destroy
48
- if @worker.nil? || @worker.destroy
49
- flash[:notice] = t(:success, scope: [:worker, :destroy])
50
- else
51
- flash[:alert] = t(:failure, scope: [:worker, :destroy])
52
- end
53
-
54
- respond_to do |format|
55
- format.html { redirect_to workers_path }
56
- end
57
- end
58
-
59
- def pause
60
- if @worker.pause!
61
- flash[:notice] = t(:success, scope: [:worker, :pause])
62
- else
63
- flash[:alert] = t(:failure, scope: [:worker, :pause])
64
- end
65
-
66
- respond_to do |format|
67
- format.html { redirect_to workers_path }
68
- end
69
- end
70
-
71
- def resume
72
- if @worker.resume!
73
- flash[:notice] = t(:success, scope: [:worker, :resume])
74
- else
75
- flash[:alert] = t(:failure, scope: [:worker, :resume])
76
- end
77
-
78
- respond_to do |format|
79
- format.html { redirect_to workers_path }
80
- end
81
- end
82
-
83
- private
84
-
85
- def find_worker
86
- @worker = RocketJob::Worker.find(params[:id])
87
- end
88
-
89
- def show_sidebar
90
- @workers_sidebar = true
91
- end
92
- end
93
- end
@@ -1,79 +0,0 @@
1
- module RocketJobMissionControl
2
- class ActiveProcessesDatatable
3
- delegate :params, :link_to, :job_path, :state_icon, to: :@view
4
- delegate :h, to: 'ERB::Util'
5
-
6
- def initialize(view, processes)
7
- @view = view
8
- @unfiltered_processes = processes
9
- end
10
-
11
- def as_json(options = {})
12
- {
13
- :draw => params[:draw].to_i,
14
- :recordsTotal => get_raw_records.count,
15
- :recordsFiltered => get_raw_records.count,
16
- :data => data
17
- }
18
- end
19
-
20
- private
21
-
22
- def data
23
- processes.map do |h|
24
- {
25
- '0' => worker_name_with_icon(h[:worker_name]),
26
- '1' => job_name_with_link(h[:klass], h[:id]),
27
- '2' => h(h[:description].try!(:truncate, 50)),
28
- '3' => h(duration(h[:started_at])),
29
- 'DT_RowClass' => "card callout callout-running"
30
- }
31
- end
32
- end
33
-
34
- def get_raw_records
35
- @unfiltered_processes
36
- end
37
-
38
- def processes
39
- @processes ||= fetch_processes
40
- end
41
-
42
- def fetch_processes
43
- records = get_raw_records
44
- records = paginate_records(records) unless params[:length].present? && params[:length] == '-1'
45
- records
46
- end
47
-
48
- def page
49
- (params[:start].to_i / per_page) + 1
50
- end
51
-
52
- def per_page
53
- params.fetch(:length, 10).to_i
54
- end
55
-
56
- def paginate_records(records)
57
- Kaminari.paginate_array(records).page(page).per(per_page)
58
- end
59
-
60
- def worker_name_with_icon(worker_name)
61
- <<-EOS
62
- <i class="fa #{state_icon(:running)}" style="font-size: 75%" title="running"></i>
63
- #{worker_name}
64
- EOS
65
- end
66
-
67
- def job_name_with_link(job_class_name, job_id)
68
- <<-EOS
69
- <a href="#{job_path(job_id)}">
70
- #{job_class_name}
71
- </a>
72
- EOS
73
- end
74
-
75
- def duration(started_at)
76
- "#{RocketJob.seconds_as_duration(Time.now - started_at)} ago" if started_at
77
- end
78
- end
79
- end