Skip to content

Commit

Permalink
Add initial Performance panel to dashboard (#1388)
Browse files Browse the repository at this point in the history

---------

Co-authored-by: Arnaud Levy <contact@arnaudlevy.com>
Co-authored-by: Arnaud Levy <arnaud.levy@noesya.coop>
Co-authored-by: Sébastien Gaya <sebastien.gaya@gmail.com>
  • Loading branch information
4 people committed Jul 6, 2024
1 parent d8b6344 commit 94b672c
Show file tree
Hide file tree
Showing 20 changed files with 258 additions and 1 deletion.
23 changes: 23 additions & 0 deletions app/controllers/good_job/performances_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

module GoodJob
class PerformancesController < ApplicationController
def index
if GoodJob::DiscreteExecution.monotonic_duration_migrated?
@performances = GoodJob::DiscreteExecution
.where.not(job_class: nil)
.group(:job_class)
.select("
job_class,
COUNT(*) AS executions_count,
AVG(duration) AS avg_duration,
MIN(duration) AS min_duration,
MAX(duration) AS max_duration
")
.order("job_class")
else
@needs_upgrade = true
end
end
end
end
1 change: 1 addition & 0 deletions app/helpers/good_job/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module ApplicationHelper

def format_duration(sec)
return unless sec
return "" if sec.is_a?(String) # pg interval support added in Rails 6.1

if sec < 1
t 'good_job.duration.milliseconds', ms: (sec * 1000).floor
Expand Down
50 changes: 50 additions & 0 deletions app/views/good_job/performances/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<div class="border-bottom">
<h2 class="pt-3 pb-2"><%= t ".title" %></h2>
</div>

<% if @needs_upgrade %>
<div class="alert alert-warning">
<%= t "shared.needs_migration" %>
</div>
<% else %>

<div class="my-3 card">
<div class="list-group list-group-flush text-nowrap" role="table">
<header class="list-group-item bg-body-tertiary">
<div class="row small text-muted text-uppercase align-items-center">
<div class="col-12 col-lg-4"><%= t ".job_class" %></div>
<div class="col-lg-1 d-none d-lg-block"><%= t ".executions" %></div>

<div class="col-lg-1 d-none d-lg-block"><%= t ".average_duration" %></div>
<div class="col-lg-1 d-none d-lg-block"><%= t ".minimum_duration" %></div>
<div class="col-lg-1 d-none d-lg-block"><%= t ".maximum_duration" %></div>
</div>
</header>

<% @performances.each do |performance| %>
<div role="row" class="list-group-item py-3">
<div class="row align-items-center">
<div class="col-12 col-lg-4"><%= performance.job_class %></div>
<div class="col-6 col-lg-1 text-wrap">
<div class="d-lg-none small text-muted mt-1"><%= t ".executions" %></div>
<%= performance.executions_count %>
</div>

<div class="col-6 col-lg-1 text-wrap">
<div class="d-lg-none small text-muted mt-1"><%= t ".average_duration" %></div>
<%= format_duration performance.avg_duration %>
</div>
<div class="col-6 col-lg-1 text-wrap">
<div class="d-lg-none small text-muted mt-1"><%= t ".minimum_duration" %></div>
<%= format_duration performance.min_duration %>
</div>
<div class="col-6 col-lg-1 text-wrap">
<div class="d-lg-none small text-muted mt-1"><%= t ".maximum_duration" %></div>
<%= format_duration performance.max_duration %>
</div>
</div>
</div>
<% end %>
</div>
</div>
<% end %>
5 changes: 5 additions & 0 deletions app/views/good_job/shared/_navbar.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
<span data-async-values-target="value" data-async-values-key="processes_count" data-async-values-zero-class="bg-danger" class="badge bg-secondary rounded-pill d-none"></span>
<% end %>
</li>
<li class="nav-item">
<%= link_to performances_path, class: ["nav-link", ("active" if controller_name == 'performances')] do %>
<%= t(".performances") %>
<% end %>
</li>
</ul>

<ul class="navbar-nav">
Expand Down
11 changes: 11 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ de:
thousand: K
trillion: T
unit: ''
performances:
index:
average_duration: Durchschnittliche Dauer
executions: Hinrichtungen
job_class: Berufsklasse
maximum_duration: Maximale Dauer
minimum_duration: Mindestdauer
title: Leistung
processes:
index:
cron_enabled: Cron aktiviert
Expand Down Expand Up @@ -225,6 +233,7 @@ de:
jobs: Jobs
live_poll: Live Poll
name: "GoodJob 👍"
performances: Leistung
processes: Prozesse
theme:
auto: Auto
Expand All @@ -241,3 +250,5 @@ de:
running: Laufend
scheduled: Geplant
succeeded: Erfolgreich
shared:
needs_migration: Bitte führen Sie GoodJob-Migrationen aus.
11 changes: 11 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ en:
thousand: K
trillion: T
unit: ''
performances:
index:
average_duration: Average duration
executions: Executions
job_class: Job class
maximum_duration: Maximum duration
minimum_duration: Minimum duration
title: Performance
processes:
index:
cron_enabled: Cron enabled
Expand Down Expand Up @@ -225,6 +233,7 @@ en:
jobs: Jobs
live_poll: Live Poll
name: "GoodJob 👍"
performances: Performance
processes: Processes
theme:
auto: Auto
Expand All @@ -241,3 +250,5 @@ en:
running: Running
scheduled: Scheduled
succeeded: Succeeded
shared:
needs_migration: Please run GoodJob migrations.
11 changes: 11 additions & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ es:
thousand: k
trillion: T
unit: ''
performances:
index:
average_duration: Duración promedio
executions: Ejecuciones
job_class: clase de trabajo
maximum_duration: Duración máxima
minimum_duration: Duración mínima
title: Actuación
processes:
index:
cron_enabled: Cron habilitado
Expand Down Expand Up @@ -225,6 +233,7 @@ es:
jobs: Tareas
live_poll: En vivo
name: "GoodJob 👍"
performances: Actuación
processes: Procesos
theme:
auto: Auto
Expand All @@ -241,3 +250,5 @@ es:
running: Ejecutando
scheduled: Programado
succeeded: Exitoso
shared:
needs_migration: Ejecute las migraciones de GoodJob.
11 changes: 11 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ fr:
thousand: k
trillion: J
unit: ''
performances:
index:
average_duration: Durée moyenne
executions: Exécutions
job_class: Catégorie d'emplois
maximum_duration: Durée maximale
minimum_duration: Durée minimale
title: Performance
processes:
index:
cron_enabled: Cron activé
Expand Down Expand Up @@ -225,6 +233,7 @@ fr:
jobs: Jobs
live_poll: En direct
name: "GoodJob 👍"
performances: Performance
processes: Processus
theme:
auto: Auto
Expand All @@ -241,3 +250,5 @@ fr:
running: En cours
scheduled: Planifiés
succeeded: Réussis
shared:
needs_migration: Veuillez exécuter des migrations GoodJob.
11 changes: 11 additions & 0 deletions config/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ it:
thousand: K
trillion: T
unit: ''
performances:
index:
average_duration: Durata media
executions: Esecuzioni
job_class: Classe di lavoro
maximum_duration: Durata massima
minimum_duration: Durata minima
title: Prestazione
processes:
index:
cron_enabled: Cron abilitato
Expand Down Expand Up @@ -225,6 +233,7 @@ it:
jobs: Job
live_poll: Live Poll
name: "GoodJob 👍"
performances: Prestazione
processes: Processi
theme:
auto: Auto
Expand All @@ -241,3 +250,5 @@ it:
running: In esecuzione
scheduled: Pianificato
succeeded: Riuscito
shared:
needs_migration: Esegui le migrazioni GoodJob.
11 changes: 11 additions & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ ja:
thousand: K
trillion: T
unit: ''
performances:
index:
average_duration: 平均所要時間
executions: 処刑
job_class: 職種
maximum_duration: 最大持続時間
minimum_duration: 最小期間
title: パフォーマンス
processes:
index:
cron_enabled: Cron が有効になっている
Expand Down Expand Up @@ -225,6 +233,7 @@ ja:
jobs: ジョブ
live_poll: リアルタイム更新
name: "GoodJob 👍"
performances: パフォーマンス
processes: プロセス
theme:
auto: 自動
Expand All @@ -241,3 +250,5 @@ ja:
running: 実行中
scheduled: スケジュール待ち
succeeded: 成功済み
shared:
needs_migration: GoodJob 移行を実行してください。
11 changes: 11 additions & 0 deletions config/locales/ko.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ ko:
thousand: K
trillion: T
unit: ''
performances:
index:
average_duration: 평균 지속 시간
executions: 처형
job_class: 직업군
maximum_duration: 최대 기간
minimum_duration: 최소 기간
title: 성능
processes:
index:
cron_enabled: Cron이 활성화되어 있음
Expand Down Expand Up @@ -225,6 +233,7 @@ ko:
jobs: 작업
live_poll: 실시간 업데이트
name: "GoodJob 👍"
performances: 성능
processes: 프로세스
theme:
auto: 자동
Expand All @@ -241,3 +250,5 @@ ko:
running: 실행 중
scheduled: 예정됨
succeeded: 성공함
shared:
needs_migration: GoodJob 마이그레이션을 실행하세요.
11 changes: 11 additions & 0 deletions config/locales/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ nl:
thousand: K
trillion: T
unit: ''
performances:
index:
average_duration: Gemiddelde duur
executions: Executies
job_class: Functie klasse
maximum_duration: Maximale duur
minimum_duration: Minimale duur
title: Prestatie
processes:
index:
cron_enabled: Cron ingeschakeld
Expand Down Expand Up @@ -225,6 +233,7 @@ nl:
jobs: Taken
live_poll: Live Poll
name: "GoodJob 👍"
performances: Prestatie
processes: Processen
theme:
auto: Auto
Expand All @@ -241,3 +250,5 @@ nl:
running: Rennen
scheduled: Gepland
succeeded: Geslaagd
shared:
needs_migration: Voer GoodJob-migraties uit.
11 changes: 11 additions & 0 deletions config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ pt-BR:
thousand: K
trillion: T
unit: ''
performances:
index:
average_duration: Duração média
executions: Execuções
job_class: Classe de trabalho
maximum_duration: Duração máxima
minimum_duration: Duração mínima
title: Desempenho
processes:
index:
cron_enabled: Agendamento ativado
Expand Down Expand Up @@ -225,6 +233,7 @@ pt-BR:
jobs: Tarefas
live_poll: Acompanhamento ao Vivo
name: "GoodJob 👍"
performances: Desempenho
processes: Processos
theme:
auto: Automático
Expand All @@ -241,3 +250,5 @@ pt-BR:
running: Em execução
scheduled: Agendado
succeeded: Concluído com sucesso
shared:
needs_migration: Execute migrações GoodJob.
11 changes: 11 additions & 0 deletions config/locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,14 @@ ru:
thousand: К
trillion: Т
unit: ''
performances:
index:
average_duration: Средняя продолжительность
executions: Казни
job_class: Класс работы
maximum_duration: Максимальная продолжительность
minimum_duration: Минимальная продолжительность
title: Производительность
processes:
index:
cron_enabled: Cron включен
Expand Down Expand Up @@ -251,6 +259,7 @@ ru:
jobs: Задания
live_poll: Обновления в реальном времени
name: "GoodJob 👍"
performances: Производительность
processes: Процессы
theme:
auto: Авто
Expand All @@ -267,3 +276,5 @@ ru:
running: Исполняется
scheduled: Запланировано
succeeded: Успешно
shared:
needs_migration: Пожалуйста, запустите миграцию GoodJob.
Loading

0 comments on commit 94b672c

Please sign in to comment.