line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GrowthForecast::Aggregator::DB; |
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
4
|
1
|
|
|
1
|
|
871
|
use utf8; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
4
|
|
5
|
1
|
|
|
1
|
|
18305
|
use Encode qw(encode_utf8); |
|
1
|
|
|
|
|
23526
|
|
|
1
|
|
|
|
|
189
|
|
6
|
1
|
|
|
1
|
|
1804
|
use HTTP::Request::Common; |
|
1
|
|
|
|
|
80143
|
|
|
1
|
|
|
|
|
112
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
1165
|
use Mouse; |
|
1
|
|
|
|
|
50452
|
|
|
1
|
|
|
|
|
7
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has name => ( |
11
|
|
|
|
|
|
|
is => 'ro', |
12
|
|
|
|
|
|
|
isa => 'Str', |
13
|
|
|
|
|
|
|
required => 1, |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has description => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
isa => 'Str', |
19
|
|
|
|
|
|
|
required => 1, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has section => ( |
23
|
|
|
|
|
|
|
is => 'ro', |
24
|
|
|
|
|
|
|
isa => 'Str', |
25
|
|
|
|
|
|
|
required => 1, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has query => ( |
29
|
|
|
|
|
|
|
is => 'rw', |
30
|
|
|
|
|
|
|
isa => 'Str', |
31
|
|
|
|
|
|
|
required => 1, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has binds => ( |
35
|
|
|
|
|
|
|
is => 'rw', |
36
|
|
|
|
|
|
|
isa => 'ArrayRef', |
37
|
|
|
|
|
|
|
default => sub { +[ ] }, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
1
|
|
432
|
no Mouse; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub run { |
43
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
44
|
0
|
|
|
|
|
|
my %args = @_; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
0
|
|
|
|
my $dbh = $args{dbh} // die "Missing mandatory parameter: dbh"; |
47
|
0
|
|
0
|
|
|
|
my $service = $args{service} // die "Missing mandatory parameter: service"; |
48
|
0
|
|
0
|
|
|
|
my $endpoint = $args{endpoint} // die "Missing mandatory parameter: endpoint"; |
49
|
0
|
|
0
|
|
|
|
my $ua = $args{ua} // die "Missing mandatory parameter: ua"; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$endpoint =~ s!/$!!; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $url = "$endpoint/$service/$self->{section}/$self->{name}"; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $sth = $dbh->prepare($self->query); |
56
|
0
|
|
|
|
|
|
$sth->execute(@{$self->binds}); |
|
0
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my ($number) = $sth->fetchrow_array(); |
58
|
0
|
|
|
|
|
|
my $req = POST $url, [ |
59
|
|
|
|
|
|
|
number => $number, |
60
|
|
|
|
|
|
|
description => encode_utf8($self->description), |
61
|
|
|
|
|
|
|
]; |
62
|
0
|
|
|
|
|
|
my $res = $ua->request($req); |
63
|
0
|
|
|
|
|
|
return $res; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
__END__ |