Bugzilla – Attachment 188832 Details for
Bug 39320
Create a 'landing page' for ERM
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39320: Preparation: ERM counts API endpoint
1efeb5a.patch (text/plain), 5.97 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-10-31 18:21:28 UTC
(
hide
)
Description:
Bug 39320: Preparation: ERM counts API endpoint
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-10-31 18:21:28 UTC
Size:
5.97 KB
patch
obsolete
>From 1efeb5ab940fc5eb5d00eda9abc814623a6aed36 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Wed, 26 Feb 2025 11:12:28 +0000 >Subject: [PATCH] Bug 39320: Preparation: ERM counts API endpoint >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Required for the follow-up ERMCounts widget > >Sponsored-by: UKHSA (UK Health Security Agency) > >Signed-off-by: Jeremy Evans <Jeremy.Evans@ukhsa.gov.uk> >Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> >--- > Koha/REST/V1/ERM.pm | 37 ++++++++++++++++++ > api/v1/swagger/definitions/erm_counts.yaml | 7 ++++ > api/v1/swagger/paths/erm_counts.yaml | 38 +++++++++++++++++++ > api/v1/swagger/swagger.yaml | 7 ++++ > .../prog/js/fetch/erm-api-client.js | 9 +++++ > 5 files changed, 98 insertions(+) > create mode 100644 api/v1/swagger/definitions/erm_counts.yaml > create mode 100644 api/v1/swagger/paths/erm_counts.yaml > >diff --git a/Koha/REST/V1/ERM.pm b/Koha/REST/V1/ERM.pm >index 1fe8911cb0a..168dc025815 100644 >--- a/Koha/REST/V1/ERM.pm >+++ b/Koha/REST/V1/ERM.pm >@@ -20,6 +20,12 @@ use Modern::Perl; > use Mojo::Base 'Mojolicious::Controller'; > > use Koha::Patrons; >+use Koha::ERM::Agreements; >+use Koha::ERM::Licenses; >+use Koha::ERM::Documents; >+use Koha::ERM::EHoldings::Titles; >+use Koha::ERM::EHoldings::Packages; >+use Koha::ERM::EUsage::UsageDataProviders; > > use Try::Tiny qw( catch try ); > >@@ -52,6 +58,37 @@ sub config { > ); > } > >+=head3 counts >+ >+Return the ERM resources counts >+ >+=cut >+ >+sub counts { >+ my $c = shift->openapi->valid_input or return; >+ >+ my $agreements_count = Koha::ERM::Agreements->search->count; >+ my $documents_count = Koha::ERM::Documents->search->count; >+ my $eholdings_packages_count = Koha::ERM::EHoldings::Packages->search->count; >+ my $eholdings_titles_count = Koha::ERM::EHoldings::Titles->search->count; >+ my $licenses_count = Koha::ERM::Licenses->search->count; >+ my $usage_data_providers_count = Koha::ERM::EUsage::UsageDataProviders->search->count; >+ >+ return $c->render( >+ status => 200, >+ openapi => { >+ counts => { >+ agreements_count => $agreements_count, >+ documents_count => $documents_count, >+ eholdings_packages_count => $eholdings_packages_count, >+ eholdings_titles_count => $eholdings_titles_count, >+ licenses_count => $licenses_count, >+ usage_data_providers_count => $usage_data_providers_count, >+ } >+ }, >+ ); >+} >+ > =head3 list_users > > Return the list of possible ERM users >diff --git a/api/v1/swagger/definitions/erm_counts.yaml b/api/v1/swagger/definitions/erm_counts.yaml >new file mode 100644 >index 00000000000..a47d7dd358c >--- /dev/null >+++ b/api/v1/swagger/definitions/erm_counts.yaml >@@ -0,0 +1,7 @@ >+--- >+type: object >+properties: >+ counts: >+ type: object >+ description: List of ERM resources counts >+additionalProperties: false >diff --git a/api/v1/swagger/paths/erm_counts.yaml b/api/v1/swagger/paths/erm_counts.yaml >new file mode 100644 >index 00000000000..dfb91605eed >--- /dev/null >+++ b/api/v1/swagger/paths/erm_counts.yaml >@@ -0,0 +1,38 @@ >+--- >+/erm/counts: >+ get: >+ x-mojo-to: ERM#counts >+ operationId: getERMcounts >+ description: This resource returns a list of ERM resources counts >+ summary: get the ERM counts >+ tags: >+ - erm_counts >+ produces: >+ - application/json >+ responses: >+ 200: >+ description: The ERM counts >+ schema: >+ $ref: "../swagger.yaml#/definitions/erm_counts" >+ 400: >+ description: Bad request >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ 403: >+ description: Access forbidden >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ 500: >+ description: | >+ Internal server error. Possible `error_code` attribute values: >+ >+ * `internal_server_error` >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ 503: >+ description: Under maintenance >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ x-koha-authorization: >+ permissions: >+ erm: 1 >diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml >index 14e41bd327f..4b8e21c402e 100644 >--- a/api/v1/swagger/swagger.yaml >+++ b/api/v1/swagger/swagger.yaml >@@ -50,6 +50,8 @@ definitions: > $ref: ./definitions/desk.yaml > edifact_file: > $ref: ./definitions/edifact_file.yaml >+ erm_counts: >+ $ref: ./definitions/erm_counts.yaml > erm_config: > $ref: ./definitions/erm_config.yaml > erm_agreement: >@@ -335,6 +337,8 @@ paths: > $ref: "./paths/deleted_biblios.yaml#/~1deleted~1biblios~1{biblio_id}" > /erm/config: > $ref: ./paths/erm_config.yaml#/~1erm~1config >+ /erm/counts: >+ $ref: ./paths/erm_counts.yaml#/~1erm~1counts > /erm/agreements: > $ref: ./paths/erm_agreements.yaml#/~1erm~1agreements > "/erm/agreements/{agreement_id}": >@@ -1204,6 +1208,9 @@ tags: > - description: "Manage ERM configuration\n" > name: erm_config > x-displayName: ERM configuration >+ - description: "Get ERM resources counts\n" >+ name: erm_counts >+ x-displayName: ERM counts > - description: "Manage ERM counter files\n" > name: erm_counter_files > x-displayName: ERM counter files >diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/erm-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/erm-api-client.js >index b618e0d672b..49e1bad5964 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/fetch/erm-api-client.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/erm-api-client.js >@@ -447,6 +447,15 @@ export class ERMAPIClient { > }), > }; > } >+ >+ get counts() { >+ return { >+ get: () => >+ this.httpClient.get({ >+ endpoint: "counts", >+ }), >+ }; >+ } > } > > export default ERMAPIClient; >-- >2.51.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 39320
:
187513
|
187514
|
187515
|
187516
|
187517
|
187518
|
187519
|
187520
|
187521
|
187522
|
187563
|
187568
|
187635
|
187636
|
187637
|
187638
|
187639
|
187640
|
187641
|
187642
|
187643
|
187644
|
187645
|
188094
|
188095
|
188096
|
188097
|
188098
|
188099
|
188100
|
188101
|
188102
|
188103
|
188104
|
188151
|
188279
|
188280
|
188281
|
188282
|
188283
|
188284
|
188285
|
188312
|
188315
|
188372
|
188375
|
188376
|
188637
|
188638
|
188639
|
188640
|
188641
|
188830
|
188831
| 188832 |
188833
|
188834
|
188835
|
188836
|
188837
|
188838
|
188839
|
188840
|
188841
|
188842
|
188843
|
188844
|
188845
|
188846
|
188847
|
188848
|
188849
|
188850
|
188851
|
188852
|
188853
|
188854
|
188855
|
188856
|
188857
|
188858
|
188859
|
188860
|
188861
|
188862
|
188863
|
188864