line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Minion::Overview; |
2
|
1
|
|
|
1
|
|
66864
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
1
|
|
|
|
|
193930
|
|
|
1
|
|
|
|
|
7
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1608
|
use Mojolicious::Plugin::Minion::Overview::Facade; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
12
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
49
|
use Mojo::ByteStream 'b'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
56
|
|
7
|
1
|
|
|
1
|
|
7
|
use Mojo::Date; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
8
|
1
|
|
|
1
|
|
30
|
use Mojo::File 'path'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
763
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.1.0'; |
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
|
|
|
|
|
|
|
# Recent Jobs |
98
|
0
|
|
|
|
|
|
my $failed_jobs = $prefix->route('failed-jobs') |
99
|
|
|
|
|
|
|
->to(controller => 'FailedJobs'); |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
$failed_jobs->get('/')->to(action => 'search') |
102
|
|
|
|
|
|
|
->name('minion_overview.failed_jobs'); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# Jobs |
105
|
0
|
|
|
|
|
|
my $jobs = $prefix->route('jobs') |
106
|
|
|
|
|
|
|
->to(controller => 'Jobs'); |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
$jobs->get('/')->to(action => 'search') |
109
|
|
|
|
|
|
|
->name('minion_overview.jobs'); |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
$jobs->get('/:id')->to(action => 'show') |
112
|
|
|
|
|
|
|
->name('minion_overview.jobs.show'); |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
$jobs->get('/:id/retry')->to(action => 'retry') |
115
|
|
|
|
|
|
|
->name('minion_overview.jobs.retry'); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# API |
119
|
0
|
|
|
|
|
|
my $api = $prefix->route('api'); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# Metrics |
122
|
0
|
|
|
|
|
|
my $api_metrics = $api->route('metrics'); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# Jobs |
125
|
0
|
|
|
|
|
|
my $api_metrics_jobs = $api_metrics->route('jobs') |
126
|
|
|
|
|
|
|
->to(controller => 'API::Metrics::Jobs'); |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
$api_metrics_jobs->get('/:job/runtime')->to(action => 'runtime') |
129
|
|
|
|
|
|
|
->name('minion_overview.api.metrics.jobs.runtime'); |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
$api_metrics_jobs->get('/:job/throughput')->to(action => 'throughput') |
132
|
|
|
|
|
|
|
->name('minion_overview.api.metrics.jobs.throughput'); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |