line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Minion::Overview; |
2
|
1
|
|
|
1
|
|
69081
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
1
|
|
|
|
|
192914
|
|
|
1
|
|
|
|
|
8
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1469
|
use Mojolicious::Plugin::Minion::Overview::Facade; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
12
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
46
|
use Mojo::ByteStream 'b'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
62
|
|
7
|
1
|
|
|
1
|
|
8
|
use Mojo::Date; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
8
|
1
|
|
|
1
|
|
31
|
use Mojo::File 'path'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
828
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.1.2'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head2 register |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Register the plugin and defined the routes |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub register { |
20
|
0
|
|
|
0
|
1
|
|
my ($self, $app, $config) = @_; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# TODO: Find out why the connection is dropped |
23
|
|
|
|
|
|
|
# my $minion_overview = Mojolicious::Plugin::Minion::Overview::Facade->load($app->minion); |
24
|
0
|
|
|
0
|
|
|
$app->helper(minion_overview => sub { Mojolicious::Plugin::Minion::Overview::Facade->load($app->minion) }); |
|
0
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$app->helper(overview_job_status => sub { |
27
|
0
|
|
|
0
|
|
|
my ($c, $status) = @_; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $html = sprintf('', $status); |
30
|
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
if ($status eq 'finished') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
$html = sprintf('', $status); |
33
|
|
|
|
|
|
|
} elsif ($status eq 'failed') { |
34
|
0
|
|
|
|
|
|
$html = sprintf('', $status); |
35
|
|
|
|
|
|
|
} elsif ($status eq 'active') { |
36
|
0
|
|
|
|
|
|
$html = sprintf('', $status); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
return b($html); |
40
|
0
|
|
|
|
|
|
}); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$app->helper(overview_job_date => sub { |
43
|
0
|
|
|
0
|
|
|
my ($c, $timestamp) = @_; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $date = Mojo::Date->new($timestamp); |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return $date->to_datetime; |
48
|
0
|
|
|
|
|
|
}); |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
push(@{ $app->routes->namespaces }, 'Mojolicious::Plugin::Minion::Overview::Controller'); |
|
0
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Config |
53
|
0
|
|
0
|
|
|
|
my $prefix = $config->{route} // $app->routes->route('minion-overview'); |
54
|
0
|
|
0
|
|
|
|
$prefix->to(return_to => $config->{return_to} // '/'); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Static files |
57
|
0
|
|
|
|
|
|
my $resources = path(__FILE__)->sibling('Overview', 'resources'); |
58
|
0
|
|
|
|
|
|
push @{$app->static->paths}, $resources->child('public')->to_string; |
|
0
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Templates |
61
|
0
|
|
|
|
|
|
push @{$app->renderer->paths}, $resources->child('templates')->to_string; |
|
0
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Set date |
64
|
0
|
|
|
|
|
|
$prefix->get('/date/:date') |
65
|
|
|
|
|
|
|
->to(controller => 'Overview', action => 'setDate') |
66
|
|
|
|
|
|
|
->name('minion_overview.overview.set_date'); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Dashboard |
69
|
0
|
|
|
|
|
|
$prefix->get('/') |
70
|
|
|
|
|
|
|
->to(controller => 'Dashboard', action => 'search'); |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $dashboard = $prefix->route('dashboard') |
73
|
|
|
|
|
|
|
->to(controller => 'Dashboard'); |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
$dashboard->get('/')->to(action => 'search') |
76
|
|
|
|
|
|
|
->name('minion_overview.dashboard'); |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
$dashboard->get('overview')->to(action => 'overview') |
79
|
|
|
|
|
|
|
->name('minion_overview.dashboard.overview'); |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$dashboard->get('workers')->to(action => 'workers') |
82
|
|
|
|
|
|
|
->name('minion_overview.dashboard.workers'); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Metrics |
85
|
0
|
|
|
|
|
|
my $metrics = $prefix->route('metrics') |
86
|
|
|
|
|
|
|
->to(controller => 'Metrics'); |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
$metrics->get('/')->to(action => 'search') |
89
|
|
|
|
|
|
|
->name('minion_overview.metrics'); |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
my $metrics_jobs = $metrics->route('jobs') |
92
|
|
|
|
|
|
|
->to(controller => 'Metrics::Jobs'); |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
$metrics_jobs->get(':job')->to(action => 'show') |
95
|
|
|
|
|
|
|
->name('minion_overview.metrics.jobs.show'); |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
my $metrics_workers = $metrics->route('workers') |
98
|
|
|
|
|
|
|
->to(controller => 'Metrics::Workers'); |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
$metrics_workers->get(':worker')->to(action => 'show') |
101
|
|
|
|
|
|
|
->name('minion_overview.metrics.workers.show'); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# Recent Jobs |
104
|
0
|
|
|
|
|
|
my $failed_jobs = $prefix->route('failed-jobs') |
105
|
|
|
|
|
|
|
->to(controller => 'FailedJobs'); |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
$failed_jobs->get('/')->to(action => 'search') |
108
|
|
|
|
|
|
|
->name('minion_overview.failed_jobs'); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# Jobs |
111
|
0
|
|
|
|
|
|
my $jobs = $prefix->route('jobs') |
112
|
|
|
|
|
|
|
->to(controller => 'Jobs'); |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
$jobs->get('/')->to(action => 'search') |
115
|
|
|
|
|
|
|
->name('minion_overview.jobs'); |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
$jobs->get('/:id')->to(action => 'show') |
118
|
|
|
|
|
|
|
->name('minion_overview.jobs.show'); |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
$jobs->get('/:id/retry')->to(action => 'retry') |
121
|
|
|
|
|
|
|
->name('minion_overview.jobs.retry'); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# API |
125
|
0
|
|
|
|
|
|
my $api = $prefix->route('api'); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# Metrics |
128
|
0
|
|
|
|
|
|
my $api_metrics = $api->route('metrics'); |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# Jobs |
131
|
0
|
|
|
|
|
|
my $api_metrics_jobs = $api_metrics->route('jobs') |
132
|
|
|
|
|
|
|
->to(controller => 'API::Metrics::Jobs'); |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
$api_metrics_jobs->get('/:job/runtime')->to(action => 'runtime') |
135
|
|
|
|
|
|
|
->name('minion_overview.api.metrics.jobs.runtime'); |
136
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
$api_metrics_jobs->get('/:job/throughput')->to(action => 'throughput') |
138
|
|
|
|
|
|
|
->name('minion_overview.api.metrics.jobs.throughput'); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# Workers |
141
|
0
|
|
|
|
|
|
my $api_metrics_workers = $api_metrics->route('workers') |
142
|
|
|
|
|
|
|
->to(controller => 'API::Metrics::Workers'); |
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
$api_metrics_workers->get('/:worker/waittime')->to(action => 'waittime') |
145
|
|
|
|
|
|
|
->name('minion_overview.api.metrics.workers.waittime'); |
146
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
$api_metrics_workers->get('/:worker/throughput')->to(action => 'throughput') |
148
|
|
|
|
|
|
|
->name('minion_overview.api.metrics.workers.throughput'); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
1; |