Bug 16672 - Add ability to remove expired holidays from special_holidays
Summary: Add ability to remove expired holidays from special_holidays
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Kyle M Hall
QA Contact: Testopia
URL:
Keywords:
: 13409 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-06-06 13:19 UTC by Kyle M Hall
Modified: 2018-06-04 20:10 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 16672 - Add ability to remove expired holidays from special_holidays (4.19 KB, patch)
2016-06-06 13:55 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 16672 [QA Followup] - Convert negative days to positive days (738 bytes, patch)
2016-06-13 18:27 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 16672 - Add ability to remove expired holidays from special_holidays (4.26 KB, patch)
2016-06-14 09:16 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 16672 [QA Followup] - Convert negative days to positive days (811 bytes, patch)
2016-06-14 09:17 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 16672: Fix typo unqiue vs unique (931 bytes, patch)
2016-06-14 09:17 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle M Hall 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 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 2016-06-13 18:27:20 UTC Comment hidden (obsolete)
Comment 5 Kyle M Hall 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 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. ***