[open-ils-commits] [GIT] Evergreen ILS branch master updated. fc2dcdadb96da9d5b051703e9b65290025bac6f7

Evergreen Git git at git.evergreen-ils.org
Wed Aug 9 15:37:43 EDT 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  fc2dcdadb96da9d5b051703e9b65290025bac6f7 (commit)
       via  4105f8d3d4bc214104efa997bb5bd84bd13a6fb8 (commit)
       via  4a244416e1d5cc01104fb583c58b6a8d816cec95 (commit)
      from  2621af6377970470e347559d67f0da5de47aaa9f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit fc2dcdadb96da9d5b051703e9b65290025bac6f7
Author: Mike Rylander <mrylander at gmail.com>
Date:   Wed Aug 9 15:37:05 2017 -0400

    Stamping upgrade script for slim all-circs view
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 9dc75df..96e1170 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -90,7 +90,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1050', :eg_version); -- mmorgan/cesardv/gmcharlt
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1051', :eg_version); -- berick/miker
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.all-circs-slim.sql b/Open-ILS/src/sql/Pg/upgrade/1051.schema.all-circs-slim.sql
similarity index 98%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.schema.all-circs-slim.sql
rename to Open-ILS/src/sql/Pg/upgrade/1051.schema.all-circs-slim.sql
index 914044f..71c22f1 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.all-circs-slim.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/1051.schema.all-circs-slim.sql
@@ -1,6 +1,6 @@
 BEGIN;
 
--- SELECT evergreen.upgrade_deps_block_check('1XXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('1051', :eg_version);
 
 CREATE OR REPLACE VIEW action.all_circulation_slim AS
     SELECT * FROM action.circulation

commit 4105f8d3d4bc214104efa997bb5bd84bd13a6fb8
Author: Bill Erickson <berickxx at gmail.com>
Date:   Thu Jun 1 16:11:11 2017 -0400

    LP#1695007 Webstafff circ group summary display fix
    
    Repair display of the Total Circs, Last Renewed On, and Renewal
    Workstation fields in the web staff item summary Recent Circ History tab
    Most Recent Circ Group Display.
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/web/js/ui/default/staff/cat/item/app.js b/Open-ILS/web/js/ui/default/staff/cat/item/app.js
index dabc637..7bd717d 100644
--- a/Open-ILS/web/js/ui/default/staff/cat/item/app.js
+++ b/Open-ILS/web/js/ui/default/staff/cat/item/app.js
@@ -1476,7 +1476,7 @@ function($scope , $q , $location , $routeParams , $timeout , $window , egCore ,
                 'open-ils.circ.renewal_chain.retrieve_by_circ.summary',
                 egCore.auth.token(), $scope.circ.id()
             ).then(function(summary) {
-                $scope.circ_summary = summary.summary;
+                $scope.circ_summary = summary;
             });
 
             if (!loadPrev) return;

commit 4a244416e1d5cc01104fb583c58b6a8d816cec95
Author: Bill Erickson <berickxx at gmail.com>
Date:   Thu Jun 1 10:56:11 2017 -0400

    LP#1695007 All-circulations slim DB VIEW
    
    Adds a new view action.all_circulation_slim which collects all
    action.circulation and action.aged_circulation rows into a single set,
    without the added joins for copy and patron data imposed by the existing
    action.aged_circulation view.
    
    The new leaner view is now used by various other views and APIs in place
    of the all_circulation view:
    
    DB:  action.all_circ_chain()
    DB:  action.summarize_all_circ_chain()
    DB:  rating.percent_time_circulating()
    API: open-ils.circ.retrieve
    API: open-ils.circ.copy_checkout_history.retrieve
    API: open-ils.circ.copy_details.retrieve
    API: open-ils.circ.renewal_chain.retrieve_by_circ[.summary]
    API: open-ils.circ.prev_renewal_chain.retrieve_by_circ[.summary]
    
    To Test (webstaff style):
    
    [1] Open a copy in the web staff Item Status / Detail View interface
        that has live and aged circulations.
    [2] Open the Recent Circ History tab
    [3] Confirm relevent fields for both types of circs display as expected
        and that the Patron field for the aged circulation shows a value of
        <Aged Circulation>
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml
index cfcdd10..43aed7d 100644
--- a/Open-ILS/examples/fm_IDL.xml
+++ b/Open-ILS/examples/fm_IDL.xml
@@ -4244,6 +4244,80 @@ SELECT  usr,
 			</actions>
 		</permacrud>
 	</class>
+	<class id="aacs" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="action::all_circulation_slim" oils_persist:tablename="action.all_circulation_slim" reporter:core="true" reporter:label="Combined Aged and Active circulations" oils_persist:readonly="true">
+		<fields oils_persist:primary="id" oils_persist:sequence="money.billable_xact_id_seq">
+			<field reporter:label="Check In Library" name="checkin_lib" reporter:datatype="org_unit"/>
+			<field reporter:label="Check In Staff" name="checkin_staff" reporter:datatype="link"/>
+			<field reporter:label="Check In Date/Time" name="checkin_time" reporter:datatype="timestamp"/>
+			<field reporter:label="Circulating Library" name="circ_lib"  reporter:datatype="org_unit"/>
+			<field reporter:label="Circulating Staff" name="circ_staff" reporter:datatype="link"/>
+			<field reporter:label="Desk Renewal" name="desk_renewal" reporter:datatype="bool"/>
+			<field reporter:label="Due Date/Time" name="due_date" reporter:datatype="timestamp"/>
+			<field reporter:label="Circulation Duration" name="duration" reporter:datatype="interval"/>
+			<field reporter:label="Circ Duration Rule" name="duration_rule" reporter:datatype="link"/>
+			<field reporter:label="Fine Interval" name="fine_interval" reporter:datatype="interval"/>
+			<field reporter:label="Circ ID" name="id" reporter:datatype="id" />
+			<field reporter:label="Max Fine Amount" name="max_fine" reporter:datatype="money" />
+			<field reporter:label="Max Fine Rule" name="max_fine_rule" reporter:datatype="link"/>
+			<field reporter:label="OPAC Renewal" name="opac_renewal" reporter:datatype="bool"/>
+			<field reporter:label="Phone Renewal" name="phone_renewal" reporter:datatype="bool"/>
+			<field reporter:label="Recurring Fine Amount" name="recurring_fine" reporter:datatype="money" />
+			<field reporter:label="Recurring Fine Rule" name="recurring_fine_rule" reporter:datatype="link"/>
+			<field reporter:label="Remaining Renewals" name="renewal_remaining" reporter:datatype="int" />
+			<field reporter:label="Grace Period" name="grace_period" reporter:datatype="interval" />
+			<field reporter:label="Fine Stop Reason" name="stop_fines" reporter:datatype="text"/>
+			<field reporter:label="Fine Stop Date/Time" name="stop_fines_time" reporter:datatype="timestamp"/>
+			<field reporter:label="Circulating Item" name="target_copy" reporter:datatype="link"/>
+			<field reporter:label="Transaction Finish Date/Time" name="xact_finish" reporter:datatype="timestamp" />
+			<field reporter:label="Checkout Date/Time" name="xact_start" reporter:datatype="timestamp" />
+			<field reporter:label="Record Creation Date/Time" name="create_time" reporter:datatype="timestamp" />
+			<field reporter:label="Parent Circulation" name="parent_circ" reporter:datatype="link"/>
+			<field reporter:label="Checkin Scan Time" name="checkin_scan_time" reporter:datatype="timestamp"/>
+			<field reporter:label="Checkin Workstation" name="checkin_workstation" reporter:datatype="link"/>
+			<field reporter:label="Patron" name="usr" reporter:datatype="link"/>
+			<field reporter:label="Transaction Billings" name="billings" oils_persist:virtual="true" reporter:datatype="link"/>
+			<field reporter:label="Transaction Payments" name="payments" oils_persist:virtual="true" reporter:datatype="link"/>
+			<field reporter:label="Base Transaction" name="billable_transaction" oils_persist:virtual="true" reporter:datatype="link"/>
+			<field reporter:label="Workstation" name="workstation" reporter:datatype="link"/>
+			<field reporter:label="Circulation Type" name="circ_type" oils_persist:virtual="true" reporter:datatype="text"/>
+			<field reporter:label="Billing Totals" name="billing_total" oils_persist:virtual="true" reporter:datatype="money"/>
+			<field reporter:label="Payment Totals" name="payment_total" oils_persist:virtual="true" reporter:datatype="money"/>
+			<field reporter:label="Archived Patron Stat-Cat Entries" name="aaactsc_entries" oils_persist:virtual="true" reporter:datatype="link"/>
+			<field reporter:label="Archived Copy Stat-Cat Entries" name="aaasc_entries" oils_persist:virtual="true" reporter:datatype="link"/>
+			<field reporter:label="Linked Active Circulation" name="active_circ" oils_persist:virtual="true" reporter:datatype="link"/>
+			<field reporter:label="Linked Aged Circulation" name="aged_circ" oils_persist:virtual="true" reporter:datatype="link"/>
+		</fields>
+		<links>
+			<link field="billable_transaction" reltype="might_have" key="id" map="" class="mbt"/>
+			<link field="circ_staff" reltype="has_a" key="id" map="" class="au"/>
+			<link field="checkin_lib" reltype="has_a" key="id" map="" class="aou"/>
+			<link field="target_copy" reltype="has_a" key="id" map="" class="acp"/>
+			<link field="checkin_staff" reltype="has_a" key="id" map="" class="au"/>
+			<link field="circ_lib" reltype="has_a" key="id" map="" class="aou"/>
+			<link field="payments" reltype="has_many" key="xact" map="" class="mp"/>
+			<link field="billings" reltype="has_many" key="xact" map="" class="mb"/>
+			<link field="duration_rule" reltype="has_a" key="name" map="" class="crcd"/>
+			<link field="max_fine_rule" reltype="has_a" key="name" map="" class="crmf"/>
+			<link field="recurring_fine_rule" reltype="has_a" key="name" map="" class="crrf"/>
+			<link field="circ_type" reltype="might_have" key="id" map="" class="rcirct"/>
+			<link field="billing_total" reltype="might_have" key="xact" map="" class="rxbt"/>
+			<link field="payment_total" reltype="might_have" key="xact" map="" class="rxpt"/>
+			<link field="workstation" reltype="has_a" key="id" map="" class="aws"/>
+			<link field="checkin_workstation" reltype="has_a" key="id" map="" class="aws"/>
+			<link field="aaactsc_entries" reltype="has_many" key="xact" map="" class="aaactsc"/>
+			<link field="aaasc_entries" reltype="has_many" key="xact" map="" class="aaasc"/>
+			<link field="active_circ" reltype="might_have" key="id" map="" class="circ"/>
+			<link field="aged_circ" reltype="might_have" key="id" map="" class="acirc"/>
+			<link field="parent_circ" reltype="might_have" key="id" map="" class="acirc"/>
+			<link field="usr" reltype="has_a" key="id" map="" class="au"/>
+		</links>
+		<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+			<actions>
+				<retrieve permission="VIEW_CIRCULATIONS" context_field="circ_lib" />
+			</actions>
+		</permacrud>
+	</class>
+
 	<class id="combcirc" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="action::all_circulation" oils_persist:tablename="action.all_circulation" reporter:core="true" reporter:label="Combined Aged and Active Circulations" oils_persist:readonly="true">
 		<fields oils_persist:primary="id" oils_persist:sequence="money.billable_xact_id_seq">
 			<field reporter:label="Check In Library" name="checkin_lib" reporter:datatype="org_unit"/>
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
index 54230dc..280ecdd 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
@@ -55,7 +55,7 @@ __PACKAGE__->register_method(
         Retrieve a circ object by id
         @param authtoken Login session key
         @pararm circid The id of the circ object
-        @param all_circ Returns an action.all_circulation object instead
+        @param all_circ Returns an action.all_circulation_slim object instead
             of an action.circulation object to pick up aged circs.
     /
 );
@@ -65,7 +65,7 @@ sub retrieve_circ {
     my $e = new_editor(authtoken => $a);
     return $e->event unless $e->checkauth;
     my $method = $all_circ ?
-        'retrieve_action_all_circulation' :
+        'retrieve_action_all_circulation_slim' :
         'retrieve_action_circulation';
     my $circ = $e->$method($i) or return $e->event;
     if( $e->requestor->id ne ($circ->usr || '') ) {
@@ -794,9 +794,9 @@ sub view_circs {
         $count = 4 unless defined $count;
     }
 
-    return $e->search_action_all_circulation([
+    return $e->search_action_all_circulation_slim([
         {target_copy => $copyid}, 
-        {limit => $count, order_by => { combcirc => "xact_start DESC" }} 
+        {limit => $count, order_by => { aacs => "xact_start DESC" }} 
     ]);
 }
 
@@ -1155,12 +1155,12 @@ sub copy_details {
 
     # find the most recent circulation for the requested copy,
     # be it active, completed, or aged.
-    my $circ = $e->search_action_all_circulation([
+    my $circ = $e->search_action_all_circulation_slim([
         { target_copy => $copy_id },
         {
             flesh => 1,
             flesh_fields => {
-                combcirc => [
+                aacs => [
                     'workstation',
                     'checkin_workstation',
                     'duration_rule',
@@ -1168,7 +1168,7 @@ sub copy_details {
                     'recurring_fine_rule'
                 ],
             },
-            order_by => { combcirc => 'xact_start desc' },
+            order_by => { aacs => 'xact_start desc' },
             limit => 1
         }
     ])->[0];
@@ -1876,7 +1876,7 @@ sub retrieve_circ_chain {
         my $chain = $e->json_query({from => ['action.all_circ_chain', $circ_id]});
 
         for my $circ_info (@$chain) {
-            my $circ = Fieldmapper::action::all_circulation->new;
+            my $circ = Fieldmapper::action::all_circulation_slim->new;
             $circ->$_($circ_info->{$_}) for keys %$circ_info;
             $conn->respond($circ);
         }
@@ -1924,18 +1924,18 @@ sub retrieve_prev_circ_chain {
     my $first_circ = 
         $e->json_query({from => ['action.all_circ_chain', $circ_id]})->[0];
 
-    my $prev_circ = $e->search_action_all_circulation([
+    my $prev_circ = $e->search_action_all_circulation_slim([
         {   target_copy => $first_circ->{target_copy},
             xact_start => {'<' => $first_circ->{xact_start}}
         }, {   
             flesh => 1,
             flesh_fields => {
-                combcirc => [
+                aacs => [
                     'active_circ',
                     'aged_circ'
                 ]
             },
-            order_by => { combcirc => 'xact_start desc' },
+            order_by => { aacs => 'xact_start desc' },
             limit => 1 
         }
     ])->[0];
@@ -1963,7 +1963,7 @@ sub retrieve_prev_circ_chain {
         {from => ['action.all_circ_chain', $prev_circ->id]});
 
     for my $circ_info (@$chain) {
-        my $circ = Fieldmapper::action::all_circulation->new;
+        my $circ = Fieldmapper::action::all_circulation_slim->new;
         $circ->$_($circ_info->{$_}) for keys %$circ_info;
         $conn->respond($circ);
     }
diff --git a/Open-ILS/src/sql/Pg/090.schema.action.sql b/Open-ILS/src/sql/Pg/090.schema.action.sql
index 11ee4c3..3de949e 100644
--- a/Open-ILS/src/sql/Pg/090.schema.action.sql
+++ b/Open-ILS/src/sql/Pg/090.schema.action.sql
@@ -258,6 +258,47 @@ CREATE OR REPLACE VIEW action.all_circulation AS
         LEFT JOIN actor.usr_address a ON (p.mailing_address = a.id)
         LEFT JOIN actor.usr_address b ON (p.billing_address = b.id);
 
+CREATE OR REPLACE VIEW action.all_circulation_slim AS
+    SELECT * FROM action.circulation
+UNION ALL
+    SELECT
+        id,
+        NULL AS usr,
+        xact_start,
+        xact_finish,
+        unrecovered,
+        target_copy,
+        circ_lib,
+        circ_staff,
+        checkin_staff,
+        checkin_lib,
+        renewal_remaining,
+        grace_period,
+        due_date,
+        stop_fines_time,
+        checkin_time,
+        create_time,
+        duration,
+        fine_interval,
+        recurring_fine,
+        max_fine,
+        phone_renewal,
+        desk_renewal,
+        opac_renewal,
+        duration_rule,
+        recurring_fine_rule,
+        max_fine_rule,
+        stop_fines,
+        workstation,
+        checkin_workstation,
+        copy_location,
+        checkin_scan_time,
+        parent_circ
+    FROM action.aged_circulation
+;
+
+
+
 CREATE OR REPLACE FUNCTION action.age_circ_on_delete () RETURNS TRIGGER AS $$
 DECLARE
 found char := 'N';
@@ -896,13 +937,13 @@ $$ LANGUAGE 'plpgsql';
 -- same as action.circ_chain, but returns action.all_circulation 
 -- rows which may include aged circulations.
 CREATE OR REPLACE FUNCTION action.all_circ_chain (ctx_circ_id INTEGER) 
-    RETURNS SETOF action.all_circulation AS $$
+    RETURNS SETOF action.all_circulation_slim AS $$
 DECLARE
-    tmp_circ action.all_circulation%ROWTYPE;
-    circ_0 action.all_circulation%ROWTYPE;
+    tmp_circ action.all_circulation_slim%ROWTYPE;
+    circ_0 action.all_circulation_slim%ROWTYPE;
 BEGIN
 
-    SELECT INTO tmp_circ * FROM action.all_circulation WHERE id = ctx_circ_id;
+    SELECT INTO tmp_circ * FROM action.all_circulation_slim WHERE id = ctx_circ_id;
 
     IF tmp_circ IS NULL THEN
         RETURN NEXT tmp_circ;
@@ -911,7 +952,7 @@ BEGIN
 
     -- find the front of the chain
     WHILE TRUE LOOP
-        SELECT INTO tmp_circ * FROM action.all_circulation 
+        SELECT INTO tmp_circ * FROM action.all_circulation_slim 
             WHERE id = tmp_circ.parent_circ;
         IF tmp_circ IS NULL THEN
             EXIT;
@@ -926,7 +967,7 @@ BEGIN
             EXIT;
         END IF;
         RETURN NEXT tmp_circ;
-        SELECT INTO tmp_circ * FROM action.all_circulation 
+        SELECT INTO tmp_circ * FROM action.all_circulation_slim 
             WHERE parent_circ = tmp_circ.id;
     END LOOP;
 
@@ -941,14 +982,14 @@ CREATE OR REPLACE FUNCTION action.summarize_all_circ_chain
 DECLARE
 
     -- first circ in the chain
-    circ_0 action.all_circulation%ROWTYPE;
+    circ_0 action.all_circulation_slim%ROWTYPE;
 
     -- last circ in the chain
-    circ_n action.all_circulation%ROWTYPE;
+    circ_n action.all_circulation_slim%ROWTYPE;
 
     -- circ chain under construction
     chain action.circ_chain_summary;
-    tmp_circ action.all_circulation%ROWTYPE;
+    tmp_circ action.all_circulation_slim%ROWTYPE;
 
 BEGIN
     
@@ -981,7 +1022,6 @@ BEGIN
 END;
 $$ LANGUAGE 'plpgsql';
 
-
 CREATE OR REPLACE FUNCTION action.usr_visible_holds (usr_id INT) RETURNS SETOF action.hold_request AS $func$
 DECLARE
     h               action.hold_request%ROWTYPE;
diff --git a/Open-ILS/src/sql/Pg/220.schema.rating.sql b/Open-ILS/src/sql/Pg/220.schema.rating.sql
index 3494a7b..8fed4cd 100644
--- a/Open-ILS/src/sql/Pg/220.schema.rating.sql
+++ b/Open-ILS/src/sql/Pg/220.schema.rating.sql
@@ -835,7 +835,7 @@ BEGIN
               FROM  asset.copy cp
                     JOIN precalc_copy_filter_bib_list c ON (cp.id = c.copy)
                     JOIN asset.call_number cn ON (cn.id = cp.call_number)
-                    LEFT JOIN action.all_circulation circ ON (
+                    LEFT JOIN action.all_circulation_slim circ ON (
                         circ.target_copy = cp.id
                         AND stop_fines NOT IN (
                             'LOST',
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.all-circs-slim.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.all-circs-slim.sql
new file mode 100644
index 0000000..914044f
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.all-circs-slim.sql
@@ -0,0 +1,193 @@
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('1XXX', :eg_version);
+
+CREATE OR REPLACE VIEW action.all_circulation_slim AS
+    SELECT * FROM action.circulation
+UNION ALL
+    SELECT
+        id,
+        NULL AS usr,
+        xact_start,
+        xact_finish,
+        unrecovered,
+        target_copy,
+        circ_lib,
+        circ_staff,
+        checkin_staff,
+        checkin_lib,
+        renewal_remaining,
+        grace_period,
+        due_date,
+        stop_fines_time,
+        checkin_time,
+        create_time,
+        duration,
+        fine_interval,
+        recurring_fine,
+        max_fine,
+        phone_renewal,
+        desk_renewal,
+        opac_renewal,
+        duration_rule,
+        recurring_fine_rule,
+        max_fine_rule,
+        stop_fines,
+        workstation,
+        checkin_workstation,
+        copy_location,
+        checkin_scan_time,
+        parent_circ
+    FROM action.aged_circulation
+;
+
+DROP FUNCTION action.summarize_all_circ_chain(INTEGER);
+DROP FUNCTION action.all_circ_chain(INTEGER);
+
+CREATE OR REPLACE FUNCTION action.all_circ_chain (ctx_circ_id INTEGER) 
+    RETURNS SETOF action.all_circulation_slim AS $$
+DECLARE
+    tmp_circ action.all_circulation_slim%ROWTYPE;
+    circ_0 action.all_circulation_slim%ROWTYPE;
+BEGIN
+
+    SELECT INTO tmp_circ * FROM action.all_circulation_slim WHERE id = ctx_circ_id;
+
+    IF tmp_circ IS NULL THEN
+        RETURN NEXT tmp_circ;
+    END IF;
+    circ_0 := tmp_circ;
+
+    -- find the front of the chain
+    WHILE TRUE LOOP
+        SELECT INTO tmp_circ * FROM action.all_circulation_slim 
+            WHERE id = tmp_circ.parent_circ;
+        IF tmp_circ IS NULL THEN
+            EXIT;
+        END IF;
+        circ_0 := tmp_circ;
+    END LOOP;
+
+    -- now send the circs to the caller, oldest to newest
+    tmp_circ := circ_0;
+    WHILE TRUE LOOP
+        IF tmp_circ IS NULL THEN
+            EXIT;
+        END IF;
+        RETURN NEXT tmp_circ;
+        SELECT INTO tmp_circ * FROM action.all_circulation_slim 
+            WHERE parent_circ = tmp_circ.id;
+    END LOOP;
+
+END;
+$$ LANGUAGE 'plpgsql';
+
+CREATE OR REPLACE FUNCTION action.summarize_all_circ_chain 
+    (ctx_circ_id INTEGER) RETURNS action.circ_chain_summary AS $$
+
+DECLARE
+
+    -- first circ in the chain
+    circ_0 action.all_circulation_slim%ROWTYPE;
+
+    -- last circ in the chain
+    circ_n action.all_circulation_slim%ROWTYPE;
+
+    -- circ chain under construction
+    chain action.circ_chain_summary;
+    tmp_circ action.all_circulation_slim%ROWTYPE;
+
+BEGIN
+    
+    chain.num_circs := 0;
+    FOR tmp_circ IN SELECT * FROM action.all_circ_chain(ctx_circ_id) LOOP
+
+        IF chain.num_circs = 0 THEN
+            circ_0 := tmp_circ;
+        END IF;
+
+        chain.num_circs := chain.num_circs + 1;
+        circ_n := tmp_circ;
+    END LOOP;
+
+    chain.start_time := circ_0.xact_start;
+    chain.last_stop_fines := circ_n.stop_fines;
+    chain.last_stop_fines_time := circ_n.stop_fines_time;
+    chain.last_checkin_time := circ_n.checkin_time;
+    chain.last_checkin_scan_time := circ_n.checkin_scan_time;
+    SELECT INTO chain.checkout_workstation name FROM actor.workstation WHERE id = circ_0.workstation;
+    SELECT INTO chain.last_checkin_workstation name FROM actor.workstation WHERE id = circ_n.checkin_workstation;
+
+    IF chain.num_circs > 1 THEN
+        chain.last_renewal_time := circ_n.xact_start;
+        SELECT INTO chain.last_renewal_workstation name FROM actor.workstation WHERE id = circ_n.workstation;
+    END IF;
+
+    RETURN chain;
+
+END;
+$$ LANGUAGE 'plpgsql';
+
+CREATE OR REPLACE FUNCTION rating.percent_time_circulating(badge_id INT)
+    RETURNS TABLE (record BIGINT, value NUMERIC) AS $f$
+DECLARE
+    badge   rating.badge_with_orgs%ROWTYPE;
+BEGIN
+
+    SELECT * INTO badge FROM rating.badge_with_orgs WHERE id = badge_id;
+
+    PERFORM rating.precalc_bibs_by_copy(badge_id);
+
+    DELETE FROM precalc_copy_filter_bib_list WHERE id NOT IN (
+        SELECT id FROM precalc_filter_bib_list
+            INTERSECT
+        SELECT id FROM precalc_bibs_by_copy_list
+    );
+
+    ANALYZE precalc_copy_filter_bib_list;
+
+    RETURN QUERY
+     SELECT bib,
+            SUM(COALESCE(circ_time,0))::NUMERIC / SUM(age)::NUMERIC
+      FROM  (SELECT cn.record AS bib,
+                    cp.id,
+                    EXTRACT( EPOCH FROM AGE(cp.active_date) ) + 1 AS age,
+                    SUM(  -- time copy spent circulating
+                        EXTRACT(
+                            EPOCH FROM
+                            AGE(
+                                COALESCE(circ.checkin_time, circ.stop_fines_time, NOW()),
+                                circ.xact_start
+                            )
+                        )
+                    )::NUMERIC AS circ_time
+              FROM  asset.copy cp
+                    JOIN precalc_copy_filter_bib_list c ON (cp.id = c.copy)
+                    JOIN asset.call_number cn ON (cn.id = cp.call_number)
+                    LEFT JOIN action.all_circulation_slim 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)
+                    AND cp.active_date IS NOT NULL
+                    -- Next line requires that copies with no circs (circ.id IS NULL) also not be deleted
+                    AND ((circ.id IS NULL AND NOT cp.deleted) OR circ.id IS NOT NULL)
+              GROUP BY 1,2,3
+            ) x
+      GROUP BY 1;
+END;
+$f$ LANGUAGE PLPGSQL STRICT;
+
+
+-- ROLLBACK;
+COMMIT;
+
diff --git a/Open-ILS/web/js/ui/default/staff/cat/item/app.js b/Open-ILS/web/js/ui/default/staff/cat/item/app.js
index 865a842..dabc637 100644
--- a/Open-ILS/web/js/ui/default/staff/cat/item/app.js
+++ b/Open-ILS/web/js/ui/default/staff/cat/item/app.js
@@ -89,7 +89,7 @@ function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog
         limit :  1
     }
 
-    //Retrieve separate copy, combcirc, and accs information
+    //Retrieve separate copy, aacs, and accs information
     service.getCopy = function(barcode, id) {
         if (barcode) return egCore.pcrud.search(
             'acp', {barcode : barcode, deleted : 'f'},
@@ -99,7 +99,7 @@ function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog
             .then(function(copy) {return copy});
     }
     service.getCirc = function(id) {
-        return egCore.pcrud.search('combcirc', { target_copy : id },
+        return egCore.pcrud.search('aacs', { target_copy : id },
             service.circFlesh).then(function(circ) {return circ});
     }
     service.getSummary = function(id) {
@@ -1556,11 +1556,11 @@ function($scope , $q , $location , $routeParams , $timeout , $window , egCore ,
 
         }).then(function(count) {
 
-            egCore.pcrud.search('combcirc', 
+            egCore.pcrud.search('aacs', 
                 {target_copy : copyId},
                 {   flesh : 2,
                     flesh_fields : {
-                        combcirc : [
+                        aacs : [
                             'usr',
                             'workstation',                                         
                             'checkin_workstation',                                 
@@ -1568,7 +1568,7 @@ function($scope , $q , $location , $routeParams , $timeout , $window , egCore ,
                         ],
                         au : ['card']
                     },
-                    order_by : {combcirc : 'xact_start desc'}, 
+                    order_by : {aacs : 'xact_start desc'}, 
                     limit :  count
                 }
 

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/examples/fm_IDL.xml                       |   74 ++++++++
 .../src/perlmods/lib/OpenILS/Application/Circ.pm   |   24 ++--
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/090.schema.action.sql          |   60 +++++-
 Open-ILS/src/sql/Pg/220.schema.rating.sql          |    2 +-
 .../sql/Pg/upgrade/1051.schema.all-circs-slim.sql  |  193 ++++++++++++++++++++
 Open-ILS/web/js/ui/default/staff/cat/item/app.js   |   12 +-
 7 files changed, 337 insertions(+), 30 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/1051.schema.all-circs-slim.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list