line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Minion::Overview::Backend; |
2
|
1
|
|
|
1
|
|
525
|
use Mojo::Base -base; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
59
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
672
|
use Minion; |
|
1
|
|
|
|
|
168829
|
|
|
1
|
|
|
|
|
9
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has 'db'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has 'minion' => sub { Minion->new }, weak => 1; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'query' => sub {{ |
11
|
|
|
|
|
|
|
limit => 25, |
12
|
|
|
|
|
|
|
page => 1, |
13
|
|
|
|
|
|
|
where => {}, |
14
|
|
|
|
|
|
|
tags => [], |
15
|
|
|
|
|
|
|
term => '', |
16
|
|
|
|
|
|
|
}}; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has 'start' => 'CURDATE()'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 clear_query |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Clear the query fields |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub clear_query { |
28
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
$self->query({ |
31
|
|
|
|
|
|
|
limit => 25, |
32
|
|
|
|
|
|
|
page => 1, |
33
|
|
|
|
|
|
|
where => {}, |
34
|
|
|
|
|
|
|
tags => [], |
35
|
|
|
|
|
|
|
term => '', |
36
|
|
|
|
|
|
|
}); |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
return $self; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 date |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Set date |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub date { |
48
|
0
|
|
|
0
|
1
|
|
my ($self, $date) = @_; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $start = 'CURDATE()'; |
51
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
if ($date eq 'Since yesterday') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$start = 'DATE_ADD(CURDATE(), INTERVAL -1 DAY)'; |
54
|
|
|
|
|
|
|
} elsif ($date eq 'Last 3 days') { |
55
|
0
|
|
|
|
|
|
$start = 'DATE_ADD(CURDATE(), INTERVAL -3 DAY)'; |
56
|
|
|
|
|
|
|
} elsif ($date eq 'Last 7 days') { |
57
|
0
|
|
|
|
|
|
$start = 'DATE_ADD(CURDATE(), INTERVAL -7 DAY)'; |
58
|
|
|
|
|
|
|
} elsif ($date eq 'This month') { |
59
|
0
|
|
|
|
|
|
$start = 'LAST_DAY(CURDATE() + INTERVAL -1 MONTH) + INTERVAL 1 DAY'; |
60
|
|
|
|
|
|
|
} elsif ($date eq 'Last 3 months') { |
61
|
0
|
|
|
|
|
|
$start = 'LAST_DAY(CURDATE() + INTERVAL -3 MONTH) + INTERVAL 1 DAY'; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$self->start($start); |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
return $self; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 dashboard |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Dashboard stats |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub dashboard { |
76
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
return { |
79
|
0
|
|
|
|
|
|
overview => $self->overview, |
80
|
|
|
|
|
|
|
workers => $self->workers, |
81
|
|
|
|
|
|
|
}; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 failed_jobs |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Search failed jobs |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub failed_jobs { |
91
|
0
|
|
|
0
|
1
|
|
return {}; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 job |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Find a job by id |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub job { |
101
|
0
|
|
|
0
|
1
|
|
my ($self, $id) = @_; |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
return $self->minion->job($id); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 job_runtime_metrics |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Job runtime metrics |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub job_runtime_metrics { |
113
|
0
|
|
|
0
|
1
|
|
return []; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 job_throughput_metrics |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Job throughput metrics |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub job_throughput_metrics { |
123
|
0
|
|
|
0
|
1
|
|
return []; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 jobs |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Search jobs |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub jobs { |
133
|
0
|
|
|
0
|
1
|
|
return {}; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 limit |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Set the limit and return current instance |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub limit { |
143
|
0
|
|
|
0
|
1
|
|
my ($self, $limit) = @_; |
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
|
$self->query->{ limit } = $limit; |
146
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
return $self; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 overview |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Dashboard overview |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub overview { |
157
|
0
|
|
|
0
|
1
|
|
return []; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head2 page |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Set the page and return current instance |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=cut |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub page { |
167
|
0
|
|
|
0
|
1
|
|
my ($self, $page) = @_; |
168
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
$self->query->{ page } = $page; |
170
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
return $self; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head2 search |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Set the search term and return current instance |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub search { |
181
|
0
|
|
|
0
|
1
|
|
my ($self, $term) = @_; |
182
|
|
|
|
|
|
|
|
183
|
0
|
|
|
|
|
|
$self->query->{ term } = $term; |
184
|
|
|
|
|
|
|
|
185
|
0
|
|
|
|
|
|
return $self; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head2 tags |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Set the search tags and return current instance |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=cut |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
sub tags { |
195
|
0
|
|
|
0
|
1
|
|
my ($self, $tags) = @_; |
196
|
|
|
|
|
|
|
|
197
|
0
|
|
|
|
|
|
push(@{ $self->query->{ tags } }, @$tags); |
|
0
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
|
199
|
0
|
|
|
|
|
|
return $self; |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head2 unique_jobs |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Search the list of unique jobs |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=cut |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub unique_jobs { |
209
|
0
|
|
|
0
|
1
|
|
return {}; |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head2 when |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Add where condition when first param is true |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=cut |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
sub when { |
219
|
0
|
|
|
0
|
1
|
|
my ($self, $value, $field) = @_; |
220
|
|
|
|
|
|
|
|
221
|
0
|
0
|
|
|
|
|
if ($value) { |
222
|
0
|
|
|
|
|
|
$self->where($field, $value); |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
0
|
|
|
|
|
|
return $self; |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head2 where |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Add a condition for a field and return current instance |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=cut |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
sub where { |
235
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
236
|
0
|
|
|
|
|
|
my $field = shift; |
237
|
0
|
|
|
|
|
|
my $condition = shift; |
238
|
0
|
|
|
|
|
|
my $value = shift; |
239
|
|
|
|
|
|
|
|
240
|
0
|
|
0
|
|
|
|
$self->query->{ where }->{ $field } = $value || $condition; |
241
|
|
|
|
|
|
|
|
242
|
0
|
|
|
|
|
|
return $self; |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head2 worker |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
Find a worker by id |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=cut |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
sub worker { |
252
|
0
|
|
|
0
|
1
|
|
return {}; |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head2 worker_waittime_metrics |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
Worker waittime metrics |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=cut |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
sub worker_waittime_metrics { |
262
|
0
|
|
|
0
|
1
|
|
return []; |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=head2 worker_throughput_metrics |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
Worker throughput metrics |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=cut |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
sub worker_throughput_metrics { |
272
|
0
|
|
|
0
|
1
|
|
return []; |
273
|
|
|
|
|
|
|
} |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=head2 workers |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
Get workers information |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=cut |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
sub workers { |
282
|
0
|
|
|
0
|
1
|
|
return []; |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
1; |