Revert "LP#1672346 - Copy Statistics View"
authorChris Sharp <csharp@georgialibraries.org>
Sun, 8 Oct 2017 02:56:39 +0000 (22:56 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Sun, 8 Oct 2017 02:56:39 +0000 (22:56 -0400)
This reverts commit f4bb098fcff54de26eb64610749096f5329e15fb.

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/reporter-schema.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.reporter_copy_statistics_view.sql [deleted file]

index ab32467..b493698 100644 (file)
@@ -9815,44 +9815,6 @@ SELECT  usr,
                        <link field="owning_lib" reltype="has_a" key="id" map="" class="aou"/>
                </links>
        </class>
-
-       <class id="rcsv" controller="open-ils.reporter-store" oils_obj:fieldmapper="reporter::copy_statistics_view" oils_persist:tablename="reporter.copy_statistics_view" reporter:label="Item Statistics View">
-               <fields oils_persist:primary="copy_id">
-                       <field reporter:label="Item ID" name="copy_id" reporter:datatype="link"/>
-                       <field reporter:label="Owning Library Link" name="owning_lib_id" reporter:datatype="link"/>
-                       <field reporter:label="Consortium: Last Circulation Date" name="consortium_last_circ_date" reporter:datatype="timestamp"/>
-                       <field reporter:label="System: Last Circulation Date" name="system_last_circ_date" reporter:datatype="timestamp"/>
-                       <field reporter:label="Branch: Last Circulation Date" name="branch_last_circ_date" reporter:datatype="timestamp"/>
-                       <field reporter:label="Consortium: Last Checkin Date" name="consortium_last_checkin_date" reporter:datatype="timestamp"/>
-                       <field reporter:label="System: Last Checkin Date" name="system_last_checkin_date" reporter:datatype="timestamp"/>
-                       <field reporter:label="Branch: Last Checkin Date" name="branch_last_checkin_date" reporter:datatype="timestamp"/>
-                       <field reporter:label="Consortium: Last Due Date" name="consortium_last_due_date" reporter:datatype="timestamp"/>
-                       <field reporter:label="System: Last Due Date" name="system_last_due_date" reporter:datatype="timestamp"/>
-                       <field reporter:label="Branch: Last Due Date" name="branch_last_due_date" reporter:datatype="timestamp"/>
-                       <field reporter:label="Consortium: Month-to-Date Circulation" name="consortium_month_to_date_circ" reporter:datatype="int"/>
-                       <field reporter:label="System: Month-to-Date Circulation" name="system_month_to_date_circ" reporter:datatype="int"/>
-                       <field reporter:label="Branch: Month-to-Date Circulation" name="branch_month_to_date_circ" reporter:datatype="int"/>
-                       <field reporter:label="Consortium: Year-to-Date Circulation" name="consortium_year_to_date_circ" reporter:datatype="int"/>
-                       <field reporter:label="System: Year-to-Date Circulation" name="system_year_to_date_circ" reporter:datatype="int"/>
-                       <field reporter:label="Branch: Year-to-Date Circulation" name="branch_year_to_date_circ" reporter:datatype="int"/>
-                       <field reporter:label="Consortium: Lifetime Circulation" name="consortium_lifetime_circ" reporter:datatype="int"/>
-                       <field reporter:label="System: Lifetime Circulation" name="system_lifetime_circ" reporter:datatype="int"/>
-                       <field reporter:label="Branch: Lifetime Circulation" name="branch_lifetime_circ" reporter:datatype="int"/>
-                       <field reporter:label="Consortium: Current Title Hold Count" name="consortium_current_title_hold_count" reporter:datatype="int"/>
-                       <field reporter:label="System: Current Title Hold Count" name="system_current_title_hold_count" reporter:datatype="int"/>
-                       <field reporter:label="Branch: Current Title Hold Count" name="branch_current_title_hold_count" reporter:datatype="int"/>
-                       <field reporter:label="Consortium: Lifetime Title Hold Count" name="consortium_lifetime_holds" reporter:datatype="int"/>
-                       <field reporter:label="System: Lifetime Title Hold Count" name="system_lifetime_holds" reporter:datatype="int"/>
-                       <field reporter:label="Branch: Lifetime Title Hold Count" name="branch_lifetime_holds" reporter:datatype="int"/>
-                       <field reporter:label="Consortium: Lifetime Transits" name="consortium_lifetime_transits" reporter:datatype="int"/>
-                       <field reporter:label="System: Lifetime Outbound Transits" name="system_lifetime_transits" reporter:datatype="int"/>
-                       <field reporter:label="Branch: Lifetime Outbound Transits" name="branch_lifetime_transits" reporter:datatype="int"/>
-               </fields>
-               <links>
-                       <link field="copy_id" reltype="has_a" key="id" map="" class="acp"/>
-                       <link field="owning_lib_id" reltype="has_a" key="id" map="" class="aou"/>
-               </links>
-       </class>
        <class id="acqdf" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::distribution_formula" oils_persist:tablename="acq.distribution_formula" reporter:label="Distribution Formula">
                <fields oils_persist:primary="id" oils_persist:sequence="acq.distribution_formula_id_seq">
                        <field reporter:label="Formula ID" name="id" reporter:datatype="id" reporter:selector="name" />
index 93c3ffe..28d9d44 100644 (file)
@@ -390,220 +390,5 @@ CREATE OR REPLACE VIEW reporter.currently_running AS
    JOIN actor.card c ON c.id = u.card
   WHERE s.start_time IS NOT NULL AND s.complete_time IS NULL;
 
-CREATE OR REPLACE VIEW reporter.copy_statistics_view AS
-SELECT    acp.id as copy_id,
-       owning_lib.id as owning_lib_id,
-    -- last circulation date in corsortium
-    (SELECT COALESCE(MAX(xact_start), NULL)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-    ) AS consortium_last_circ_date,
-    -- last circulation date in system
-    (SELECT COALESCE(MAX(xact_start), NULL)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-     AND circ_lib in (
-        SELECT id
-        FROM actor.org_unit
-        WHERE parent_ou = owning_lib.parent_ou
-        )
-    ) AS system_last_circ_date,
-    -- last circulation date in branch
-    (SELECT COALESCE(MAX(xact_start), NULL)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-     AND circ_lib = owning_lib.id
-    ) AS branch_last_circ_date,
-    -- last checkin date in corsortium
-    (SELECT COALESCE(MAX(checkin_time), NULL)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-    ) AS consortium_last_checkin_date,
-    -- last checkin date in system
-    (SELECT COALESCE(MAX(checkin_time), NULL)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-     AND circ_lib in ( 
-        SELECT id 
-        FROM actor.org_unit 
-        WHERE parent_ou = owning_lib.parent_ou
-        )
-    ) AS system_last_checkin_date,
-    -- last checkin date in branch
-    (SELECT COALESCE(MAX(checkin_time), NULL)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-     AND circ_lib = owning_lib.id
-    ) AS branch_last_checkin_date,
-    -- last due date in consortium
-    (SELECT COALESCE(MAX(due_date), NULL)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-    ) AS consortium_last_due_date,
-    -- last due date in system
-    (SELECT COALESCE(MAX(due_date), NULL)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-     AND circ_lib in ( 
-        SELECT id 
-        FROM actor.org_unit 
-        WHERE parent_ou = owning_lib.parent_ou
-        )
-    ) AS system_last_due_date,
-    -- last due date in branch
-    (SELECT COALESCE(MAX(due_date), NULL)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-     AND circ_lib = owning_lib.id
-    ) AS branch_last_due_date,
-    -- month-to-date circ in corsortium
-    (SELECT count(*)
-     FROM action.all_circulation
-     WHERE EXTRACT(YEAR FROM xact_start) = EXTRACT(YEAR FROM now())
-     AND EXTRACT(MONTH FROM xact_start) = EXTRACT(MONTH FROM now())
-     AND target_copy = acp.id
-    ) AS consortium_month_to_date_circ,
-    -- month-to-date circ in system
-    (SELECT count(*)
-     FROM action.all_circulation
-     WHERE EXTRACT(YEAR FROM xact_start) = EXTRACT(YEAR FROM now())
-     AND EXTRACT(MONTH FROM xact_start) = EXTRACT(MONTH FROM now())
-     AND target_copy = acp.id
-     AND circ_lib in ( 
-       SELECT id 
-       FROM actor.org_unit  
-       WHERE parent_ou = owning_lib.parent_ou
-       )
-    ) AS system_month_to_date_circ,
-    -- month-to-date circ in branch
-    (SELECT count(*)
-     FROM action.all_circulation
-     WHERE EXTRACT(YEAR FROM xact_start) = EXTRACT(YEAR FROM now())
-     AND EXTRACT(MONTH FROM xact_start) = EXTRACT(MONTH FROM now())
-     AND target_copy = acp.id
-     AND circ_lib = owning_lib.id
-    ) AS branch_month_to_date_circ,
-    -- year-to-date circ in consortium
-    (SELECT count(*)
-     FROM action.all_circulation
-     WHERE EXTRACT(YEAR FROM xact_start) = EXTRACT(YEAR FROM now())
-     AND target_copy = acp.id
-    ) AS consortium_year_to_date_circ,
-    -- year-to-date circ in system
-    (SELECT count(*)
-     FROM action.all_circulation
-     WHERE EXTRACT(YEAR FROM xact_start) = EXTRACT(YEAR FROM now())
-     AND target_copy = acp.id
-     AND circ_lib in ( 
-       SELECT id 
-       FROM actor.org_unit
-       WHERE parent_ou = owning_lib.parent_ou
-       )
-    ) AS system_year_to_date_circ,
-    -- year-to-date circ in branch
-    (SELECT count(*)
-     FROM action.all_circulation
-     WHERE EXTRACT(YEAR FROM xact_start) = EXTRACT(YEAR FROM now())
-     AND target_copy = acp.id
-     AND circ_lib = owning_lib.id
-    ) AS branch_year_to_date_circ,
-    -- lifetime circ in consortium
-    erfcc.circ_count AS consortium_lifetime_circ,
-    -- lifetime circ in system
-    (SELECT count(*)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-     AND circ_lib in (
-        SELECT id
-        FROM actor.org_unit
-        WHERE parent_ou = owning_lib.parent_ou
-        )
-    ) AS system_lifetime_circ,
-    -- lifetime circ in branch
-    (SELECT count(*)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-     AND circ_lib = owning_lib.id
-    ) AS branch_lifetime_circ,
-    -- current title hold count in consortium
-    (SELECT count(*)
-     FROM action.hold_request ahr
-     WHERE cancel_time IS NULL
-     AND expire_time > now()
-     AND fulfillment_time IS NULL
-     AND target = bre.id
-     AND hold_type = 'T'
-    ) AS consortium_current_title_hold_count,
-    -- current title hold count in system
-    (SELECT count(*)
-     FROM action.hold_request ahr
-     WHERE cancel_time IS NULL
-     AND expire_time > now()
-     AND fulfillment_time IS NULL
-     AND target = bre.id
-     AND hold_type = 'T'
-     AND pickup_lib IN (
-        SELECT id
-        FROM actor.org_unit
-        WHERE parent_ou = owning_lib.parent_ou
-        )
-    ) AS system_current_title_hold_count,
-    -- current title hold count in branch
-    (SELECT count(*)
-     FROM action.hold_request ahr
-     WHERE cancel_time IS NULL
-     AND expire_time > now()
-     AND fulfillment_time IS NULL
-     AND target = bre.id
-     AND hold_type = 'T'
-     AND pickup_lib = owning_lib.parent_ou
-    ) AS branch_current_title_hold_count,
-    -- consortium lifetime holds
-    (SELECT count(*)
-     FROM action.all_hold_request
-     WHERE current_copy = acp.id) AS consortium_lifetime_holds,
-    -- system lifetime holds
-    (SELECT count(*)
-     FROM action.all_hold_request
-     WHERE current_copy = acp.id
-     AND pickup_lib IN (
-        SELECT id
-        FROM actor.org_unit
-        WHERE parent_ou = owning_lib.parent_ou
-        )
-    ) AS system_lifetime_holds,
-    -- branch lifetime holds
-    (SELECT count(*)
-     FROM action.all_hold_request
-     WHERE current_copy = acp.id
-     AND pickup_lib = owning_lib.parent_ou
-    ) AS branch_lifetime_holds,
-    -- consortium lifetime transits
-    (SELECT count(*)
-     FROM action.transit_copy
-     WHERE target_copy = acp.id
-    ) AS consortium_lifetime_transits,
-    -- system lifetime transits
-    (SELECT count(*)
-     FROM action.transit_copy
-     WHERE target_copy = acp.id
-     AND source IN (
-        SELECT id
-        FROM actor.org_unit
-        WHERE parent_ou = owning_lib.parent_ou
-        )
-    ) AS system_lifetime_transits,
-    -- branch lifetime transits
-    (SELECT count(*)
-     FROM action.transit_copy
-     WHERE target_copy = acp.id
-     AND source = owning_lib.id
-    ) AS branch_lifetime_transits
-FROM    asset.copy acp
-    INNER JOIN asset.call_number acn ON (acp.call_number = acn.id)
-    INNER JOIN biblio.record_entry bre ON (acn.record = bre.id)
-    INNER JOIN actor.org_unit owning_lib ON (acn.owning_lib = owning_lib.id)
-    LEFT OUTER JOIN extend_reporter.full_circ_count erfcc ON (erfcc.id = acp.id);
-
 COMMIT;
 
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.reporter_copy_statistics_view.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.reporter_copy_statistics_view.sql
deleted file mode 100644 (file)
index a3e1d98..0000000
+++ /dev/null
@@ -1,218 +0,0 @@
-BEGIN;
-
-CREATE OR REPLACE VIEW reporter.copy_statistics_view AS
-SELECT    acp.id as copy_id,
-       owning_lib.id as owning_lib_id,
-    -- last circulation date in corsortium
-    (SELECT COALESCE(MAX(xact_start), NULL)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-    ) AS consortium_last_circ_date,
-    -- last circulation date in system
-    (SELECT COALESCE(MAX(xact_start), NULL)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-     AND circ_lib in (
-        SELECT id
-        FROM actor.org_unit
-        WHERE parent_ou = owning_lib.parent_ou
-        )
-    ) AS system_last_circ_date,
-    -- last circulation date in branch
-    (SELECT COALESCE(MAX(xact_start), NULL)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-     AND circ_lib = owning_lib.id
-    ) AS branch_last_circ_date,
-    -- last checkin date in corsortium
-    (SELECT COALESCE(MAX(checkin_time), NULL)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-    ) AS consortium_last_checkin_date,
-    -- last checkin date in system
-    (SELECT COALESCE(MAX(checkin_time), NULL)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-     AND circ_lib in ( 
-        SELECT id 
-        FROM actor.org_unit 
-        WHERE parent_ou = owning_lib.parent_ou
-        )
-    ) AS system_last_checkin_date,
-    -- last checkin date in branch
-    (SELECT COALESCE(MAX(checkin_time), NULL)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-     AND circ_lib = owning_lib.id
-    ) AS branch_last_checkin_date,
-    -- last due date in consortium
-    (SELECT COALESCE(MAX(due_date), NULL)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-    ) AS consortium_last_due_date,
-    -- last due date in system
-    (SELECT COALESCE(MAX(due_date), NULL)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-     AND circ_lib in ( 
-        SELECT id 
-        FROM actor.org_unit 
-        WHERE parent_ou = owning_lib.parent_ou
-        )
-    ) AS system_last_due_date,
-    -- last due date in branch
-    (SELECT COALESCE(MAX(due_date), NULL)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-     AND circ_lib = owning_lib.id
-    ) AS branch_last_due_date,
-    -- month-to-date circ in corsortium
-    (SELECT count(*)
-     FROM action.all_circulation
-     WHERE EXTRACT(YEAR FROM xact_start) = EXTRACT(YEAR FROM now())
-     AND EXTRACT(MONTH FROM xact_start) = EXTRACT(MONTH FROM now())
-     AND target_copy = acp.id
-    ) AS consortium_month_to_date_circ,
-    -- month-to-date circ in system
-    (SELECT count(*)
-     FROM action.all_circulation
-     WHERE EXTRACT(YEAR FROM xact_start) = EXTRACT(YEAR FROM now())
-     AND EXTRACT(MONTH FROM xact_start) = EXTRACT(MONTH FROM now())
-     AND target_copy = acp.id
-     AND circ_lib in ( 
-       SELECT id 
-       FROM actor.org_unit  
-       WHERE parent_ou = owning_lib.parent_ou
-       )
-    ) AS system_month_to_date_circ,
-    -- month-to-date circ in branch
-    (SELECT count(*)
-     FROM action.all_circulation
-     WHERE EXTRACT(YEAR FROM xact_start) = EXTRACT(YEAR FROM now())
-     AND EXTRACT(MONTH FROM xact_start) = EXTRACT(MONTH FROM now())
-     AND target_copy = acp.id
-     AND circ_lib = owning_lib.id
-    ) AS branch_month_to_date_circ,
-    -- year-to-date circ in consortium
-    (SELECT count(*)
-     FROM action.all_circulation
-     WHERE EXTRACT(YEAR FROM xact_start) = EXTRACT(YEAR FROM now())
-     AND target_copy = acp.id
-    ) AS consortium_year_to_date_circ,
-    -- year-to-date circ in system
-    (SELECT count(*)
-     FROM action.all_circulation
-     WHERE EXTRACT(YEAR FROM xact_start) = EXTRACT(YEAR FROM now())
-     AND target_copy = acp.id
-     AND circ_lib in ( 
-       SELECT id 
-       FROM actor.org_unit
-       WHERE parent_ou = owning_lib.parent_ou
-       )
-    ) AS system_year_to_date_circ,
-    -- year-to-date circ in branch
-    (SELECT count(*)
-     FROM action.all_circulation
-     WHERE EXTRACT(YEAR FROM xact_start) = EXTRACT(YEAR FROM now())
-     AND target_copy = acp.id
-     AND circ_lib = owning_lib.id
-    ) AS branch_year_to_date_circ,
-    -- lifetime circ in consortium
-    erfcc.circ_count AS consortium_lifetime_circ,
-    -- lifetime circ in system
-    (SELECT count(*)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-     AND circ_lib in (
-        SELECT id
-        FROM actor.org_unit
-        WHERE parent_ou = owning_lib.parent_ou
-        )
-    ) AS system_lifetime_circ,
-    -- lifetime circ in branch
-    (SELECT count(*)
-     FROM action.all_circulation
-     WHERE target_copy = acp.id
-     AND circ_lib = owning_lib.id
-    ) AS branch_lifetime_circ,
-    -- current title hold count in consortium
-    (SELECT count(*)
-     FROM action.hold_request ahr
-     WHERE cancel_time IS NULL
-     AND expire_time > now()
-     AND fulfillment_time IS NULL
-     AND target = bre.id
-     AND hold_type = 'T'
-    ) AS consortium_current_title_hold_count,
-    -- current title hold count in system
-    (SELECT count(*)
-     FROM action.hold_request ahr
-     WHERE cancel_time IS NULL
-     AND expire_time > now()
-     AND fulfillment_time IS NULL
-     AND target = bre.id
-     AND hold_type = 'T'
-     AND pickup_lib IN (
-        SELECT id
-        FROM actor.org_unit
-        WHERE parent_ou = owning_lib.parent_ou
-        )
-    ) AS system_current_title_hold_count,
-    -- current title hold count in branch
-    (SELECT count(*)
-     FROM action.hold_request ahr
-     WHERE cancel_time IS NULL
-     AND expire_time > now()
-     AND fulfillment_time IS NULL
-     AND target = bre.id
-     AND hold_type = 'T'
-     AND pickup_lib = owning_lib.parent_ou
-    ) AS branch_current_title_hold_count,
-    -- consortium lifetime holds
-    (SELECT count(*)
-     FROM action.all_hold_request
-     WHERE current_copy = acp.id) AS consortium_lifetime_holds,
-    -- system lifetime holds
-    (SELECT count(*)
-     FROM action.all_hold_request
-     WHERE current_copy = acp.id
-     AND pickup_lib IN (
-        SELECT id
-        FROM actor.org_unit
-        WHERE parent_ou = owning_lib.parent_ou
-        )
-    ) AS system_lifetime_holds,
-    -- branch lifetime holds
-    (SELECT count(*)
-     FROM action.all_hold_request
-     WHERE current_copy = acp.id
-     AND pickup_lib = owning_lib.parent_ou
-    ) AS branch_lifetime_holds,
-    -- consortium lifetime transits
-    (SELECT count(*)
-     FROM action.transit_copy
-     WHERE target_copy = acp.id
-    ) AS consortium_lifetime_transits,
-    -- system lifetime transits
-    (SELECT count(*)
-     FROM action.transit_copy
-     WHERE target_copy = acp.id
-     AND source IN (
-        SELECT id
-        FROM actor.org_unit
-        WHERE parent_ou = owning_lib.parent_ou
-        )
-    ) AS system_lifetime_transits,
-    -- branch lifetime transits
-    (SELECT count(*)
-     FROM action.transit_copy
-     WHERE target_copy = acp.id
-     AND source = owning_lib.id
-    ) AS branch_lifetime_transits
-FROM    asset.copy acp
-    INNER JOIN asset.call_number acn ON (acp.call_number = acn.id)
-    INNER JOIN biblio.record_entry bre ON (acn.record = bre.id)
-    INNER JOIN actor.org_unit owning_lib ON (acn.owning_lib = owning_lib.id)
-    LEFT OUTER JOIN extend_reporter.full_circ_count erfcc ON (erfcc.id = acp.id);
-
-COMMIT;