7 'name' => 'Average per group',
8 'select' => 'AVG(?COLNAME?)',
11 'label' => 'Standard Deviation per group',
12 'select' => 'STDDEV(?COLNAME?)',
15 'label' => 'Sum per group',
16 'select' => 'SUM(?COLNAME?)',
19 'label' => 'Count per group',
20 'select' => 'COUNT(?COLNAME?)',
23 'label' => 'Distinct Count per group',
24 'select' => 'COUNT(DISTINCT ?COLNAME?)',
27 'label' => 'Transform string to lower case',
28 'select' => 'LOWER(?COLNAME?)',
31 'label' => 'Transform string to upper case',
32 'select' => 'UPPER(?COLNAME?)',
35 'label' => 'Trim string length',
36 'select' => 'substr(?COLNAME?,1,?PARAM?)',
40 'label' => 'Age as of runtime -- day granularity',
41 'select' => 'AGE(?COLNAME?::DATE)',
43 'dateformat' => { # see http://www.postgresql.org/docs/8.0/interactive/functions-formatting.html
44 'label' => 'Format date and time',
45 'select' => 'TO_CHAR(?COLNAME?,?PARAM?)',
48 'numformat' => { # see http://www.postgresql.org/docs/8.0/interactive/functions-formatting.html
49 'label' => 'Format Numeric data',
50 'select' => 'TO_CHAR(?COLNAME?,?PARAM?)',
56 'int' => [ 'avg','stddev','sum','count','count_dist','numformat'],
57 'numeric' => [ 'avg','stddev','sum','count','count_dist','numformat'],
58 'float' => [ 'avg','stddev','sum','count','count_dist','numformat'],
59 'time' => [ 'count', 'dateformat'],
60 'date' => [ 'count', 'age','dateformat'],
61 'timestamp' => [ 'count', 'age','dateformat'],
62 'timestamptz' => [ 'count', 'age','dateformat'],
63 'text' => [ 'count','count_dist','lower','upper','substr'],
67 WRAPPER html/table width='100%' style='border-top: 1px solid black';
69 WRAPPER html/cell align="right" width="30%";
73 class.findvalue('label');
77 WRAPPER html/cell align="right";
78 %]<b>Description:</b>[%
81 class.findvalue('description');
84 IF class.findvalue('@fact-table') == 'true' AND CGI.param('create_stage2') != 1;
86 WRAPPER html/cell align="right";
90 IF CGI.param('detail');
91 %]<a href="?detail=0&id=[% fact_table %]">No Details</a>[%
93 %]<a href="?detail=1&id=[% fact_table %]">Details</a>[%
95 %]|<a href="?create_stage2=1&id=[% fact_table %]">New Report Template</a>[%
99 INCLUDE html/cell align="right" valign='top' content='<b>Report Templates:</b>';
101 q = 'select * from reporter.stage2 ' _
102 'where pub is true or owner = ' _ DBI.quote(user.id());
103 FOR r IN DBI.query(q);
105 href="stage2?id=" _ r.id
106 content=utils.JSON2perl(r.params).templatename;
113 INCLUDE class_detail IF CGI.param('detail') == 1;
123 FOR f IN class.findnodes('fields/field');
125 WRAPPER html/cell align="right";
126 f.findvalue('label');
130 IF f.findvalue('description');
131 f.findvalue('description');
134 f.findvalue('@name')%]::[%f.findvalue('@datatype') %])[%
147 INCLUDE class_fields;
149 IF class.findvalue('@fact-table') == 'true' AND nosub != 1;
151 WRAPPER html/cell align="right";
152 %]<b>Report Dimensions<br>and Attributes:</b>[%
155 incs = class.findnodes('links/link/@field');
158 link_xpath = '/reporter/tables/table[@id="' _ fact_table _'"]'_
159 '/links/link[@field="' _ dim.value() _ '"]/@table';
162 dim_table = config.findvalue(link_xpath);
164 dim_xpath = '/reporter/tables/table[@id="' _ dim_table _ '"]';
167 dim_def = config.findnodes(dim_xpath);
169 INCLUDE class_table class = dim_def;