Bug 31455

Summary: Batch modification tool orders found items by itemnumber
Product: Koha Reporter: Lucas Gass (lukeg) <lucas>
Component: ToolsAssignee: Lucas Gass (lukeg) <lucas>
Status: CLOSED FIXED QA Contact: Joonas Kylmälä <joonas.kylmala>
Severity: normal    
Priority: P5 - low CC: fridolin.somers, joonas.kylmala, victor
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00,22.05.05,21.11.12
Circulation function:
Bug Depends on: 28445    
Bug Blocks:    
Attachments: Bug 31455: Make batchMod sort by order scanned
Bug 31455: Make batchMod sort by order scanned
Bug 31455: Make batchMod sort by order scanned
Bug 31455: (QA follow-up) Make table creation O(N)

Description Lucas Gass (lukeg) 2022-08-24 21:39:35 UTC
When using the batch mod tools and entering in a set of barcodes the table of found items is ordered by itemnumber instead of by the order in which the barcodes were scanned.

This is a problem for librarians who scan a batch of books and then get a table ordered completely different.
Comment 1 Lucas Gass (lukeg) 2022-09-01 17:00:57 UTC
Created attachment 140052 [details] [review]
Bug 31455: Make batchMod sort by order scanned

To test:
1. In batch item deletion and batch item modification add some barcodes.
2. Notice they are being sorted by item number, not in the order scanned.
3. Appply patch and restart services.
4. Try scanning items again in both batch item deletion and batch item modification.
5. The found barcodes should now sort by order scanned.
Comment 2 Owen Leonard 2022-09-01 19:05:25 UTC
Created attachment 140059 [details] [review]
Bug 31455: Make batchMod sort by order scanned

To test:
1. In batch item deletion and batch item modification add some
   barcodes.
2. Notice they are being sorted by item number, not in the order
   scanned.
3. Appply patch and restart services.
4. Try scanning items again in both batch item deletion and batch item
   modification.
5. The found barcodes should now sort by order scanned.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 3 Joonas Kylmälä 2022-09-01 19:47:08 UTC
Created attachment 140061 [details] [review]
Bug 31455: Make batchMod sort by order scanned

To test:
1. In batch item deletion and batch item modification add some
   barcodes.
2. Notice they are being sorted by item number, not in the order
   scanned.
3. Appply patch and restart services.
4. Try scanning items again in both batch item deletion and batch item
   modification.
5. The found barcodes should now sort by order scanned.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Comment 4 Joonas Kylmälä 2022-09-01 19:47:11 UTC
Created attachment 140062 [details] [review]
Bug 31455: (QA follow-up) Make table creation O(N)

We can insert the indices before the main loop to a hash,
this way we don't have to look up during each loop iteration
the index from an array which in the worst case might take O(N)
thus making the total time complexity O(N^2).

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Comment 5 Tomás Cohen Arazi (tcohen) 2022-09-12 18:37:18 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 6 Lucas Gass (lukeg) 2022-09-16 15:23:28 UTC
Backported to 22.05.x for 22.05.05
Comment 7 Arthur Suzuki 2022-09-21 15:09:24 UTC
Thanks!

Pushed to 21.11 for 21.11.12
Comment 8 Fridolin Somers 2022-10-10 08:29:24 UTC
We could have define no sort by default like in batch record modification : 
"aaSorting": [],
Comment 9 Fridolin Somers 2022-10-10 08:35:40 UTC
(In reply to Arthur Suzuki from comment #7)
> Thanks!
> 
> Pushed to 21.11 for 21.11.12

Ich I dont see first patch in 21.11.x :

https://git.koha-community.org/Koha-community/Koha/commits/branch/21.11.x/search?q=31455
Comment 10 Victor Grousset/tuxayo 2022-10-13 15:07:59 UTC
Not backported to oldoldstable (21.05.x). Feel free to ask if it's needed.

Nothing to document it seems, note: mark resolved when the issue with 21.11 missing a patch is resolved.