barbeque 0.2.4 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3707becb45358885573f40c06905837a35c1896
4
- data.tar.gz: 9ee199c83b68136aca685ef570eb53dba597c05d
3
+ metadata.gz: 7811c426dbfc4b9b7514f444e45845ce6f894a67
4
+ data.tar.gz: 32fb25ca095959abc65c0e751d8edcfd36efee9d
5
5
  SHA512:
6
- metadata.gz: 1a71ed42d5a4055f093339f7eb3dd3a3b46cc4dbed3e56ce7fbf73b3a9ab883d23680f16e8d2fa13b15140072f229094a87ad990419d2da7a923807b47599d3c
7
- data.tar.gz: 6e07242cd9d27bcd55485fae725d9d36c8cc072e801009c52883ecef94ed29a604cdbfa33f1ba610470df7da34858c59d4d8d77424d9de1500aef41b575cb563
6
+ metadata.gz: ab8d6fb436a2dedbd01be1e094199ffb580bcfe5091bb457dd8260223421ed7afd26d02699b0be7aae18ca998a9283bffa54d53a0f1593074e459d728b65b119
7
+ data.tar.gz: 8fb3fedcce8573d92bb6019583d229db768c8ed24e6c107874ea2a02f86fb11d2ad29e68d46013b3b379e191c7d861619b6b389917b557dea8481ad8d3a9df8b
@@ -2,6 +2,7 @@ class Barbeque::JobExecutionsController < Barbeque::ApplicationController
2
2
  def show
3
3
  @job_execution = Barbeque::JobExecution.find(params[:id])
4
4
  @log = @job_execution.execution_log
5
+ @job_retries = @job_execution.job_retries.order(id: :desc)
5
6
  end
6
7
 
7
8
  def retry
@@ -0,0 +1,38 @@
1
+ class Barbeque::MonitorsController < Barbeque::ApplicationController
2
+ def index
3
+ hour_sql = "date_format(#{Barbeque::JobExecution.table_name}.created_at, '%Y-%m-%d %H:00:00')"
4
+ now = Time.zone.now
5
+ from = 6.hours.ago(now.beginning_of_hour)
6
+ rows = Barbeque::JobExecution.
7
+ joins(job_definition: :app).
8
+ where(created_at: from .. now).
9
+ group("#{hour_sql}, #{Barbeque::JobDefinition.table_name}.id").
10
+ pluck("#{hour_sql}, #{Barbeque::App.table_name}.id, #{Barbeque::App.table_name}.name, #{Barbeque::JobDefinition.table_name}.id, #{Barbeque::JobDefinition.table_name}.job, count(1)")
11
+
12
+ jobs = {}
13
+ rows.each do |_, app_id, app_name, job_id, job_name, _|
14
+ job = {
15
+ app_id: app_id,
16
+ app_name: app_name,
17
+ job_id: job_id,
18
+ job_name: job_name,
19
+ }
20
+ jobs[job_id] = job
21
+ end
22
+
23
+ @recently_processed_jobs = {}
24
+ t = from
25
+ while t < now
26
+ @recently_processed_jobs[t] = {}
27
+ jobs.each do |job_id, job|
28
+ @recently_processed_jobs[t][job_id] = job.merge(count: 0)
29
+ end
30
+ t += 1.hour
31
+ end
32
+
33
+ rows.each do |date_hour, _, _, job_id, _, count|
34
+ date_hour = Time.zone.parse("#{date_hour} UTC")
35
+ @recently_processed_jobs[date_hour][job_id] = jobs[job_id].merge(count: count)
36
+ end
37
+ end
38
+ end
@@ -1,3 +1,3 @@
1
1
  = render 'form'
2
2
 
3
- = link_to 'Back', job_definitions_path
3
+ = link_to 'Back', job_definition_path(@job_definition)
@@ -49,7 +49,7 @@
49
49
  Retries
50
50
 
51
51
  .box-body
52
- - if @job_execution.job_retries.present?
52
+ - if @job_retries.present?
53
53
  %table.table.table-bordered
54
54
  %thead
55
55
  %tr
@@ -59,7 +59,7 @@
59
59
  %th Elapsed Time
60
60
  %th
61
61
  %tbody
62
- - @job_execution.job_retries.each do |job_retry|
62
+ - @job_retries.each do |job_retry|
63
63
  %tr
64
64
  %td= job_retry.id
65
65
  %td= status_label(job_retry.status)
@@ -0,0 +1,50 @@
1
+ .row
2
+ .col-sm-12
3
+ .box.box-primary
4
+ .box-header
5
+ %h3.box-title.with_padding Recently processed jobs (hourly)
6
+ .box-body
7
+ #recently-processed-jobs-chart{data: { jobs: @recently_processed_jobs.to_json }}
8
+ %table.table
9
+ %thead
10
+ %tr
11
+ %th Hour
12
+ %th Application
13
+ %th Job
14
+ %th Count
15
+ %tbody
16
+ - @recently_processed_jobs.keys.sort { |x, y| y <=> x }.each do |date_hour|
17
+ - jobs = @recently_processed_jobs[date_hour]
18
+ - jobs.keys.sort.each do |job_id|
19
+ - job = jobs[job_id]
20
+ %tr
21
+ %td= date_hour
22
+ %td= link_to(job[:app_name], app_path(job[:app_id]))
23
+ %td= link_to(job[:job_name], job_definition_path(job[:job_id]))
24
+ %td= job[:count]
25
+
26
+ :coffee
27
+ chartDiv = document.getElementById('recently-processed-jobs-chart')
28
+ recentlyProcesedJobs = JSON.parse(chartDiv.dataset.jobs)
29
+
30
+ countsPerJob = {}
31
+ for own dateHour, jobs of recentlyProcesedJobs
32
+ for own jobId, job of jobs
33
+ name = job.app_name + ' - ' + job.job_name
34
+ countsPerJob[name] ||= []
35
+ countsPerJob[name][dateHour] ||= job.count
36
+
37
+ plotlyArgs = []
38
+ for own name, series of countsPerJob
39
+ x = []
40
+ y = []
41
+ for own dateHour, count of series
42
+ x.push(dateHour)
43
+ y.push(count)
44
+ plotlyArgs.push({
45
+ type: 'scatter',
46
+ name: name,
47
+ x: x,
48
+ y: y,
49
+ })
50
+ Plotly.plot(chartDiv, plotlyArgs)
@@ -2,15 +2,19 @@
2
2
  %section.sidebar
3
3
  %ul.sidebar-menu
4
4
  %li.header Menu
5
- %li{ class: ('active' if controller_path == 'apps') }
5
+ %li{ class: ('active' if controller_path == 'barbeque/apps') }
6
6
  = link_to root_path do
7
7
  %i.fa.fa-users
8
8
  %span Applications
9
- %li{ class: ('active' if controller_path == 'job_definitions') }
9
+ %li{ class: ('active' if controller_path == 'barbeque/job_definitions') }
10
10
  = link_to job_definitions_path do
11
11
  %i.fa.fa-tasks
12
12
  %span Job Definitions
13
- %li{ class: ('active' if controller_path == 'job_queues') }
13
+ %li{ class: ('active' if controller_path == 'barbeque/job_queues') }
14
14
  = link_to job_queues_path do
15
15
  %i.fa.fa-cubes
16
16
  %span Queues
17
+ %li{ class: ('active' if controller_path == 'barbeque/monitors') }
18
+ = link_to monitors_path do
19
+ %i.fa.fa-tachometer
20
+ %span Monitors
@@ -0,0 +1,6 @@
1
+ - content_for(:header) do
2
+ %h1
3
+ .fa.fa-tachometer
4
+ Monitors
5
+
6
+ = render template: 'layouts/barbeque/application'
data/config/routes.rb CHANGED
@@ -16,6 +16,8 @@ Barbeque::Engine.routes.draw do
16
16
 
17
17
  resources :job_queues
18
18
 
19
+ resources :monitors, only: %i[index]
20
+
19
21
  scope :v1, module: 'api', as: :v1 do
20
22
  resources :apps, only: [], param: :name, constraints: { name: /[\w-]+/ } do
21
23
  resource :revision_lock, only: [:create, :destroy]
@@ -1,3 +1,3 @@
1
1
  module Barbeque
2
- VERSION = '0.2.4'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barbeque
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-05 00:00:00.000000000 Z
11
+ date: 2017-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: adminlte2-rails
@@ -288,6 +288,7 @@ files:
288
288
  - app/controllers/barbeque/job_executions_controller.rb
289
289
  - app/controllers/barbeque/job_queues_controller.rb
290
290
  - app/controllers/barbeque/job_retries_controller.rb
291
+ - app/controllers/barbeque/monitors_controller.rb
291
292
  - app/helpers/barbeque/application_helper.rb
292
293
  - app/helpers/barbeque/job_definitions_helper.rb
293
294
  - app/helpers/barbeque/job_executions_helper.rb
@@ -325,6 +326,7 @@ files:
325
326
  - app/views/barbeque/job_queues/new.html.haml
326
327
  - app/views/barbeque/job_queues/show.html.haml
327
328
  - app/views/barbeque/job_retries/show.html.haml
329
+ - app/views/barbeque/monitors/index.html.haml
328
330
  - app/views/layouts/barbeque/_header.html.haml
329
331
  - app/views/layouts/barbeque/_sidebar.html.haml
330
332
  - app/views/layouts/barbeque/application.html.haml
@@ -332,6 +334,7 @@ files:
332
334
  - app/views/layouts/barbeque/job_definitions.html.haml
333
335
  - app/views/layouts/barbeque/job_executions.html.haml
334
336
  - app/views/layouts/barbeque/job_queues.html.haml
337
+ - app/views/layouts/barbeque/monitors.html.haml
335
338
  - config/initializers/garage.rb
336
339
  - config/routes.rb
337
340
  - db/migrate/20160217020910_create_job_queues.rb