Bug 32494

Summary: Potentially expensive API calls made for conditional template rendering
Product: Koha Reporter: Matt Blenkinsop <matt.blenkinsop>
Component: ERMAssignee: Jonathan Druart <jonathan.druart>
Status: RESOLVED DUPLICATE QA Contact:
Severity: enhancement    
Priority: P5 - low CC: jonathan.druart, jonathan.field, martin.renvoize, pedro.amorim
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 32474    
Bug Blocks:    

Description Matt Blenkinsop 2022-12-19 17:33:40 UTC
Bug 32474 introduces ajax based scrolling in v-selects to reduce expensive API calls. Within ERM there are components where an API call is made and then sections of template are conditionally rendered depending on whether the call returns any data. For example, LicensesList.vue requests a list of all licenses and then renders a div containing a table if "licences.length" is true. The table then makes the same API call again to fetch the data to populate the table. The initial API call is therefore not relevant to the table data and if there is a large number of licenses, this will be an expensive call to make simply to render the table before making the same call again.

I would suggest that the initial API call needs to be paginated to return a small amount of data to pass the licenses.length conditional check. The change proposed in bug 32474 in fetch.js allows fetchLicenses to be called with a parameter to paginate to just one page like this: "fetchLicenses(1)". We will then only be fetching one page of 20 values to pass the check. 

N.B. in bug 32474 components with a v-select have already been paginated e.g. AgreementLicenses.vue - this bug is to patch the components that have not been modified already, such as LicensesList.vue
Comment 1 Jonathan Druart 2023-10-03 06:56:06 UTC
I think this has been fixed by the following commit:
  Bug 32807: Fetch count instead of all entries for agreements and licenses

*** This bug has been marked as a duplicate of bug 32807 ***