line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::OptimalQuery::JSON; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
587
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
3
|
no warnings qw( uninitialized ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
6
|
1
|
|
|
1
|
|
2
|
use base 'CGI::OptimalQuery::Base'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
52
|
|
7
|
1
|
|
|
1
|
|
3
|
use CGI(); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
8
|
1
|
|
|
1
|
|
3
|
use JSON::XS(); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
142
|
|
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::encode_json($rec); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
$$o{output_handler}->('[' . join(',', @buf) . ']'); |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$o->finish(); |
30
|
0
|
|
|
|
|
|
return undef; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |