Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOLIO: more flexible hold exclusion configuration #2683

Merged

Conversation

meganschanz
Copy link
Contributor

This adds a new config in the FOLIO driver to optionally exclude hold location matches by substrings instead of full string matches. This config is set to false by default for backwards compatibility.

This was useful for us because we have a dozens of locations we need to exclude that either start with or contain a string (such as "Reserve" or "Special Collection") but the full location have more specific qualifiers in them like the floor and the list would be quite long and difficult to maintain anytime a new location was added or changed.

@meganschanz
Copy link
Contributor Author

Rookie mistake! I'm working on cleaning up the format issues and I'll make another commit tomorrow.

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @meganschanz -- I'm happy to merge this as is, but a suggestion for your consideration first: what if, instead of a binary excludeHoldLocationsBySubString setting, we had a excludeHoldLocationsCompareMode setting, with "exact" or "substring" options? This would open the way to adding additional options (like a "regex" mode) if we need them, without having to further redesign the configuration. Or we could implement regex mode now, and make "substring" a special case of regex (we could just add /.* ... .*/ around each value. Case sensitivity is another question: do we want to offer case-sensitive and case-insensitive versions? Using regular expressions makes it easier to configure this without having to add lots of different modes, since you can control it with regex switches.

@demiankatz demiankatz changed the title Add ability to optionally match excluded hold locations in FOLIO driver based on substring match FOLIO: more flexible hold exclusion configuration Jan 26, 2023
@meganschanz
Copy link
Contributor Author

Good idea. I much prefer that. I took your suggested and made a commit that has a setting with excludeHoldLocationsCompareMode with the default value of exact but allowing for regex.

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great, @meganschanz! A few minor suggestions for finishing touches. It might also be nice to add some test coverage for the new behavior. If you'd like to try that and are not yet familiar with VuFind's test suite, I can point you to some resources and make some suggestions. If you don't have time, I can probably add a quick test myself before merging this.

config/vufind/Folio.ini Show resolved Hide resolved
module/VuFind/src/VuFind/ILS/Driver/Folio.php Outdated Show resolved Hide resolved
module/VuFind/src/VuFind/ILS/Driver/Folio.php Outdated Show resolved Hide resolved
@meganschanz
Copy link
Contributor Author

Those suggestions look good. I just started in on writing the unit tests and ran into a problem, the isHoldable function is protected. Is there a preferred way for tested those. I could have it call the public getHolding function and then just check the is_holdable attribute of item, but that seems like more overhead than necessary.

Error: Call to protected method VuFind\ILS\Driver\Folio::isHoldable() from scope VuFindTest\ILS\Driver\FolioTest

@demiankatz
Copy link
Member

Thanks, @meganschanz! If you need to test a protected method, and there's not a straightforward way to test it via a public method, you can mix in the ReflectionTrait and use $this->callMethod().

@meganschanz
Copy link
Contributor Author

I learned so much about the testing today... that vendor/bin/phing qa-php command that the CI runs is handy!

Let me know if you have suggestions for any rework that could be done to the tests. When working on the tests, I also added in a small change to the isHoldable function to better handle the scenario when a bad regex pattern is set in the config.

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the ongoing progress, @meganschanz -- this is looking great, and could nearly be merged as it is... but since you asked about test style, I provided some suggestions that I think will make this even better. I also had one small stylistic comment which you can use or ignore as you see fit. The only thing that I think we absolutely must do is fix the order of parameters in the assertions; the rest is a matter of taste.

One other tool in the PHPUnit test kit that I find very useful is the @dataProvider annotation, which lets you separate your test logic from your test data in a useful way. You could use that for some of the tests here, though I think it's probably overkill. If you're interested in learning more about it, though, feel free to experiment.

Let me know if there's anything more I can do to help!

@meganschanz
Copy link
Contributor Author

I spent some time playing around with the @dataProvider syntax this morning, which was really neat! I did think it probably would be overkill to do in this case since I couldn't use the same data provider for each of the separate test functions (due to the expected output changing based on the config setting of that particular test function). So for simplicity and readability I kept it as-is for now. But for future tests I will definitely keep that in mind!

I made the other corrections and suggestions to the tests and removed the unnecessary else statement in the isHoldable function. Let me know if you see anything else!

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, @meganschanz -- thanks for taking the time to put it all together!

@demiankatz demiankatz merged commit ae94488 into vufind-org:dev Jan 31, 2023
@meganschanz meganschanz deleted the optional_substring_hold_exclusion branch February 1, 2023 20:43
EreMaijala pushed a commit to EreMaijala/vufind that referenced this pull request Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants