Add "Last circulation date" field to new rcl view
authorDan Scott <dscott@laurentian.ca>
Tue, 20 Dec 2011 21:19:08 +0000 (16:19 -0500)
committerThomas Berezansky <tsbere@mvlc.org>
Tue, 20 Dec 2011 23:26:38 +0000 (18:26 -0500)
Some libraries will want the option of filtering out copies which have
truly never circulated, so offering up the bare "last circulation date"
field rather than coalescing it with "create date" will give report
writers the ability to use an IS NOT NULL clause.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Open-ILS/examples/fm_IDL.xml

index fd47489..7e0b301 100644 (file)
@@ -8733,19 +8733,21 @@ SELECT  usr,
                </permacrud>
        </class>
 
-       <class id="rlc" controller="open-ils.cstore open-ils.pcrud open-ils.reporter-store" oils_obj:fieldmapper="reporter::last_circ_date" oils_persist:readonly="true" reporter:label="Last Circulation Date">
+       <class id="rlc" controller="open-ils.cstore open-ils.pcrud open-ils.reporter-store" oils_obj:fieldmapper="reporter::last_circ_date" oils_persist:readonly="true" reporter:label="Last Circulation or Creation Date">
                <oils_persist:source_definition>
             SELECT
                 ac.id,
-                coalesce(max(actac.xact_start), ac.create_date) as last_circ_or_create
+                COALESCE(MAX(actac.xact_start), ac.create_date) AS last_circ_or_create,
+                MAX(actac.xact_start) AS last_circ
             FROM asset.copy ac
                  LEFT JOIN action.all_circulation actac ON ac.id = actac.target_copy
-            GROUP BY ac.id, ac.create_date
+            GROUP BY ac.id
 
             -- Alternate version, say if you have migrated last checkout information in extend_reporter.legacy_circ_timestamp:
             --SELECT
             --    ac.id,
-            --    greatest(max(actac.xact_start), erlct.last_cko_ts, ac.create_date) as last_circ
+            --    GREATEST(MAX(actac.xact_start), erlct.last_cko_ts, ac.create_date) AS last_circ_or_create,
+            --    GREATEST(MAX(actac.xact_start), erlct.last_cko_ts) AS last_circ
             --FROM asset.copy ac
             --     LEFT JOIN action.all_circulation actac ON ac.id = actac.target_copy
             --     LEFT JOIN extend_reporter.legacy_circ_timestamp erlct ON ac.id = erlct.id
@@ -8754,6 +8756,7 @@ SELECT  usr,
                <fields oils_persist:primary="id" oils_persist:sequence="biblio.record_entry">
                        <field reporter:label="Copy ID" name="id" reporter:datatype="link"/>
                        <field reporter:label="Last Circulation or Creation Date" name="last_circ_or_create" reporter:datatype="timestamp"/>
+                       <field reporter:label="Last Circulation Date" name="last_circ" reporter:datatype="timestamp"/>
                </fields>
                <links>
                        <link field="id" reltype="has_a" key="id" map="" class="acp"/>