Bug 16672

Summary: Add ability to remove expired holidays from special_holidays
Product: Koha Reporter: Kyle M Hall (khall) <kyle>
Component: Architecture, internals, and plumbingAssignee: Kyle M Hall (khall) <kyle>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: florent.mara, fridolin.somers, jonathan.druart
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 16672 - Add ability to remove expired holidays from special_holidays
Bug 16672 [QA Followup] - Convert negative days to positive days
Bug 16672 - Add ability to remove expired holidays from special_holidays
Bug 16672 [QA Followup] - Convert negative days to positive days
Bug 16672: Fix typo unqiue vs unique

Description Kyle M Hall (khall) 2016-06-06 13:19:32 UTC
It would be very helpful if the cleanup_database.pl script had the ability to delete holidays from the special_holidays table there were older than a given number of days in the past.
Comment 1 Kyle M Hall (khall) 2016-06-06 13:55:14 UTC Comment hidden (obsolete)
Comment 2 Florent Mara 2016-06-07 01:38:25 UTC
Inserted 3 entries using the following on June 7th 2016:
INSERT INTO special_holidays(branchcode, day, month, year, isexception, description) VALUES
('FFL', 1, 6, 2016, 1, 'description1'), 
('FFL', 2, 6, 2016, 1, 'description2'), 
('FFL', 3, 6, 2016, 1, 'description3');

Ran cleanup_database using the new switch:
# perl misc/cronjobs/cleanup_database.pl --unique-holidays 5

Only 2 entries were remaining in table `special_holidays`.

Then ran the same switch with the verbose flag
# perl misc/cronjobs/cleanup_database.pl --unique-holidays 4 --verbose
Removed 1 unqiue holidays

One entry was left in table `special_holidays`.
This patch works as expected.
Comment 3 Jonathan Druart 2016-06-13 17:41:54 UTC
The script accepts negative numbers, is it expected?
Comment 4 Kyle M Hall (khall) 2016-06-13 18:27:20 UTC Comment hidden (obsolete)
Comment 5 Kyle M Hall (khall) 2016-06-13 18:28:53 UTC
(In reply to Jonathan Druart from comment #3)
> The script accepts negative numbers, is it expected?

That seems like inadvisable behavior. I can't imagine needing to automatically delete holidays in the future! I can imagine the thought process of thinking about days in the past as a negative number. I've added a following that simply makes it so a days of 20 or -20 would both remove holidays older than 20 days in the past.
Comment 6 Jonathan Druart 2016-06-14 09:16:45 UTC
Created attachment 52353 [details] [review]
Bug 16672 - Add ability to remove expired holidays from special_holidays

It would be very helpful if the cleanup_database.pl script had the
ability to delete holidays from the special_holidays table there were
older than a given number of days in the past.

Test Plan:
1) Apply this patch
2) Create some unique holidays in the past of varying ages
3) Test the new switch '--unique-holidays DAYS' for cleanup_database.pl
4) Verify only holidays older then the specified number of days are removed

NOTE: The language 'unique holdays' is used in the interface to match
      it's use in the staff web interface.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 7 Jonathan Druart 2016-06-14 09:17:06 UTC
Created attachment 52354 [details] [review]
Bug 16672 [QA Followup] - Convert negative days to positive days

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 8 Jonathan Druart 2016-06-14 09:17:13 UTC
Created attachment 52355 [details] [review]
Bug 16672: Fix typo unqiue vs unique

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 9 Kyle M Hall (khall) 2016-06-17 15:46:29 UTC
Pushed to master for Koha 16.11, thanks for the followup Jonathan!
Comment 10 Fridolin Somers 2017-07-25 14:32:33 UTC
*** Bug 13409 has been marked as a duplicate of this bug. ***