[Bug 25554] New: Refactor rule kinds assignments in CirculationRules.pm
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25554 Bug ID: 25554 Summary: Refactor rule kinds assignments in CirculationRules.pm Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: ASSIGNED Severity: enhancement Priority: P5 - low Component: Circulation Assignee: stalkernoid@gmail.com Reporter: stalkernoid@gmail.com QA Contact: testopia@bugs.koha-community.org CC: gmcharlt@gmail.com, kyle.m.hall@gmail.com Rule kinds in CirculationRules.pm have repeated code with the same values assigned many times. Refactored code is already in a patch that will be pushed promptly to this ticket. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25554 --- Comment #1 from Peter Vashchuk <stalkernoid@gmail.com> --- Created attachment 105154 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=105154&action=edit Bug 25554: Refactor rule kinds assignments in CirculationRules.pm CirculationRules.pm have repeated code with the same values assigned many times to rule kinds and also same hardcoded values appear in foreach loop. Refactored by creating arrays once and then assigning and looping their values. Mentored-by: Andrew Nugged <nugged@gmail.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25554 Peter Vashchuk <stalkernoid@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25554 Peter Vashchuk <stalkernoid@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nugged@gmail.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25554 Peter Vashchuk <stalkernoid@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |slavashishkin@gmail.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25554 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@bugs.koha-c | |ommunity.org --- Comment #2 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Hum, I am going to ask myself "what it scope2 again?" for years :) I agree we could have that in a variable, but be more explicit: b_c, b_i, b_c_i or, even better IMO: branch_category, branch_itemtype, branch_category_itemtype -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25554 --- Comment #3 from Peter Vashchuk <stalkernoid@gmail.com> --- Yeah I thought about naming them similarly to what you proposed but it would undermine some decisions that were taken into consideration during refactor. The thing is, we need to add another item to "scope3" for Koha Finland, if we name those arrays something like I already did (scope1, scope2, scope3) all it requires is to add another item to array and we’re done, but if we rename those arrays like you suggested (branch_category, branch_itemtype, branch_category_itemtype) it will complicate things if we ever need to add any other element to any of those arrays. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25554 --- Comment #4 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Hi Peter, can you explain about your future needs? At the moment I am with Jonathan, I think readability is to be preferred, even if resulting in more code. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25554 --- Comment #5 from Andrew Nugged <nugged@gmail.com> --- Here we need to have more filtering criteria for smart-rules. For Finnish libraries, we added "ccode" and "sleving_location", two extra smart rule filters (but by the way also later we propose this for the community version) so we had before: my $scope3 = [ 'branchcode', 'categorycode', 'itemtype' ]; but now we have in our case: my $scope3 = [ 'branchcode', 'categorycode', 'itemtype', 'ccode', 'shelving_location' ]; and because of having only a single variable, we don't need to change any variable names down in the file, nor copy-paste dozen times like it is now the same array copypasted everywhere. But now proposal from Jonathan to name it something like "$branch_category_itemtype" will make this: my $branch_category_itemtype = [ 'branchcode', 'categorycode', 'itemtype' ]; becoming this (???): my $branch_category_itemtype_ccode_shelving_location = [ 'branchcode', 'categorycode', 'itemtype', 'ccode', 'shelving_location' ]; so when we add two extra items, we should again change all the code down below to the new variable name $branch_category_itemtype_ccode_shelving_location? Yikes! That's why we voting for "$scope3", because we have three scope sections, even logically separated: small one, middle, and full. ... Oh, or let's name it "$scope_full" if you ok? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25554 --- Comment #6 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- What about the following? $scopes => [ { scope => [ qw( branchcode ) ], rules => [ qw( refund ) ], }, { scope => [ qw( branchcode categorycode ) ], rules => [ qw( patron_maxissueqty patron_maxonsiteissueqty max_holds ... ) ], }, ... { scope => [ qw( branchcode categorycode itemtype ) ], rules => [ qw( article_requests auto_renew cap_fine_to_replacement_price ...) ], }, ]; ie you define using a different structure, then you "revert" it to generate the existing structure. Don't implement it yet, I am not sure I agree with myself :D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25554 Andrew Nugged <nugged@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |In Discussion --- Comment #7 from Andrew Nugged <nugged@gmail.com> --- But that's not only about the assignment of $RULE_KINDS on the beginning, $scope3 also used in the code further, in two places:
+my $scope3 = [ 'branchcode', 'categorycode', 'itemtype' ]; ...
my $order_by = $params->{order_by} - // { -desc => [ 'branchcode', 'categorycode', 'itemtype' ] }; + // { -desc => $scope3 };
...
# Enforce scope; a rule should be set for its defined scope, no more, no less. - foreach my $scope_level ( qw( branchcode categorycode itemtype ) ) { + foreach my $scope_level ( @$scope3 ) { if ( grep /$scope_level/, @{ $kind_info->{scope} } ) {
so just making pairs rules/scopes won't solve this, more advanced refactoring then needed. Let's think about this, yes (just thinking aloud here too :) ). -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25554 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=25112 -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org