]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/perlmods/OpenILS/WWW/Reporter/transforms.pm
c34795e468f83739869fe5859dd8a70cf58d5628
[Evergreen.git] / Open-ILS / src / perlmods / OpenILS / WWW / Reporter / transforms.pm
1 #!/usr/bin/perl
2
3 package OpenILS::WWW::Reporter;
4
5 our $dtype_xform_map = {
6         'int'                   => [ 'avg','stddev','sum','count','count_dist','numformat'],
7         'numeric'       => [ 'avg','stddev','sum','count','count_dist','numformat'],
8         'float' => [ 'avg','stddev','sum','count','count_dist','numformat'],
9         'time'  => [ 'count', 'dateformat'],
10         'date'  => [ 'count', 'age','dateformat'],
11         'timestamp'     => [ 'count', 'age','dateformat'],
12         'timestamptz'   => [ 'count', 'age','dateformat'],
13         'text'  => [ 'count','count_dist','lower','upper','substr','dewy','dewy_prefix'],
14 };
15
16
17
18 our $dtype_xforms = {
19         'avg'           => { 
20                 'name'  => 'Average per group',
21                 'select'        => 'AVG(?COLNAME?)',
22                 'group' => 0 },
23         'stddev'        => {
24                 'label' => 'Standard Deviation per group',
25                 'select'        => 'STDDEV(?COLNAME?)',
26                 'group' => 0 },
27         'sum'           => {
28                 'label' => 'Sum per group',
29                 'select'        => 'SUM(?COLNAME?)',
30                 'group' => 0 }, 
31         'count'         => {    
32                 'label' => 'Count per group',
33                 'select'        => 'COUNT(?COLNAME?)',
34                 'group' => 0 },
35         'count_dist'            => {
36                 'label' => 'Distinct Count per group',
37                 'select'        => 'COUNT(DISTINCT ?COLNAME?)',
38                 'group' => 0 }, 
39         'dewy_prefix'         => {    
40                 'label' => 'Extract Dewey number prefix from call number',
41                 'select'        => 'call_number_dewey(?COLNAME?,?PARAM?)',
42                 'param' => 1,           
43                 'group' => 1 },
44         'dewy'         => {    
45                 'label' => 'Extract Dewey number from call number',
46                 'select'        => 'call_number_dewey(?COLNAME?)',
47                 'group' => 1 },
48         'lower'         => {    
49                 'label' => 'Transform string to lower case',
50                 'select'        => 'LOWER(?COLNAME?)',
51                 'group' => 1 },
52         'upper'         => {
53                 'label' => 'Transform string to upper case',
54                 'select'        => 'UPPER(?COLNAME?)',
55                 'group' => 1 }, 
56         'substr'                => {
57                 'label' => 'Trim string length',
58                 'select'        => 'substr(?COLNAME?,1,?PARAM?)',
59                 'param' => 1,           
60                 'group' => 1 },                 
61         'age'           => {            
62                 'label' => 'Age as of runtime -- day granularity',
63                 'select'        => 'AGE(?COLNAME?::DATE)',
64                 'group' => 1 },
65         'dateformat'            => { # see http://www.postgresql.org/docs/8.0/interactive/functions-formatting.html
66                 'label' => 'Format date and time',
67                 'select'        => "TO_CHAR(?COLNAME?,'?PARAM?')",
68                 'param' => 1,           
69                 'group' => 1 },                 
70         'numformat'             => { # see http://www.postgresql.org/docs/8.0/interactive/functions-formatting.html
71                 'label' => 'Format Numeric data',
72                 'select'        => "TO_CHAR(?COLNAME?,'?PARAM?')",
73                 'param' => 1,                           
74                 'group' => 1 },                         
75 };                                      
76
77 ;