line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::OptimalQuery::JSON; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
691
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
4
|
no warnings qw( uninitialized ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
6
|
1
|
|
|
1
|
|
4
|
use base 'CGI::OptimalQuery::Base'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
69
|
|
7
|
1
|
|
|
1
|
|
5
|
use CGI(); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
8
|
1
|
|
|
1
|
|
3
|
use JSON::XS(); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
151
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub output { |
11
|
0
|
|
|
0
|
0
|
|
my $o = shift; |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
|
|
|
my $title = $o->{schema}->{title}; |
14
|
0
|
|
|
|
|
|
$title =~ s/\W//g; |
15
|
0
|
|
|
|
|
|
my @t = localtime; |
16
|
0
|
|
|
|
|
|
$title .= '_'.($t[5] + 1900).($t[4] + 1).$t[3].$t[2].$t[1]; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
$$o{output_handler}->(CGI::header(-type => 'application/json', -attachment => "$title.json")); |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my @selCols = @{ $o->get_usersel_cols() }; |
|
0
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my @buf = (); |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
while(my $rec = $o->fetch()) { |
24
|
0
|
|
|
|
|
|
push @buf, JSON::XS->new->utf8->encode($rec); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
$$o{output_handler}->('[' . join(',', @buf) . ']'); |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$o->finish(); |
30
|
0
|
|
|
|
|
|
return undef; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |