Description
Andrew Fuerste-Henry
2021-06-08 17:23:55 UTC
+1 We also would like to see this functionality added in. As we move to a more floating based system, we are going to rely on CollectionsHQ to tell us how to shift. It would be a great option to see this built into the ILS. We would also like this as a feature, it would be very helpful to have this as we are also using CollectionHQ to tell us how to shift our collections. -Charlie Created attachment 160038 [details] [review] Bug 28530: Update database, add new schema file Created attachment 160039 [details] [review] Bug 28530: Update database, add new schema file Created attachment 160040 [details] [review] Bug 28530: Add Koha Object(s) for Float Limits Created attachment 160041 [details] [review] Bug 28530: Update existing schema files Created attachment 160042 [details] [review] Bug 28530: Add float limits editor Created attachment 160043 [details] [review] Bug 28530: Implement float limits Test Plan: 1) Apply this patch set 2) Run updatedatabase.pl 3) Restart all the things! 4) Enable UseLibraryFloatLimits 5) Verify items float correctly as per your circulation rules 6) Set some float limits from the Library Float Limits configuration page in the Administration section The simplest solution is to set the float limit from one branch to 1 item, a second to 100 items, and a third to 300 items for a single itemtype 7) Verify checked in items that should have floated at this branch are now transfered to the branch with the best float ratio Created attachment 160044 [details] [review] Bug 28530: Add unit tests Created attachment 160045 [details] [review] Bug 28530: Update database, add new schema file Created attachment 160046 [details] [review] Bug 28530: Add Koha Object(s) for Float Limits Created attachment 160047 [details] [review] Bug 28530: Update existing schema files Created attachment 160048 [details] [review] Bug 28530: Add float limits editor Created attachment 160049 [details] [review] Bug 28530: Implement float limits Test Plan: 1) Apply this patch set 2) Run updatedatabase.pl 3) Restart all the things! 4) Enable UseLibraryFloatLimits 5) Verify items float correctly as per your circulation rules 6) Set some float limits from the Library Float Limits configuration page in the Administration section The simplest solution is to set the float limit from one branch to 1 item, a second to 100 items, and a third to 300 items for a single itemtype 7) Verify checked in items that should have floated at this branch are now transfered to the branch with the best float ratio Created attachment 160050 [details] [review] Bug 28530: Add unit tests I created a sandbox with these patches, but it doesn't seem to have the new table. I get the following error when I go to /cgi-bin/koha/admin/float_limits.pl: DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Table 'koha_floatie.library_float_limits' doesn't exist at /kohadevbox/koha/Koha/Objects.pm line 317 at /usr/share/perl5/DBIx/Class/Exception.pm line 77 Created attachment 160053 [details] [review] Bug 28530: Update database, add new schema file Created attachment 160054 [details] [review] Bug 28530: Add Koha Object(s) for Float Limits Created attachment 160055 [details] [review] Bug 28530: Update existing schema files Created attachment 160056 [details] [review] Bug 28530: Add float limits editor Created attachment 160057 [details] [review] Bug 28530: Implement float limits Test Plan: 1) Apply this patch set 2) Run updatedatabase.pl 3) Restart all the things! 4) Enable UseLibraryFloatLimits 5) Verify items float correctly as per your circulation rules 6) Set some float limits from the Library Float Limits configuration page in the Administration section The simplest solution is to set the float limit from one branch to 1 item, a second to 100 items, and a third to 300 items for a single itemtype 7) Verify checked in items that should have floated at this branch are now transfered to the branch with the best float ratio Created attachment 160058 [details] [review] Bug 28530: Add unit tests Note for testing: I confirmed that AutomaticItemReturn does control whether or not one can decline the transfers initiated by this feature. Issues: - Library float limits needs to be included in the admin nav sidebar - Allow value of zero -- currently, if you enter a zero it gets treated as a blank and no limit is saved. As described on the screen, a blank should mean float is not limited while a limit of zero would mean items of that type should always transfer away - rename "limit" field as it causes errors in writing reports unless you refer to the field with its full name (library_floating_limits.limit). Maybe "item_limit"? Transfer triggered for checkin that *meets* limit rather than exceeding it: - have a float limit set to 1 for Branch A - have 1 item of that item type at Branch A, giving ratio of 1 - check that item in at Branch A, get notified that this would put the library over its limit and the item will be transferred Ratio not correctly calculated for branches with zero items of type: - Have defined float limits for Branches: A = 1, B = 10, C = 100 - Have 1 item of limited type at Branch A, 1 at Branch B, zero at Branch C - Check 1 item in at Branch A - Koha directs the item to transfer to Branch B (ratio of .1) rather than Branch C (ratio of zero) Seems like we're only calculating a ratio where there is at least 1 item already. > Transfer triggered for checkin that *meets* limit rather than exceeding it:
> - have a float limit set to 1 for Branch A
> - have 1 item of that item type at Branch A, giving ratio of 1
> - check that item in at Branch A, get notified that this would put the
> library over its limit and the item will be transferred
Clarifying a little -- currently the patch *does* generate a transfer when a checked in item *meets* the floating limit. And I suppose that's what the text on screen says: "if the checkin library has reached its' limit for that type of item." That said, I feel like users may expect transfers to be generated only when the limits are *exceeded*.
Created attachment 160061 [details] [review] Bug 28530: (QA follow-up): Fix qa issues Created attachment 160062 [details] [review] Bug 28530: Update database, add new schema file Created attachment 160063 [details] [review] Bug 28530: Add Koha Object(s) for Float Limits Created attachment 160064 [details] [review] Bug 28530: Update existing schema files Created attachment 160065 [details] [review] Bug 28530: Add float limits editor Created attachment 160066 [details] [review] Bug 28530: Implement float limits Test Plan: 1) Apply this patch set 2) Run updatedatabase.pl 3) Restart all the things! 4) Enable UseLibraryFloatLimits 5) Verify items float correctly as per your circulation rules 6) Set some float limits from the Library Float Limits configuration page in the Administration section The simplest solution is to set the float limit from one branch to 1 item, a second to 100 items, and a third to 300 items for a single itemtype 7) Verify checked in items that should have floated at this branch are now transfered to the branch with the best float ratio Created attachment 160067 [details] [review] Bug 28530: Add unit tests Created attachment 160068 [details] [review] Bug 28530: (QA follow-up) Fix QA issues Created attachment 160071 [details] [review] Bug 28530: Update database, add new schema file Created attachment 160072 [details] [review] Bug 28530: Add Koha Object(s) for Float Limits Created attachment 160073 [details] [review] Bug 28530: Update existing schema files Created attachment 160074 [details] [review] Bug 28530: Add float limits editor Created attachment 160075 [details] [review] Bug 28530: Implement float limits Test Plan: 1) Apply this patch set 2) Run updatedatabase.pl 3) Restart all the things! 4) Enable UseLibraryFloatLimits 5) Verify items float correctly as per your circulation rules 6) Set some float limits from the Library Float Limits configuration page in the Administration section The simplest solution is to set the float limit from one branch to 1 item, a second to 100 items, and a third to 300 items for a single itemtype 7) Verify checked in items that should have floated at this branch are now transfered to the branch with the best float ratio Created attachment 160076 [details] [review] Bug 28530: Add unit tests (In reply to Andrew Fuerste-Henry from comment #24) All issues should be fixed. All fixes merged into original patchset! (In reply to Andrew Fuerste-Henry from comment #24) > > Transfer triggered for checkin that *meets* limit rather than exceeding it: > > - have a float limit set to 1 for Branch A > > - have 1 item of that item type at Branch A, giving ratio of 1 > > - check that item in at Branch A, get notified that this would put the > > library over its limit and the item will be transferred > > Clarifying a little -- currently the patch *does* generate a transfer when a > checked in item *meets* the floating limit. And I suppose that's what the > text on screen says: "if the checkin library has reached its' limit for that > type of item." That said, I feel like users may expect transfers to be > generated only when the limits are *exceeded*. I'll change to exceeding the limit. I think that's more natural and expected. Created attachment 160077 [details] [review] Bug 28530: (QA follow-up) Require the item checkin to exceed the limit, rather than meet the limit Created attachment 160078 [details] [review] Bug 28530: Update database, add new schema file Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Created attachment 160079 [details] [review] Bug 28530: Add Koha Object(s) for Float Limits Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Created attachment 160080 [details] [review] Bug 28530: Update existing schema files Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Created attachment 160081 [details] [review] Bug 28530: Add float limits editor Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Created attachment 160082 [details] [review] Bug 28530: Implement float limits Test Plan: 1) Apply this patch set 2) Run updatedatabase.pl 3) Restart all the things! 4) Enable UseLibraryFloatLimits 5) Verify items float correctly as per your circulation rules 6) Set some float limits from the Library Float Limits configuration page in the Administration section The simplest solution is to set the float limit from one branch to 1 item, a second to 100 items, and a third to 300 items for a single itemtype 7) Verify checked in items that should have floated at this branch are now transfered to the branch with the best float ratio Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Created attachment 160083 [details] [review] Bug 28530: Add unit tests Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Created attachment 160084 [details] [review] Bug 28530: (QA follow-up) Require the item checkin to exceed the limit, rather than meet the limit Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Programming error - op 'set_float_limits' must start with 'cud-' for POST http://localhost:8081/intranet/admin/float_limits.pl Created attachment 163919 [details] [review] Bug 28530: (QA follow-up): Implement CSRF cud op Created attachment 168343 [details] [review] Bug 28530: Update database, add new schema file Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Created attachment 168344 [details] [review] Bug 28530: Add Koha Object(s) for Float Limits Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Created attachment 168345 [details] [review] Bug 28530: Add float limits editor Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Created attachment 168346 [details] [review] Bug 28530: Implement float limits Test Plan: 1) Apply this patch set 2) Run updatedatabase.pl 3) Restart all the things! 4) Enable UseLibraryFloatLimits 5) Verify items float correctly as per your circulation rules 6) Set some float limits from the Library Float Limits configuration page in the Administration section The simplest solution is to set the float limit from one branch to 1 item, a second to 100 items, and a third to 300 items for a single itemtype 7) Verify checked in items that should have floated at this branch are now transfered to the branch with the best float ratio Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Created attachment 168347 [details] [review] Bug 28530: Add unit tests Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Created attachment 168348 [details] [review] Bug 28530: (QA follow-up) Require the item checkin to exceed the limit, rather than meet the limit Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Created attachment 168349 [details] [review] Bug 28530: (QA follow-up): Implement CSRF cud op Created attachment 168350 [details] [review] Bug 28530: Update existing schema files Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Sorry Kyle, this no longer applies Created attachment 178762 [details] [review] Bug 28530: Update database, add new schema file Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Created attachment 178763 [details] [review] Bug 28530: Add Koha Object(s) for Float Limits Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Created attachment 178764 [details] [review] Bug 28530: Add float limits editor Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Created attachment 178765 [details] [review] Bug 28530: Implement float limits Test Plan: 1) Apply this patch set 2) Run updatedatabase.pl 3) Restart all the things! 4) Enable UseLibraryFloatLimits 5) Verify items float correctly as per your circulation rules 6) Set some float limits from the Library Float Limits configuration page in the Administration section The simplest solution is to set the float limit from one branch to 1 item, a second to 100 items, and a third to 300 items for a single itemtype 7) Verify checked in items that should have floated at this branch are now transfered to the branch with the best float ratio Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Created attachment 178766 [details] [review] Bug 28530: Add unit tests Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Created attachment 178767 [details] [review] Bug 28530: (QA follow-up) Require the item checkin to exceed the limit, rather than meet the limit Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Created attachment 178768 [details] [review] Bug 28530: (QA follow-up): Implement CSRF cud op Created attachment 178769 [details] [review] Bug 28530: Update existing schema files Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Rebased for current main, still some noticeable problems with both CSRF and Bootstrap 5 things. Setting to FQA for now. Created attachment 178783 [details] [review] Bug 28530: Template adjustmentts for CSRF and Bootstrap 5 Created attachment 178784 [details] [review] Bug 28530: Tidy admin-menu.inc Created attachment 178785 [details] [review] Bug 28530: Fix remaining QA script failures I think this is again ready for testing, resetting to NSO. This doesn't seem to be enforcing limits correctly. I think it's checking the float limit against the total number of items of that item type in the whole system (rather than just at the current branch) and then prompting a transfer to the branch with the lowest items/limit ratio (unless that's your current branch, in which case no transfer is generated). To recreate: - set circ rules to everything floats - create 4 items of itemtype CF / Computer Files (this itype exists in the default data without any items, so it's easy to test with) - set float limit of 3 for CF items at Centerville and Fairfield branches, leave other branches without limits - play around checking your 4 items in at Centerville and Fairfield Koha should only generate a transfer when all 4 items end up at either Centerville or Fairfield. Instead, it seems to be generating a transfer whenever the branch at which you're checking in does not have the lowest ratio of items/limit. Created attachment 178934 [details] [review] Bug 28530: (QA follow-up) correct item count and limit enforcement Corrected the count of items to limit to the current branch. Also set the limit to trigger when the count of items at the branch is currently at the limit before the item to be checked in. Created attachment 178935 [details] [review] Bug 28530: Update database, add new schema file Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 178936 [details] [review] Bug 28530: Add Koha Object(s) for Float Limits Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 178937 [details] [review] Bug 28530: Add float limits editor Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 178938 [details] [review] Bug 28530: Implement float limits Test Plan: 1) Apply this patch set 2) Run updatedatabase.pl 3) Restart all the things! 4) Enable UseLibraryFloatLimits 5) Verify items float correctly as per your circulation rules 6) Set some float limits from the Library Float Limits configuration page in the Administration section The simplest solution is to set the float limit from one branch to 1 item, a second to 100 items, and a third to 300 items for a single itemtype 7) Verify checked in items that should have floated at this branch are now transfered to the branch with the best float ratio Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 178939 [details] [review] Bug 28530: Add unit tests Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 178940 [details] [review] Bug 28530: (QA follow-up) Require the item checkin to exceed the limit, rather than meet the limit Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 178941 [details] [review] Bug 28530: (QA follow-up): Implement CSRF cud op Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 178942 [details] [review] Bug 28530: Update existing schema files Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 178943 [details] [review] Bug 28530: Template adjustmentts for CSRF and Bootstrap 5 Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 178944 [details] [review] Bug 28530: Tidy admin-menu.inc Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 178945 [details] [review] Bug 28530: Fix remaining QA script failures Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 178946 [details] [review] Bug 28530: (QA follow-up) correct item count and limit enforcement Corrected the count of items to limit to the current branch. Also set the limit to trigger when the count of items at the branch is currently at the limit before the item to be checked in. Signed-off-by: Kris Becker <kbecker@jcls.org> Unit tests are failing here I'm afraid. Created attachment 179943 [details] [review] Bug 28530: Update database, add new schema file Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 179944 [details] [review] Bug 28530: Add Koha Object(s) for Float Limits Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 179945 [details] [review] Bug 28530: Add float limits editor Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 179946 [details] [review] Bug 28530: Implement float limits Test Plan: 1) Apply this patch set 2) Run updatedatabase.pl 3) Restart all the things! 4) Enable UseLibraryFloatLimits 5) Verify items float correctly as per your circulation rules 6) Set some float limits from the Library Float Limits configuration page in the Administration section The simplest solution is to set the float limit from one branch to 1 item, a second to 100 items, and a third to 300 items for a single itemtype 7) Verify checked in items that should have floated at this branch are now transfered to the branch with the best float ratio Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 179947 [details] [review] Bug 28530: Add unit tests Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 179948 [details] [review] Bug 28530: (QA follow-up) Require the item checkin to exceed the limit, rather than meet the limit Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 179949 [details] [review] Bug 28530: (QA follow-up): Implement CSRF cud op Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 179950 [details] [review] Bug 28530: Update existing schema files Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 179951 [details] [review] Bug 28530: Template adjustmentts for CSRF and Bootstrap 5 Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 179952 [details] [review] Bug 28530: Tidy admin-menu.inc Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 179953 [details] [review] Bug 28530: Fix remaining QA script failures Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 179954 [details] [review] Bug 28530: (QA follow-up) correct item count and limit enforcement Corrected the count of items to limit to the current branch. Also set the limit to trigger when the count of items at the branch is currently at the limit before the item to be checked in. Signed-off-by: Kris Becker <kbecker@jcls.org> Created attachment 179955 [details] [review] Bug 28530: Adjust number of tests (In reply to Martin Renvoize (ashimema) from comment #87) > Unit tests are failing here I'm afraid. It seems like it was only the number of test, I have adjusted that. Nothing else was failing for me. Created attachment 180028 [details] [review] Bug 28530: Adjust number of tests Signed-off-by: Kris Becker <kbecker@jcls.org> I'm afraid I'm seeing unit test failures still here.. I've reset_all etc and the tests still fail I'm afraid. Comment on attachment 179944 [details] [review] Bug 28530: Add Koha Object(s) for Float Limits Review of attachment 179944 [details] [review]: ----------------------------------------------------------------- ::: Koha/Library/FloatLimits.pm @@ +43,5 @@ > +sub lowest_ratio_library { > + my ( $self, $item, $branchcode ) = @_; > + > + my $field = C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype'; > + my $query = qq{ Is it deliverate to continue using plain SQL here rather than constructing a DBIC query.. and should we perhaps be returning a Koha::Library object rather than a branchcode given this is a Koha:: object method? In fact.. I'd kinda be tempted to shift that filter method into Koha::Libraries... you're basically looking for the library with the lowest_ratio.. that feels like a `Koha::Libraries->find_library_with_lowest_float_ratio` method to me...
> Is it deliverate to continue using plain SQL here rather than constructing a
> DBIC query.. and should we perhaps be returning a Koha::Library object
> rather than a branchcode given this is a Koha:: object method?
I'm not the original author but I tend to agree, let's use a DBIC query and return a library object.
Created attachment 182931 [details] [review] Bug 28530: Use DBIC query and return library object In testing this, I've run into some shortcomings in its logic. I suspect these are things that were not considered to begin with, rather than things introduced in the recent change to use DBIC and a library object. As these float limits are enforced, we count items based purely on their holdingbranch, regardless of other values. Most pointedly, we don't consider whether or not those items are either checked out or in transit to another library. The goal here is to govern floating based on how many items are actually on the shelf, so this isn't ideal. My pretend library has a branch with a floating limit of 10 for the itemtype DVD, because they're small. At this small branch: - there are 10 DVDs available -- they're at their float limit - a patron checks out 5 DVDs, leaving 5 available Per the current logic, this library is *still* at their float limit because those 5 checked-out DVDs haven't changed their holding branch, even though we have no expectation that those DVDs will come back to the same branch they were checked out from. ** When an item is checked out, it should not count toward the float limit at *any* branch. A new scenario at my pretend library, again at the small branch with the float limit of 10 DVDs: - there are 10 DVDs available -- they're at their float limit - take one of those 10 available DVDs and check it in for a local use - Koha tells you to transfer that item away to keep under your float limit. Accept that transfer - Check in one of your 9 remaining available DVDs for another local use. Koha tells you to transfer this one away, too. Because the holding branch on the previous one hasn't changed yet and we're not looking at whether or not it's in transit. ** When an item is in transit, it should count toward the float limit at the branch it is transferring to, even when it hasn't been received yet. (In reply to Andrew Fuerste-Henry from comment #108) > A new scenario at my pretend library, again at the small branch with the > float limit of 10 DVDs: > - there are 10 DVDs available -- they're at their float limit > - take one of those 10 available DVDs and check it in for a local use > - Koha tells you to transfer that item away to keep under your float limit. This is another issue. Checkin an item in for a local use prompts that item to transfer away if the library is *at* its float limit. Seems like it's not considering that the item being checked in is already here and therefore will not push the library to *exceed* its limit, which is when a transfer should happen. |