Bug 14834: Make membership_expiry cronjob more flexible
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Thu, 17 Sep 2015 08:25:50 +0000 (10:25 +0200)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 29 Apr 2016 16:57:51 +0000 (16:57 +0000)
commit51be8ecd9d7a1d260fd2b1788cb6d54d8da53f31
tree122a5379426fdb50307f1b998723feb898d0ddec
parent8682a9f821a1ed9c3e27efe472dc172233c40a8f
Bug 14834: Make membership_expiry cronjob more flexible

This patch adds three parameters to the cron job: -before and -after, and
-branch.

You can run the cronjob now in an adjusted frequency: say once a week with
before 6 or after 6 (not both together). If your pref is set to 14, running
before=6 will include expiries from 8 days to 14 days ahead. When you
use after=6, you would include 14 days to 20 days ahead, etc.

You could also rerun the job of yesterday by setting before=1 and after=-1;
this could help in case of problem recovery.

Obviously, the branch parameter can be used as a filter.

NOTE: Why are these parameters passed only via the command line?
Well, obviously the branch parameter is not suitable for a pref.
The before/after parameter allows you to handle expiry mails different from
the normal scheme or could be used in some sort of recovery. In those cases
it will be more practical to use a command line parameter than editing a
pref.

NOTE: The unit test has been adjusted for the above reasons, but I also
added some lines to let existing expires not interfere with the added
borrowers by an additional count and using the branchcode parameter.

Test plan:
[1] Run the adjusted unit test GetUpcomingMembershipExpires.t
[2] Set the expiry date for patron A to now+16 (with pref 14).
    Set the expiry date for patron B to now+11.
[3] Run the cronjob without range. You should not see A and B.
[4] Run the cronjob with before 3. You should see patron B.
[5] Run the cronjob with before 3 and after 2. You should see A and B.
[6] Repeat step 5 with a branchcode that does not exist. No patrons.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Work as described following test plan.
Test pass
No errors

New parameters work with one (-) or two(--) dashes, no problem
with that but convention suggest that 'long' options use two-dashes.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/Members.pm
misc/cronjobs/membership_expiry.pl
t/db_dependent/Members/GetUpcomingMembershipExpires.t