Summary: | [DOCS] Add description and examples to membership_expiry.pl about --where option | ||
---|---|---|---|
Product: | Koha | Reporter: | David Nind <david> |
Component: | Documentation | Assignee: | Marie-Luce Laflamme <marie-luce.laflamme> |
Status: | Needs documenting --- | QA Contact: | Testopia <testopia> |
Severity: | normal | ||
Priority: | P5 - low | CC: | andrew, anke.bruns, bibliothek, marie-luce.laflamme |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
See Also: |
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28456 https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39595 |
||
GIT URL: | Change sponsored?: | --- | |
Patch complexity: | --- | Documentation contact: | David Nind |
Documentation submission: | Text to go in the release notes: | ||
Version(s) released in: | Circulation function: |
Description
David Nind
2022-10-14 09:48:46 UTC
Filtering for categorycode with the where parameter doesn't work: koha-foreach /usr/share/koha/bin/cronjobs/membership_expiry.pl -n -c -v --where="categorycode='STUD'" results in no mails being sent even though there are expiring memberships within the time covered by the cronjob. We tried every combination of single and double quotes we could think of. We also tried the above command with "me.categorycode" instead of categorycode. I've also had a hard time testing the categorycode argument. However, David’s description had the answer in the IRC discussion link. We need to add a "me" before the categorycode, so it should look like this: --where="me.categorycode = 'CODE' " e.g. to run send email only for one category, try: ./misc/cronjobs/membership_expiry.pl -c -v -n --before 100 --after 100 --where="me.categorycode = 'S'" to exclude a category, try: ./misc/cronjobs/membership_expiry.pl -c -where="me.categorycode !='YA'" I've added the info in the manual - merge request pending Yes, we tried the "me" but it didn't help, either. The cron probably doesn't like the dot (.) in the argument. My colleague fix this issue by adding a "\" before and after the argument. For example, our cron to exclude some categories look like this: /misc/cronjobs/membership_expiry.pl -c -where=\"me.categorycode NOT IN ('EM','ADM','SU', 'TA')\" ignore my previous comment 5. The main issue lies with the quotation marks (") in the argument. You need to escape them to ensure that the script is fully read and executed correctly, otherwise the script will only read the first quotation mark and think it ends there. For example, our cron to exclude some categories look like this: /misc/cronjobs/membership_expiry.pl -c -where=\"me.categorycode NOT IN ('EM','ADM','SU', 'TA')\" see https://chat.koha-community.org/koha-community/pl/a17z7r3zaig1ibqy1s74whhudh I tested a little, set one patron (categroycode S) to expire in 2 days, set MembershipExpiryDaysNotice in sysprefs to 2 days and the following call worked: sudo koha-foreach --chdir --enabled /kohadevbox//koha/misc/cronjobs/membership_expiry.pl -c -renew -where='me.categorycode=\"S\"' -v See the missing spaces between categorycode and the escaped S. Somehow the parameter -where gets cut after a space If someone can confirm my previous solution I would update the docs. The following all worked for me: perl misc/cronjobs/membership_expiry.pl -v -letter MEMBERSHIP_EXPIRY -c -where="me.categorycode = 's'" perl misc/cronjobs/membership_expiry.pl -v -letter MEMBERSHIP_EXPIRY -c -where="me.categorycode in ('s','pt')" perl misc/cronjobs/membership_expiry.pl -v -letter MEMBERSHIP_EXPIRY -c -where "me.categorycode in ('s','pt')" I haven't needed to escape any quotation marks, though it did error out when I made mistakes and my quotation marks didn't match up correctly. I guess I just forgot to include the "=" after "where" at first, but apparently it doesn't care? All of the above fail if I leave off the "me." before "categorycode." This also works: perl misc/cronjobs/membership_expiry.pl -v -letter MEMBERSHIP_EXPIRY -c -where 'borrowernumber in (select borrowernumber from borrower_attributes where code="show_bcode" and attribute=0)' No clear idea why that doesn't need a "me." It works with or without it. I ended up here because I was doing a search before filing a bug to create a clearer way to check attributes here. (In reply to Andrew Fuerste-Henry from comment #9) ... > I haven't needed to escape any quotation marks, As I recall the quotation marks were only needed when using koha-foreach (In reply to Jan Kissig from comment #10) > (In reply to Andrew Fuerste-Henry from comment #9) > ... > > I haven't needed to escape any quotation marks, > > As I recall the quotation marks were only needed when using koha-foreach I believe so too. What worked on command line stopped working as soon as it was added to the cronjob. Took a while to understand that. |