From ec14da1675ef9a51453c3d43077b021eb3c3537e Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 16 May 2023 17:56:36 -0400 Subject: [PATCH] LP2019974 Open Non-Cataloged Circs View * Make open non-cataloged circs available as a cstore/pcrud-accessible DB view. * Migrate the public API to cstore retrieval * Migrate one of the browser client calls to pcrud * Minor code tidying Signed-off-by: Bill Erickson --- Open-ILS/examples/fm_IDL.xml | 26 ++++++++++++++++++++ .../src/app/staff/share/patron/patron.service.ts | 10 +++----- .../lib/OpenILS/Application/Circ/NonCat.pm | 28 ++++++++++++---------- Open-ILS/src/sql/Pg/090.schema.action.sql | 7 ++++++ .../sql/Pg/upgrade/XXXX.schema.non-cat-view.sql | 14 +++++++++++ 5 files changed, 65 insertions(+), 20 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.schema.non-cat-view.sql diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 949ed2b1c2..174d95e241 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -8515,6 +8515,32 @@ SELECT usr, + + + + + + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/share/patron/patron.service.ts b/Open-ILS/src/eg2/src/app/staff/share/patron/patron.service.ts index fbf075a7e9..bce516f4a1 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/patron/patron.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/patron/patron.service.ts @@ -296,14 +296,10 @@ export class PatronService { } return patronStats = stats; - }) - .then(_ => { - return this.net.request( - 'open-ils.circ', - 'open-ils.circ.open_non_cataloged_circulation.user.authoritative', - this.auth.token(), patron.id() - ).toPromise(); + }).then(_ => { + return this.pcrud.search('aoncc', + {patron: patron.id()}, {}, {idlist: true, atomic: true}).toPromise(); }).then(noncats => { if (noncats && patronStats) { diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm index 3105ddf605..fde9b50d1b 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm @@ -233,18 +233,20 @@ __PACKAGE__->register_method( ); sub fetch_open_noncats { - my( $self, $conn, $auth, $userid ) = @_; - my $e = new_editor( authtoken => $auth ); + my ($self, $conn, $auth, $user_id) = @_; + + my $e = new_editor(authtoken => $auth); return $e->event unless $e->checkauth; - $userid ||= $e->requestor->id; - if( $e->requestor->id ne $userid ) { - return $e->event unless $e->allowed('VIEW_CIRCULATIONS'); # XXX rely on editor perm + + $user_id ||= $e->requestor->id; + + if ($e->requestor->id ne $user_id) { + return $e->event unless $e->allowed('VIEW_CIRCULATIONS'); } - return $U->simplereq( - 'open-ils.storage', - 'open-ils.storage.action.open_non_cataloged_circulation.user', - $userid + return $e->search_action_open_non_cataloged_circulation( + {patron => $user_id}, + {idlist => 1} ); } @@ -271,14 +273,14 @@ sub fetch_open_noncats_batch { my $e = new_editor(authtoken => $auth); return $e->event unless $e->checkauth; + $user_id ||= $e->requestor->id; if ($e->requestor->id ne $user_id) { return $e->event unless $e->allowed('VIEW_CIRCULATIONS'); } - my $ids = $U->simplereq( - 'open-ils.storage', - 'open-ils.storage.action.open_non_cataloged_circulation.user', - $user_id + my $ids = $e->search_action_open_non_cataloged_circulation( + {patron => $user_id}, + {idlist => 1} ); for my $id (@$ids) { diff --git a/Open-ILS/src/sql/Pg/090.schema.action.sql b/Open-ILS/src/sql/Pg/090.schema.action.sql index 7ce47d3066..159c9c4921 100644 --- a/Open-ILS/src/sql/Pg/090.schema.action.sql +++ b/Open-ILS/src/sql/Pg/090.schema.action.sql @@ -54,6 +54,13 @@ CREATE TABLE action.non_cat_in_house_use ( CREATE INDEX non_cat_in_house_use_staff_idx ON action.non_cat_in_house_use ( staff ); CREATE INDEX non_cat_in_house_use_ws_idx ON action.non_cat_in_house_use ( workstation ); +CREATE OR REPLACE VIEW action.open_non_cataloged_circulation AS + SELECT ncc.* + FROM action.non_cataloged_circulation ncc + JOIN config.non_cataloged_type nct ON nct.id = ncc.item_type + WHERE ncc.circ_time + nct.circ_duration > CURRENT_TIMESTAMP +; + CREATE TABLE action.survey ( id SERIAL PRIMARY KEY, owner INT NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.non-cat-view.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.non-cat-view.sql new file mode 100644 index 0000000000..8915927b68 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.non-cat-view.sql @@ -0,0 +1,14 @@ +BEGIN; + +-- SELECT evergreen.upgrade_deps_block_check('TODO', :eg_version); + +CREATE OR REPLACE VIEW action.open_non_cataloged_circulation AS + SELECT ncc.* + FROM action.non_cataloged_circulation ncc + JOIN config.non_cataloged_type nct ON nct.id = ncc.item_type + WHERE ncc.circ_time + nct.circ_duration > CURRENT_TIMESTAMP +; + +COMMIT; + + -- 2.11.0