LP#1549505: tweak percentage of time checked out calculation
authorGalen Charlton <gmc@esilibrary.com>
Fri, 11 Mar 2016 18:34:36 +0000 (13:34 -0500)
committerGalen Charlton <gmc@esilibrary.com>
Fri, 11 Mar 2016 18:34:36 +0000 (13:34 -0500)
This patch excludes lost, claims-returned, claims-never-checked-out,
long-overdue, and open max-fines loans from consideration.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.statisitcal-ratings.sql

index a03d64c..3f8570d 100644 (file)
@@ -906,7 +906,7 @@ BEGIN
                         EXTRACT(
                             EPOCH FROM
                             AGE(
-                                COALESCE(circ.checkin_time, NOW()),
+                                COALESCE(circ.checkin_time, circ.stop_fines_time, NOW()),
                                 circ.xact_start
                             )
                         )
@@ -914,7 +914,19 @@ BEGIN
               FROM  asset.copy cp
                     JOIN asset.call_number cn ON (cn.id = cp.call_number)
                     JOIN precalc_bib_list f ON (f.id = cn.record)
-                    LEFT JOIN action.all_circulation circ ON (circ.target_copy = cp.id)
+                    LEFT JOIN action.all_circulation circ ON (
+                        circ.target_copy = cp.id
+                        AND stop_fines NOT IN (
+                            'LOST',
+                            'LONGOVERDUE',
+                            'CLAIMSRETURNED',
+                            'LONGOVERDUE'
+                        )
+                        AND NOT (
+                            checkin_time IS NULL AND
+                            stop_fines = 'MAXFINES'
+                        )
+                    )
               WHERE cn.owning_lib = ANY (badge.orgs)
               GROUP BY 1,2,3
             ) x