add string aggregate transform to reporter module. String aggregate user/lew/reporter_string_agg_rebase
authorLlewellyn Marshall <llewellyn.marshall@ncdcr.gov>
Thu, 25 May 2023 18:16:08 +0000 (14:16 -0400)
committerLlewellyn Marshall <llewellyn.marshall@ncdcr.gov>
Fri, 26 May 2023 17:26:55 +0000 (13:26 -0400)
works on any data-type, converting it to a string before performing the
operation. Duplicate values and blanks are skipped.

signed-off-by: Llewellyn Marshall <llewellyn.marshall@ncdcr.gov>

Open-ILS/src/perlmods/lib/OpenILS/Reporter/SQLBuilder.pm
Open-ILS/src/templates/staff/reporter/share/report_strings.tt2
Open-ILS/web/js/dojo/openils/reports/nls/reports.js
Open-ILS/web/js/ui/default/staff/reporter/services/template.js
Open-ILS/web/reports/oils_rpt_tforms.js
Open-ILS/web/reports/xul/transforms.js
build/i18n/po/reports.js/en-CA.po
build/i18n/po/reports.js/en-GB.po
build/i18n/po/reports.js/reports.js.pot

index f805575..5a1f6d7 100644 (file)
@@ -888,6 +888,15 @@ sub toSQL {
 
 sub is_aggregate { return 1 }
 
+#-------------------------------------------------------------------------------------------------
+package OpenILS::Reporter::SQLBuilder::Column::Transform::string_agg;
+
+sub toSQL {
+    my $self = shift;
+    return 'STRING_AGG(DISTINCT nullif("' . $self->{_relation} . '"."' . $self->name . '"::text,\'\'),\',\')';
+}
+
+sub is_aggregate { return 1 }
 
 #-------------------------------------------------------------------------------------------------
 package OpenILS::Reporter::SQLBuilder::Column::Where;
index cc49019..ab8d94d 100644 (file)
@@ -82,6 +82,7 @@ s.TFORMS_LABEL_AGE = '[% l( "Age") %]';
 s.TFORMS_LABEL_MONTHS_AGO = '[% l( "Months ago") %]';
 s.TFORMS_LABEL_QUARTERS_AGO = '[% l( "Quarters ago") %]';
 s.TFORMS_LABEL_SUM = '[% l( "Sum") %]';
+s.TFORMS_LABEL_STRING_AGG = '[% l( "String Aggregate") %]';
 s.TFORMS_LABEL_AVERAGE = '[% l( "Average") %]';
 s.TFORMS_LABEL_ROUND = '[% l( "Round") %]';
 s.TFORMS_LABEL_INT = '[% l( "Drop trailing decimals") %]';
@@ -173,6 +174,7 @@ s.TRANSFORMS_AGE = '[% l( "Age") %]';
 s.TRANSFORMS_MONTHS_AGO = '[% l( "Months ago") %]';
 s.TRANSFORMS_QUARTERS_AGO = '[% l( "Quarters ago") %]';
 s.TRANSFORMS_SUM = '[% l( "Sum") %]';
+s.TRANSFORMS_STRING_AGG = '[% l( "String Aggregate") %]';
 s.TRANSFORMS_AVERAGE = '[% l( "Average") %]';
 s.TRANSFORMS_ROUND = '[% l( "Round") %]';
 s.TRANSFORMS_INT = '[% l( "Drop trailing decimals") %]';
index 17de210..efd86cb 100644 (file)
@@ -77,6 +77,7 @@
        "TFORMS_LABEL_MONTHS_AGO": "Months ago",
        "TFORMS_LABEL_QUARTERS_AGO": "Quarters ago",
        "TFORMS_LABEL_SUM": "Sum",
+       "TFORMS_LABEL_STRING_AGG": "String Aggregate",
        "TFORMS_LABEL_AVERAGE": "Average",
        "TFORMS_LABEL_ROUND": "Round",
        "TFORMS_LABEL_INT": "Drop trailing decimals",
        "TRANSFORMS_MONTHS_AGO": "Months ago",
        "TRANSFORMS_QUARTERS_AGO": "Quarters ago",
        "TRANSFORMS_SUM": "Sum",
+       "TRANSFORMS_STRING_AGG": "String Aggregate",
        "TRANSFORMS_AVERAGE": "Average",
        "TRANSFORMS_ROUND": "Round",
        "TRANSFORMS_INT": "Drop trailing decimals"
index 3908654..adc6dca 100644 (file)
@@ -162,7 +162,12 @@ function($uibModal , $q , egCore , egConfirmDialog , egAlertDialog) {
                 aggregate : true,
                 label : egCore.strings.TRANSFORMS_MAX
             },
-        
+            
+            string_agg : {
+                datatype :  OILS_RPT_DTYPE_NOT_BOOL,
+                label : egCore.strings.TRANSFORMS_STRING_AGG,
+                aggregate : true
+            },         
             /* string transforms ------------------------- */
         
             substring : {
index ff9da55..cf37b61 100644 (file)
@@ -35,6 +35,11 @@ var OILS_RPT_TRANSFORMS = {
                aggregate : true,
                label : rpt_strings.TFORMS_LABEL_MAX
        },
+    
+       string_agg : {
+               aggregate : true,
+               label : rpt_strings.TFORMS_STRING_AGG
+       },
 
        /* string transforms ------------------------- */
 
index 96b909d..7bcbda9 100644 (file)
@@ -74,6 +74,11 @@ var OILS_RPT_TRANSFORMS = {
                label : rpt_strings.TRANSFORMS_MAX
        },
 
+    string_agg : {
+        datatype :  OILS_RPT_DTYPE_NOT_BOOL,
+        label : rpt_strings.TRANSFORMS_STRING_AGG,
+        aggregate : true
+    }, 
        /* string transforms ------------------------- */
 
        substring : {
index 46d3669..2fb7d05 100644 (file)
@@ -436,6 +436,10 @@ msgstr "Hour of day"
 msgid "Max"
 msgstr "Max"
 
+#: reports.js:TFORMS_LABEL_STRING_AGG reports.js:TRANSFORMS_STRING_AGG
+msgid "String Aggregate"
+msgstr "String Aggregate"
+
 #: reports.js:TEMPLATE_CONF_NOT_IN reports.js:TEMPLATE_CONF_NO_MATCH
 msgid "Field does not match one of list (comma separated):"
 msgstr "Field does not match one of list (comma separated):"
index 5a0c70b..f0e4251 100644 (file)
@@ -441,6 +441,10 @@ msgstr "Hour of day"
 msgid "Max"
 msgstr "Max"
 
+#: reports.js:TFORMS_LABEL_STRING_AGG reports.js:TRANSFORMS_STRING_AGG
+msgid "String Aggregate"
+msgstr "String Aggregate"
+
 #: reports.js:TEMPLATE_CONF_NOT_IN reports.js:TEMPLATE_CONF_NO_MATCH
 msgid "Field does not match one of list (comma separated):"
 msgstr "Field does not match one of list (comma separated):"
index 77cee92..56253ca 100644 (file)
@@ -216,6 +216,10 @@ msgstr ""
 msgid "Max"
 msgstr ""
 
+#: reports.js:TFORMS_LABEL_STRING_AGG reports.js:TRANSFORMS_STRING_AGG
+msgid "String Aggregate"
+msgstr ""
+
 #: reports.js:TFORMS_LABEL_LOWER reports.js:TRANSFORMS_LOWER
 msgid "Lower case"
 msgstr ""