line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BenchmarkAnything::Storage::Frontend::HTTP::Controller::Search; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:SCHWIGON'; |
3
|
|
|
|
|
|
|
# ABSTRACT: BenchmarkAnything - REST API - data query |
4
|
|
|
|
|
|
|
$BenchmarkAnything::Storage::Frontend::HTTP::Controller::Search::VERSION = '0.010'; |
5
|
2
|
|
|
2
|
|
18937
|
use Mojo::Base 'Mojolicious::Controller'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
12
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub hello |
9
|
|
|
|
|
|
|
{ |
10
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
|
|
0
|
$self->render; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub search |
17
|
|
|
|
|
|
|
{ |
18
|
3
|
|
|
3
|
1
|
23957
|
my ($self) = @_; |
19
|
|
|
|
|
|
|
|
20
|
3
|
|
|
|
|
34
|
my $value_id = $self->param('value_id'); |
21
|
3
|
|
|
|
|
81
|
my $query = $self->req->json; |
22
|
|
|
|
|
|
|
|
23
|
3
|
100
|
|
|
|
4155
|
if ($value_id) { |
|
|
100
|
|
|
|
|
|
24
|
1
|
|
|
|
|
5
|
$self->render(json => $self->app->backend->get_single_benchmark_point($value_id)); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
elsif ($query) |
27
|
|
|
|
|
|
|
{ |
28
|
1
|
|
|
|
|
7
|
$self->render(json => $self->app->backend->search_array($query)); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else |
31
|
|
|
|
|
|
|
{ |
32
|
1
|
|
|
|
|
5
|
$self->render(json => []); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub listnames |
38
|
|
|
|
|
|
|
{ |
39
|
4
|
|
|
4
|
1
|
25575
|
my ($self) = @_; |
40
|
|
|
|
|
|
|
|
41
|
4
|
|
|
|
|
25
|
my $pattern = $self->param('pattern'); |
42
|
|
|
|
|
|
|
|
43
|
4
|
50
|
|
|
|
109
|
my @pattern = $pattern ? ($pattern) : (); |
44
|
4
|
|
|
|
|
15
|
my $answer = $self->app->backend->list_benchmark_names(@pattern); |
45
|
|
|
|
|
|
|
|
46
|
4
|
|
|
|
|
79383
|
$self->render(json => $answer); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub listkeys |
51
|
|
|
|
|
|
|
{ |
52
|
2
|
|
|
2
|
1
|
25249
|
my ($self) = @_; |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
10
|
my $pattern = $self->param('pattern'); |
55
|
|
|
|
|
|
|
|
56
|
2
|
50
|
|
|
|
50
|
my @pattern = $pattern ? ($pattern) : (); |
57
|
2
|
|
|
|
|
7
|
my $answer = $self->app->backend->list_additional_keys(@pattern); |
58
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
837
|
$self->render(json => $answer); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub stats |
64
|
|
|
|
|
|
|
{ |
65
|
1
|
|
|
1
|
1
|
9888
|
my ($self) = @_; |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
|
|
6
|
my $answer = $self->app->backend->get_stats; |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
1055
|
$self->render(json => $answer); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=pod |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=encoding UTF-8 |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 NAME |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
BenchmarkAnything::Storage::Frontend::HTTP::Controller::Search - BenchmarkAnything - REST API - data query |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 hello |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Returns a hello answer. Mostly for self and unit testing. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 search |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Parameters: |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=over 4 |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item * value_id (INTEGER) |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
If a single integer value is provided the complete data point for that |
97
|
|
|
|
|
|
|
ID is returned. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item * JSON request body |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
If a JSON request is provided it is interpreted as query according to |
102
|
|
|
|
|
|
|
L<BenchmarkAnything::Storage::Backend::SQL::search()|BenchmarkAnything::Storage::Backend::SQL/search>. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=back |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 listnames |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Returns a list of available benchmark metric NAMEs. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Parameters: |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=over 4 |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item * pattern (STRING) |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
If a pattern is provided it restricts the results. The pattern is used |
117
|
|
|
|
|
|
|
as SQL LIKE pattern, i.e., it allows to use C<%> as wildcards. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=back |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 listkeys |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Returns a list of additional key names. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Parameters: |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=over 4 |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * pattern (STRING) |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
If a pattern is provided it restricts the results. The pattern is used |
132
|
|
|
|
|
|
|
as SQL LIKE pattern, i.e., it allows to use C<%> as wildcards. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=back |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 stats |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Returns a hash with info about the storage, like how many data points, |
139
|
|
|
|
|
|
|
how many metrics, how many additional keys, are stored. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Parameters: none |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 AUTHOR |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Steffen Schwigon <ss5@renormalist.net> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Steffen Schwigon. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
152
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |