barbeque 2.2.0 → 2.3.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
  SHA256:
3
- metadata.gz: 8a27e1555a662fc67cff6d20504bff8e7649f761c4c7500e14f8200347a822ee
4
- data.tar.gz: 535818478a8701f4c1e00f9600328b9e0e2d6c7ccd45ca16e3851319ac8a4676
3
+ metadata.gz: 3026b077536df0611a58ba0aa89d874684f9034c770acda9dcb3157bd3eb3038
4
+ data.tar.gz: 2483622e8a5509fba04ee65cb211f9310499de78c4728f043e020e86dad3d1ee
5
5
  SHA512:
6
- metadata.gz: 768ca47dc94d8479804de1a4c9ddbb3f989732eddbb9c8eb2bbc9778503c076d965929a8a5990e663209ea78e87ca61a62cbd874f2d42876018ba339f15031a9
7
- data.tar.gz: d916df13c88917745c35e1e32c09b1e0c5d2ad1c2801abee8ec35ec2004d07f9048d1372bdf182652e89966c0249608bf2dabc7d0389d9eecac8708aa78cbcf3
6
+ metadata.gz: 0f3ad0c7751118435c9e08f1a7dabc8a9b26244d1658b4a09726234fb1da4b0a8de06e41b7909f378dfed6c1f3fc4d3946eccf2104982376ab517e3cd48b0b33
7
+ data.tar.gz: 6b0872c02ecea57d88b2512ffb23ffc6bbb65942a25f9240eafa4b251a114aae3d41f19aa0e8e012c5c5035908f9de19904cd1df6a809fc6d04e7bcc129bb729
@@ -1,21 +1,40 @@
1
1
  class Barbeque::MonitorsController < Barbeque::ApplicationController
2
2
  def index
3
- hour_sql = "date_format(#{Barbeque::JobExecution.table_name}.created_at, '%Y-%m-%d %H:00:00')"
4
3
  now = Time.zone.now
5
4
  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)")
5
+ rows = Barbeque::JobExecution.find_by_sql([<<SQL.strip_heredoc, from, now]).map(&:attributes)
6
+ select
7
+ t.date_hour
8
+ , app.id as app_id
9
+ , app.name as app_name
10
+ , def.id as job_id
11
+ , def.job as job_name
12
+ , t.cnt
13
+ from
14
+ (
15
+ select
16
+ date_format(e.created_at, '%Y-%m-%d %H:00:00') as date_hour
17
+ , e.job_definition_id
18
+ , count(1) as cnt
19
+ from #{Barbeque::JobExecution.table_name} e
20
+ where
21
+ e.created_at between ? and ?
22
+ group by
23
+ date_hour
24
+ , e.job_definition_id
25
+ ) t
26
+ inner join #{Barbeque::JobDefinition.table_name} def on def.id = t.job_definition_id
27
+ inner join #{Barbeque::App.table_name} app on app.id = def.app_id
28
+ SQL
11
29
 
12
30
  jobs = {}
13
- rows.each do |_, app_id, app_name, job_id, job_name, _|
31
+ rows.each do |row|
32
+ job_id = row.fetch('job_id')
14
33
  job = {
15
- app_id: app_id,
16
- app_name: app_name,
34
+ app_id: row.fetch('app_id'),
35
+ app_name: row.fetch('app_name'),
17
36
  job_id: job_id,
18
- job_name: job_name,
37
+ job_name: row.fetch('job_name'),
19
38
  }
20
39
  jobs[job_id] = job
21
40
  end
@@ -30,9 +49,10 @@ class Barbeque::MonitorsController < Barbeque::ApplicationController
30
49
  t += 1.hour
31
50
  end
32
51
 
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)
52
+ rows.each do |row|
53
+ date_hour = Time.zone.parse("#{row.fetch('date_hour')} UTC")
54
+ job_id = row.fetch('job_id')
55
+ @recently_processed_jobs[date_hour][job_id] = jobs[job_id].merge(count: row.fetch('cnt'))
36
56
  end
37
57
  end
38
58
  end
@@ -0,0 +1,5 @@
1
+ class AddIndexToBarbequeJobExecutionsCreatedAt < ActiveRecord::Migration[5.1]
2
+ def change
3
+ add_index :barbeque_job_executions, :created_at
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Barbeque
2
- VERSION = '2.2.0'
2
+ VERSION = '2.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: 2.2.0
4
+ version: 2.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: 2018-03-07 00:00:00.000000000 Z
11
+ date: 2018-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: adminlte2-rails
@@ -420,6 +420,7 @@ files:
420
420
  - db/migrate/20170711085157_create_barbeque_docker_containers.rb
421
421
  - db/migrate/20170712075449_create_barbeque_ecs_hako_tasks.rb
422
422
  - db/migrate/20170724025542_add_index_to_job_execution_status.rb
423
+ - db/migrate/20180411070937_add_index_to_barbeque_job_executions_created_at.rb
423
424
  - lib/barbeque.rb
424
425
  - lib/barbeque/config.rb
425
426
  - lib/barbeque/docker_image.rb