Bugzilla – Attachment 107022 Details for
Bug 25723
Improve efficiency of holiday calculation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25723: (QA follow-up) Handle holiday and exception on same day
Bug-25723-QA-follow-up-Handle-holiday-and-exceptio.patch (text/plain), 3.84 KB, created by
Joonas Kylmälä
on 2020-07-17 14:42:50 UTC
(
hide
)
Description:
Bug 25723: (QA follow-up) Handle holiday and exception on same day
Filename:
MIME Type:
Creator:
Joonas Kylmälä
Created:
2020-07-17 14:42:50 UTC
Size:
3.84 KB
patch
obsolete
>From ac8b4cd3d0e5820c9cb6686d5c564b8284bcb653 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 17 Jul 2020 12:34:18 +0000 >Subject: [PATCH] Bug 25723: (QA follow-up) Handle holiday and exception on > same day >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >When a holiday is entered, then exceptions generated on a range, there exists both a holiday and exception in >the special holidays table. We should cache the exception over the holiday instead of both > >Also, !1 in perl returns '' rather than 0, so we should explicitly set the value > >Add blank line to clear pod error from qa tools > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Re-introduce the blank line mentioned in the commit message, it was accidentally removed by automatic formatting >Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi> >--- > C4/Calendar.pm | 1 + > Koha/Calendar.pm | 5 ++--- > t/Calendar.t | 11 ++++++++++- > 3 files changed, 13 insertions(+), 4 deletions(-) > >diff --git a/C4/Calendar.pm b/C4/Calendar.pm >index 7b94537ccf..6a5d8a79a4 100644 >--- a/C4/Calendar.pm >+++ b/C4/Calendar.pm >@@ -733,3 +733,4 @@ __END__ > Koha Physics Library UNLP <matias_veleda@hotmail.com> > > =cut >+ >diff --git a/Koha/Calendar.pm b/Koha/Calendar.pm >index c0dcd8e93d..c3210d469d 100644 >--- a/Koha/Calendar.pm >+++ b/Koha/Calendar.pm >@@ -71,7 +71,7 @@ sub _holidays { > > # Add holidays for each branch > my $holidays_sth = $dbh->prepare( >-'SELECT day, month, year, isexception FROM special_holidays WHERE branchcode = ?' >+'SELECT day, month, year, MAX(isexception) FROM special_holidays WHERE branchcode = ? GROUP BY day, month, year' > ); > $holidays_sth->execute($self->{branchcode}); > >@@ -83,11 +83,10 @@ sub _holidays { > . sprintf( "%02d", $month ) > . sprintf( "%02d", $day ); > >- $holidays->{$datestring} = !$exception; >+ $holidays->{$datestring} = $exception ? 0 : 1; > } > $cache->set_in_cache( $key, $holidays, { expiry => 76800 } ); > } >- > return $holidays // {}; > } > >diff --git a/t/Calendar.t b/t/Calendar.t >index 8657bc4999..b4b94bf9c3 100755 >--- a/t/Calendar.t >+++ b/t/Calendar.t >@@ -31,7 +31,7 @@ use Module::Load::Conditional qw/check_install/; > > BEGIN { > if ( check_install( module => 'Test::DBIx::Class' ) ) { >- plan tests => 39; >+ plan tests => 40; > } else { > plan skip_all => "Need Test::DBIx::Class" > } >@@ -73,6 +73,8 @@ fixtures_ok [ > [ 'MPL', 1, 6, 2011, '', '', 0 ], > [ 'MPL', 4, 7, 2012, '', '', 0 ], > [ 'CPL', 6, 8, 2012, '', '', 0 ], >+ [ 'MPL', 7, 7, 2012, '', '', 1 ], # holiday exception >+ [ 'MPL', 7, 7, 2012, '', '', 0 ], # holiday > ], > ], "add fixtures"; > >@@ -139,6 +141,12 @@ my $holiday_for_another_branch = DateTime->new( > day => 6, # This is a monday > ); > >+my $holiday_excepted = DateTime->new( >+ year => 2012, >+ month => 7, >+ day => 7, # Both a holiday and exception >+); >+ > { # Syspref-agnostic tests > is ( $saturday->day_of_week, 6, '\'$saturday\' is actually a saturday (6th day of week)'); > is ( $sunday->day_of_week, 7, '\'$sunday\' is actually a sunday (7th day of week)'); >@@ -151,6 +159,7 @@ my $holiday_for_another_branch = DateTime->new( > is ( $cal->is_holiday($notspecial), 0, 'Fixed single date that is not a holiday test' ); > is ( $cal->is_holiday($sunday_exception), 0, 'Exception holiday is not a closed day test' ); > is ( $cal->is_holiday($holiday_for_another_branch), 0, 'Holiday defined for another branch should not be defined as an holiday' ); >+ is ( $cal->is_holiday($holiday_excepted), 0, 'Holiday defined and excepted should not be a holiday' ); > } > > { # Bugzilla #8966 - is_holiday truncates referenced date >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25723
:
105789
|
105792
|
105793
|
105830
|
105831
|
105832
|
105833
|
105834
|
105835
|
105836
|
105936
|
105937
|
105939
|
105941
|
105947
|
105954
|
105955
|
105956
|
105957
|
105958
|
105959
|
105960
|
105961
|
105962
|
105963
|
105964
|
105965
|
105966
|
105967
|
105968
|
105969
|
105970
|
106991
|
106992
|
106993
|
106994
|
106995
|
106996
|
106997
|
106998
|
106999
|
107000
|
107001
|
107002
|
107003
|
107004
|
107005
|
107006
|
107007
|
107008
|
107009
|
107010
|
107013
|
107014
|
107015
|
107016
|
107017
|
107018
|
107019
|
107020
|
107021
| 107022 |
107023
|
107025