Bug 29346: Refactor loop code into a subroutine
authorTomas Cohen Arazi <tomascohen@theke.io>
Thu, 24 Feb 2022 11:01:53 +0000 (08:01 -0300)
committerFridolin Somers <fridolin.somers@biblibre.com>
Thu, 5 May 2022 21:17:35 +0000 (11:17 -1000)
commit210c686f7bfc2fd4dc11bdd5fcd582eb9f8f4500
tree878751c6394c047b266629ff67d885483a0af8d5
parent1b230335e7560250072f4880f745636f62fefe74
Bug 29346: Refactor loop code into a subroutine

The CreateQueue() method deletes the holds queue data, fetches some
configuration (branches to use, transport cost matrix) and then loops
through a list of biblionumbers, generating the tmp_holdsqueue and
hold_fill_targets rows for the specified biblio.

This patch simply moves that last bit that is run inside the biblios
loop into a separate sub.

The update_queue_for_biblio sub is designed so it does the exact same
thing it did inside the loop, but also gets added the capability of
querying those parameters if not passed, and it also gets a 'delete'
parameter so it deletes the biblio-specific holds queue rows before
starting to work.

This way, it can be reused to write a background job for real-time holds
queue update :-D

To test:
1. Run:
   $ kshell
  k$ prove t/db_dependent/HoldsQueue.t
=> SUCCESS: Tests pass!
2. Apply this patch
3. Repeat 1
=> SUCCESS: Tests still pass! Behavior is kept!
4. Sign off :-D

Sponsored-by: Montgomery County Public Libraries
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
C4/HoldsQueue.pm