Bugzilla – Attachment 148654 Details for
Bug 32807
No need to fetch all if we need to know if one exist
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32807: Fetch count instead of all entries for agreements and licenses
Bug-32807-Fetch-count-instead-of-all-entries-for-a.patch (text/plain), 8.41 KB, created by
Kyle M Hall (khall)
on 2023-03-24 11:04:29 UTC
(
hide
)
Description:
Bug 32807: Fetch count instead of all entries for agreements and licenses
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2023-03-24 11:04:29 UTC
Size:
8.41 KB
patch
obsolete
>From 95a2333a97bfea83e47c2cc2d52ca74269ce10e4 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 22 Feb 2023 08:48:48 +0100 >Subject: [PATCH] Bug 32807: Fetch count instead of all entries for agreements > and licenses > >To list agreements and licenses we are retrieving the whole list to >simply know if at least one exists (and display the table that will >fetch the X first elements to display). > >We should call count instead. > >Test plan: >List agreements and licenses. >If none exists, the table is not displayed but a "There are no... >defined" message instead. >If at least one exists the table must be there > >Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > .../js/vue/components/ERM/AgreementsList.vue | 20 +++++++++--------- > .../ERM/EHoldingsLocalPackagesList.vue | 2 +- > .../ERM/EHoldingsLocalTitlesList.vue | 2 +- > .../js/vue/components/ERM/LicensesList.vue | 16 +++++++------- > .../prog/js/vue/fetch/erm-api-client.js | 21 ++++++++++++++++++- > 5 files changed, 40 insertions(+), 21 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue >index e14b1142498..51e63a9eb0a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue >@@ -1,8 +1,8 @@ > <template> > <div v-if="!initialized">{{ $__("Loading") }}</div> >- <div v-else-if="agreements" id="agreements_list"> >+ <div v-else-if="agreement_count" id="agreements_list"> > <Toolbar v-if="before_route_entered" /> >- <fieldset v-if="agreements.length" class="filters"> >+ <fieldset v-if="agreement_count > 0" class="filters"> > <label for="expired_filter">{{ $__("Filter by expired") }}:</label> > <input > type="checkbox" >@@ -32,7 +32,7 @@ > :value="$__('Filter')" > /> > </fieldset> >- <div v-if="agreements.length" class="page-section"> >+ <div v-if="agreement_count > 0" class="page-section"> > <table :id="table_id"></table> > </div> > <div v-else-if="initialized" class="dialog message"> >@@ -75,7 +75,7 @@ export default { > data: function () { > return { > fp_config: flatpickr_defaults, >- agreements: [], >+ agreement_count: null, > initialized: false, > filters: { > by_expired: this.$route.query.by_expired || false, >@@ -92,7 +92,7 @@ export default { > vm.before_route_entered = true // FIXME This is ugly, but we need to distinguish when it's used as main component or child component (from EHoldingsEBSCOPAckagesShow for instance) > if (!vm.building_table) { > vm.building_table = true >- vm.getAgreements().then(() => vm.build_datatable()) >+ vm.getAgreementCount().then(() => vm.build_datatable()) > } > }) > }, >@@ -106,11 +106,11 @@ export default { > }, > }, > methods: { >- async getAgreements() { >+ async getAgreementCount() { > const client = APIClient.erm >- await client.agreements.getAll().then( >- agreements => { >- this.agreements = agreements >+ await client.agreements.count().then( >+ count => { >+ this.agreement_count = count > this.initialized = true > }, > error => {} >@@ -481,7 +481,7 @@ export default { > mounted() { > if (!this.building_table) { > this.building_table = true >- this.getAgreements().then(() => this.build_datatable()) >+ this.getAgreementCount().then(() => this.build_datatable()) > } > }, > components: { flatPickr, Toolbar }, >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesList.vue >index 9fd12f73236..51967120c38 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesList.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesList.vue >@@ -48,7 +48,7 @@ export default { > }, > data: function () { > return { >- package_count: [], >+ package_count: null, > initialized: false, > filters: { > package_name: this.$route.query.package_name || "", >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesList.vue >index d9cec18f56f..598d54b4341 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesList.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesList.vue >@@ -46,7 +46,7 @@ export default { > }, > data: function () { > return { >- title_count: undefined, >+ title_count: null, > initialized: false, > filters: { > publication_title: this.$route.query.publication_title || "", >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesList.vue >index b42355685c7..1ff7243a544 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesList.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesList.vue >@@ -1,8 +1,8 @@ > <template> > <div v-if="!initialized">{{ $__("Loading") }}</div> >- <div v-else-if="licenses" id="licenses_list"> >+ <div v-else-if="license_count" id="licenses_list"> > <Toolbar /> >- <div v-if="licenses.length" class="page-section"> >+ <div v-if="license_count > 0" class="page-section"> > <table :id="table_id"></table> > </div> > <div v-else-if="initialized" class="dialog message"> >@@ -42,21 +42,21 @@ export default { > }, > data: function () { > return { >- licenses: [], >+ license_count: null, > initialized: false, > } > }, > beforeRouteEnter(to, from, next) { > next(vm => { >- vm.getLicenses().then(() => vm.build_datatable()) >+ vm.getLicenseCount().then(() => vm.build_datatable()) > }) > }, > methods: { >- async getLicenses() { >+ async getLicenseCount() { > const client = APIClient.erm >- await client.licenses.getAll().then( >- licenses => { >- this.licenses = licenses >+ await client.licenses.count().then( >+ count => { >+ this.license_count = count > this.initialized = true > }, > error => {} >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js >index 8dbd9e5453a..5cf28a9d397 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js >@@ -35,7 +35,16 @@ export class ERMAPIClient extends HttpClient { > endpoint: "agreements/" + id, > body: agreement, > }), >- //count: () => this.count("agreements"), //TODO: Implement count method >+ count: (query = {}) => >+ this.count({ >+ endpoint: >+ "agreements?" + >+ new URLSearchParams({ >+ _page: 1, >+ _per_page: 1, >+ ...(query && { q: JSON.stringify(query) }), >+ }), >+ }), > }; > } > >@@ -70,6 +79,16 @@ export class ERMAPIClient extends HttpClient { > endpoint: "licenses/" + id, > body: license, > }), >+ count: (query = {}) => >+ this.count({ >+ endpoint: >+ "licenses?" + >+ new URLSearchParams({ >+ _page: 1, >+ _per_page: 1, >+ ...(query && { q: JSON.stringify(query) }), >+ }), >+ }), > }; > } > >-- >2.30.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 32807
:
147111
|
147115
| 148654 |
148851
|
148894