Make Evergreen Perl modules installable via Module::Build to match OpenSRF
[working/Evergreen.git] / Open-ILS / src / perlmods / lib / 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'],
14         'call_number'  => [ 'count','count_dist','dewy','dewy_prefix','count_dist_dewey','count_dist_dewey_prefix','lower','upper','substr'],
15 };
16
17
18
19 our $dtype_xforms = {
20         'avg'           => { 
21                 'name'  => 'Average per group',
22                 'select'        => 'AVG(?COLNAME?)',
23                 'group' => 0 },
24         'stddev'        => {
25                 'label' => 'Standard Deviation per group',
26                 'select'        => 'STDDEV(?COLNAME?)',
27                 'group' => 0 },
28         'sum'           => {
29                 'label' => 'Sum per group',
30                 'select'        => 'SUM(?COLNAME?)',
31                 'group' => 0 }, 
32         'count'         => {    
33                 'label' => 'Count per group',
34                 'select'        => 'COUNT(?COLNAME?)',
35                 'group' => 0 },
36         'count_dist'            => {
37                 'label' => 'Distinct Count per group',
38                 'select'        => 'COUNT(DISTINCT ?COLNAME?)',
39                 'group' => 0 }, 
40         'count_dist_dewey'      => {
41                 'label' => 'Distinct Count of Dewey numbers per group',
42                 'select'        => 'COUNT(DISTINCT call_number_dewey(?COLNAME?))',
43                 'group' => 1 }, 
44         'count_dist_dewey_prefix'=> {
45                 'label' => 'Distinct Count of Dewey Number Prefixes per group',
46                 'select'        => 'COUNT(DISTINCT call_number_dewey(?COLNAME?,?PARAM?))',
47                 'param' => 1,           
48                 'group' => 1 }, 
49         'dewy_prefix'         => {    
50                 'label' => 'Extract Dewey number prefix from call number',
51                 'select'        => 'call_number_dewey(?COLNAME?,?PARAM?)',
52                 'param' => 1,           
53                 'group' => 1 },
54         'dewy'         => {    
55                 'label' => 'Extract Dewey number from call number',
56                 'select'        => 'call_number_dewey(?COLNAME?)',
57                 'group' => 1 },
58         'lower'         => {    
59                 'label' => 'Transform string to lower case',
60                 'select'        => 'LOWER(?COLNAME?)',
61                 'group' => 1 },
62         'upper'         => {
63                 'label' => 'Transform string to upper case',
64                 'select'        => 'UPPER(?COLNAME?)',
65                 'group' => 1 }, 
66         'substr'                => {
67                 'label' => 'Trim string length',
68                 'select'        => 'substr(?COLNAME?,1,?PARAM?)',
69                 'param' => 1,           
70                 'group' => 1 },                 
71         'age'           => {            
72                 'label' => 'Age as of runtime -- day granularity',
73                 'select'        => 'AGE(?COLNAME?::DATE)',
74                 'group' => 1 },
75         'dateformat'            => { # see http://www.postgresql.org/docs/8.0/interactive/functions-formatting.html
76                 'label' => 'Format date and time',
77                 'select'        => "TO_CHAR(?COLNAME?,'?PARAM?')",
78                 'param' => 1,           
79                 'group' => 1 },                 
80         'numformat'             => { # see http://www.postgresql.org/docs/8.0/interactive/functions-formatting.html
81                 'label' => 'Format Numeric data',
82                 'select'        => "TO_CHAR(?COLNAME?,'?PARAM?')",
83                 'param' => 1,                           
84                 'group' => 1 },                         
85 };                                      
86
87 ;