Bug 33430 - Use REST API for suggestions tables
Summary: Use REST API for suggestions tables
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
: 27183 (view as bug list)
Depends on:
Blocks: 34832
  Show dependency treegraph
 
Reported: 2023-04-06 11:30 UTC by Laura Escamilla
Modified: 2024-10-15 19:43 UTC (History)
13 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Laura Escamilla 2023-04-06 11:30:24 UTC
The purchase suggestion management page take anywhere between 15-45 seconds to load if there are several hundred items in the suggestions table.
Comment 1 Lucas Gass (lukeg) 2023-04-06 18:42:00 UTC
For testing purposes in koha-testing-docker I wrote this. Definitely DO NOT add this to a production server:

$('body').append('<button id="makeSuggestions">Make 100 suggestions</button>');
  $('#makeSuggestions').click( function() {
    for (let i = 0; i < 100; i++) {
      let branches = ["CPL", "FFL","FPL","FRL","IPT","LPL","MPL","PVL","RPL","SPL","TPL","UPL"];
      let random_branch = Math.floor(Math.random() * branches.length);

      let statuses = ["ASKED", "ACCEPTED", "REJECTED"];
      let random_status = Math.floor(Math.random() * statuses.length);

      let random_title = (Math.random() + 1).toString(36).substring(2);
      $.ajax({
        url: '/api/v1/suggestions',
        method: 'POST',
        data: JSON.stringify({
              "title": random_title,
              "item_type": "BK",
              "suggested_by": Math.floor(Math.random() * 51),
              "suggestion_date": "2023-04-06",
              "timestamp": "2023-04-06T17:59:26+00:00",
              "managed_by": 51,
              "library_id": branches[random_branch],
              "status": statuses[random_status],
      }),
        contentType: 'application/json',
        success: function(result) {
            console.log('suggestion added');
        },
    });
  } 
});
Comment 2 Lucas Gass (lukeg) 2023-04-26 17:33:20 UTC
Ultimately these tables probably need to be coming for the REST API?
Comment 3 Felicity Brown 2024-01-05 00:05:04 UTC
Would it be possible to have batch changes made by queuing them, like we have for batch item modification? So we could continue to work on other purchase suggestions while the last set of edits are updating? I find it grinds particularly badly when I'm trying to update several records from a page to assign a manager to them.
Comment 4 Candice Hope 2024-01-24 18:56:20 UTC
This is very slow on our system too. Hopefully there is a good solution for it soon.
Comment 5 Joe Askins 2024-06-11 20:07:45 UTC
Fayetteville Public Library cosigning the need for this fix -- the slow load times are making it very difficult to work through these purchase suggestions.
Comment 6 Teresa Dahlgren 2024-07-24 19:47:00 UTC
This is a challenge at our library as well. The purchase suggestion management page takes a long time to load, and it also takes a long time to save changes made to a purchase suggestion (such as changing the status to "Accepted" or "Ordered").
Comment 7 CJ Lynce 2024-07-26 14:21:12 UTC
We are experiencing this as well, with just over 400 items between the Accepted, Checked, and Rejected tabs. The pages can take 10+ seconds, and at times even longer to load.

We also suspect this is related to an issue that, after modifying a suggestion, the page returns to the suggestions list, but never fully loads the table of suggestions (We cannot conclusively prove this is related at this point, but are trying to narrow this down)
Comment 8 Lucas Gass (lukeg) 2024-07-26 14:27:25 UTC
*** Bug 27183 has been marked as a duplicate of this bug. ***
Comment 9 Lucas Gass (lukeg) 2024-07-26 14:29:37 UTC
Looks like Bug 27183 is a duplicate of this one. We load all the suggestions each time visiting the page. As Michal pointed out, API pagination can solve this. Not easy though. :)
Comment 10 Ray Delahunty 2024-08-13 12:25:25 UTC
Is Bug 31024 also a duplicate of this one? We have massively configured Suggestions Management with 5 additional SUGGEST_STATUS (and tweaks to the default ones). We have added various notices so we offer both centralised and college-based Suggestions Management using very different workflows. The feature is now widely used by many staff and it would be great to have the page draw quickly.
Comment 11 Katrin Fischer 2024-08-13 12:34:23 UTC
The move to REST is the ultimate fix, but could we improve performance otherwise too? How are we doing with indexes on the table and the like, are there some easy improvements we could make here?

If not, I think marking as duplicate would be the next logical step.