Bugzilla – Attachment 137226 Details for
Bug 17015
New Koha Calendar
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17015: Rebase and tests for discrete calendar
Bug-17015-Rebase-and-tests-for-discrete-calendar.patch (text/plain), 9.50 KB, created by
Shi Yao Wang
on 2022-07-06 15:24:24 UTC
(
hide
)
Description:
Bug 17015: Rebase and tests for discrete calendar
Filename:
MIME Type:
Creator:
Shi Yao Wang
Created:
2022-07-06 15:24:24 UTC
Size:
9.50 KB
patch
obsolete
>From 0cd076bef8dafe413df8a16c5e4af447867ba936 Mon Sep 17 00:00:00 2001 >From: The Minh Luong <theminh@inlibro.com> >Date: Thu, 10 Mar 2022 10:14:21 -0500 >Subject: [PATCH] Bug 17015: Rebase and tests for discrete calendar > >This patch is a rebase of all the previous patches in order to show the discrete calendar. > >TEST PLAN: >1- Apply the patch >2- Run installer/data/mysql/updatedatabase.pl >3- Run misc/cronjobs/add_days_discrete_calendar.pl >4- Check that the max date is today + 1 day >5- Run t/db_dependent/DiscreteCalendar.t (All tests should pass) > >Signed-off-by: Michal Denar <black23@gmail.com> >--- > C4/Overdues.pm | 1 - > Koha/DiscreteCalendar.pm | 5 ++- > misc/cronjobs/add_days_discrete_calendar.pl | 4 +-- > misc/cronjobs/holds/holds_reminder.pl | 4 +-- > misc/cronjobs/staticfines.pl | 1 - > t/db_dependent/DiscreteCalendar.t | 34 ++++++++++----------- > tools/discrete_calendar.pl | 6 ++-- > 7 files changed, 26 insertions(+), 29 deletions(-) > >diff --git a/C4/Overdues.pm b/C4/Overdues.pm >index 42b4ba5844..ecb2e472de 100644 >--- a/C4/Overdues.pm >+++ b/C4/Overdues.pm >@@ -30,7 +30,6 @@ use Carp qw( carp ); > use C4::Accounts; > use C4::Context; > use C4::Log; # logaction >-use C4::Debug; > use Koha::DateUtils; > use Koha::DiscreteCalendar; > use Koha::Account::Lines; >diff --git a/Koha/DiscreteCalendar.pm b/Koha/DiscreteCalendar.pm >index f80916305b..17c633eab9 100644 >--- a/Koha/DiscreteCalendar.pm >+++ b/Koha/DiscreteCalendar.pm >@@ -27,7 +27,7 @@ use Data::Dumper; > use C4::Context; > use C4::Output; > use Koha::Database; >-use Koha::DateUtils; >+use Koha::DateUtils qw ( dt_from_string output_pref ); > > # Global variables to make code more readable > our $HOLIDAYS = { >@@ -502,9 +502,8 @@ sub get_week_days_holidays { > branchcode => $branchcode, > }, > { >- select => [{ DAYOFWEEK => 'date'}, 'note'], >+ select => \[ 'distinct DAYOFWEEK(date), note'], > as => [qw/ weekday note /], >- distinct => 1, > where => ($exclude_past ? \[' date >= CURRENT_DATE()'] : {} ), > } > ); >diff --git a/misc/cronjobs/add_days_discrete_calendar.pl b/misc/cronjobs/add_days_discrete_calendar.pl >index 327c35c315..1c146ce44d 100755 >--- a/misc/cronjobs/add_days_discrete_calendar.pl >+++ b/misc/cronjobs/add_days_discrete_calendar.pl >@@ -11,7 +11,7 @@ use Getopt::Long; > use C4::Context; > use Koha::Database; > use Koha::DiscreteCalendar; >-use Koha::DateUtils; >+use Koha::DateUtils qw ( output_pref ); > > # Options > my $help = 0; >@@ -162,4 +162,4 @@ foreach my $branchCode (@branches) { > } > } > # If everything went well we commit to the database >-$schema->storage->txn_commit; >\ No newline at end of file >+$schema->storage->txn_commit; >diff --git a/misc/cronjobs/holds/holds_reminder.pl b/misc/cronjobs/holds/holds_reminder.pl >index b99259f43d..8c8ad780ce 100755 >--- a/misc/cronjobs/holds/holds_reminder.pl >+++ b/misc/cronjobs/holds/holds_reminder.pl >@@ -26,7 +26,7 @@ use C4::Context; > use C4::Letters; > use C4::Log qw( cronlogaction ); > use Koha::DateUtils qw( dt_from_string ); >-use Koha::Calendar; >+use Koha::DiscreteCalendar; > use Koha::Libraries; > use Koha::Notice::Templates; > use Koha::Patrons; >@@ -246,7 +246,7 @@ foreach my $branchcode (@branchcodes) { #BEGIN BRANCH LOOP > # If respecting calendar get the correct waiting since date > my $waiting_date; > if( $use_calendar ){ >- my $calendar = Koha::Calendar->new( branchcode => $branchcode, days_mode => 'Calendar' ); >+ my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode, days_mode => 'Calendar' ); > my $duration = DateTime::Duration->new( days => -$days ); > $waiting_date = $calendar->addDays($date_to_run,$duration); #Add negative of days > } else { >diff --git a/misc/cronjobs/staticfines.pl b/misc/cronjobs/staticfines.pl >index 77e7741eb2..d162a65366 100755 >--- a/misc/cronjobs/staticfines.pl >+++ b/misc/cronjobs/staticfines.pl >@@ -39,7 +39,6 @@ use Koha::DateUtils qw( dt_from_string output_pref ); > use C4::Circulation; > use Koha::DiscreteCalendar qw(); # don't need any exports from Calendar > use C4::Biblio; >-use C4::Debug; # supplying $debug and $cgi_debug > use Koha::Patrons; > > my $help = 0; >diff --git a/t/db_dependent/DiscreteCalendar.t b/t/db_dependent/DiscreteCalendar.t >index 7bf12a31a4..1b245b8c4f 100755 >--- a/t/db_dependent/DiscreteCalendar.t >+++ b/t/db_dependent/DiscreteCalendar.t >@@ -23,7 +23,7 @@ use Test::MockModule; > > use C4::Context; > use C4::Output; >-use Koha::DateUtils; >+use Koha::DateUtils qw ( dt_from_string ); > use Koha::DiscreteCalendar; > > >@@ -127,7 +127,7 @@ $calendar->edit_holiday({ > end_date=>$unique_holiday_range_end > }); > @unique_holidays = $calendar->get_unique_holidays(); >-is(scalar @unique_holidays, 8, "Set of exception holidays at 7"); >+is(scalar @unique_holidays, 7, "Set of exception holidays at 7"); > > my $repeatable_holiday_range_start = DateTime->today->add(days => 8); > my $repeatable_holiday_range_end = DateTime->today->add(days => 13); >@@ -281,15 +281,15 @@ $calendar->edit_holiday({ > end_date=>$tomorrow > }); > >-is($calendar->addDate( $today, $one_day_dur, 'days' )->ymd(), >+is($calendar->addDuration( $today, $one_day_dur, 'days' )->ymd(), > $today->add(days => 2)->ymd(), > 'Single day add (Calendar)' ); > >-is($calendar->addDate( $today, $two_day_dur, 'days' )->ymd(), >+is($calendar->addDuration( $today, $two_day_dur, 'days' )->ymd(), > $today->add(days => 2)->ymd(), > 'Two days add, skips holiday (Calendar)' ); > >-cmp_ok($calendar->addDate( $today, $seven_day_dur, 'days' )->ymd(), 'eq', >+cmp_ok($calendar->addDuration( $today, $seven_day_dur, 'days' )->ymd(), 'eq', > $today->add(days => 7)->ymd(), > 'Add 7 days (Calendar)' ); > #Closed Sunday >@@ -300,7 +300,7 @@ $calendar->edit_holiday({ > start_date=>$today, > end_date=>$today > }); >-is( $calendar->addDate( $sunday, $one_day_dur, 'days' )->day_of_week, 1, >+is( $calendar->addDuration( $sunday, $one_day_dur, 'days' )->day_of_week, 1, > 'addDate skips closed Sunday (Calendar)' ); > #to remove the closed sundays > $today = DateTime->today; >@@ -311,7 +311,7 @@ $calendar->edit_holiday({ > end_date=>$delete_range_end > }); > >-is( $calendar->addDate($today, $negative_one_day_dur , 'days')->ymd(), >+is( $calendar->addDuration($today, $negative_one_day_dur , 'days')->ymd(), > $today->add(days => - 1)->ymd(), > 'Negative call to addDate (Calendar)' ); > >@@ -332,15 +332,15 @@ $calendar->edit_holiday({ > end_date=>$tomorrow > }); > >-is($calendar->addDate( $today, $one_day_dur, 'days' )->ymd(), >+is($calendar->addDuration( $today, $one_day_dur, 'days' )->ymd(), > $today->add(days => 2)->ymd(), > 'Single day add' ); > >-is($calendar->addDate( $today, $two_day_dur, 'days' )->ymd(), >+is($calendar->addDuration( $today, $two_day_dur, 'days' )->ymd(), > $today->add(days => 2)->ymd(), > 'Two days add, skips holiday (Datedue)' ); > >-cmp_ok($calendar->addDate( $today, $seven_day_dur, 'days' )->ymd(), 'eq', >+cmp_ok($calendar->addDuration( $today, $seven_day_dur, 'days' )->ymd(), 'eq', > $today->add(days => 7)->ymd(), > 'Add 7 days (Datedue)' ); > #Closed Sunday >@@ -351,7 +351,7 @@ $calendar->edit_holiday({ > start_date=>$today, > end_date=>$today > }); >-is( $calendar->addDate( $sunday, $one_day_dur, 'days' )->day_of_week, 1, >+is( $calendar->addDuration( $sunday, $one_day_dur, 'days' )->day_of_week, 1, > 'addDate skips closed Sunday (Datedue)' ); > #to remove the closed sundays > $today = DateTime->today; >@@ -362,7 +362,7 @@ $calendar->edit_holiday({ > end_date=>$delete_range_end > }); > >-is( $calendar->addDate($today, $negative_one_day_dur , 'days')->ymd(), >+is( $calendar->addDuration($today, $negative_one_day_dur , 'days')->ymd(), > $today->add(days => - 1)->ymd(), > 'Negative call to addDate (Datedue)' ); > >@@ -382,15 +382,15 @@ $calendar->edit_holiday({ > start_date=>$tomorrow, > end_date=>$tomorrow > }); >-is($calendar->addDate( $today, $one_day_dur, 'days' )->ymd(), >+is($calendar->addDuration( $today, $one_day_dur, 'days' )->ymd(), > $today->add(days => 1)->ymd(), > 'Single day add' ); > >-is($calendar->addDate( $today, $two_day_dur, 'days' )->ymd(), >+is($calendar->addDuration( $today, $two_day_dur, 'days' )->ymd(), > $today->add(days => 2)->ymd(), > 'Two days add, skips holiday (Days)' ); > >-cmp_ok($calendar->addDate( $today, $seven_day_dur, 'days' )->ymd(), 'eq', >+cmp_ok($calendar->addDuration( $today, $seven_day_dur, 'days' )->ymd(), 'eq', > $today->add(days => 7)->ymd(), > 'Add 7 days (Days)' ); > #Closed Sunday >@@ -401,10 +401,10 @@ $calendar->edit_holiday({ > start_date => $today, > end_date => $today > }); >-is( $calendar->addDate( $sunday, $one_day_dur, 'days' )->day_of_week, 1, >+is( $calendar->addDuration( $sunday, $one_day_dur, 'days' )->day_of_week, 1, > 'addDate skips closed Sunday (Days)' ); > >-is( $calendar->addDate($today, $negative_one_day_dur , 'days')->ymd(), >+is( $calendar->addDuration($today, $negative_one_day_dur , 'days')->ymd(), > $today->add(days => - 1)->ymd(), > 'Negative call to addDate (Days)' ); > >diff --git a/tools/discrete_calendar.pl b/tools/discrete_calendar.pl >index 1adf19b72e..f5c740e919 100755 >--- a/tools/discrete_calendar.pl >+++ b/tools/discrete_calendar.pl >@@ -20,10 +20,10 @@ use Modern::Perl; > > use CGI qw ( -utf8 ); > >-use C4::Auth; >-use C4::Output; >+use C4::Auth qw ( get_template_and_user ); >+use C4::Output qw ( output_html_with_http_headers ); > >-use Koha::DateUtils; >+use Koha::DateUtils qw ( dt_from_string output_pref ); > use Koha::DiscreteCalendar; > > my $input = CGI->new; >-- >2.25.1
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 17015
:
53859
|
54318
|
54419
|
59166
|
59167
|
59168
|
59169
|
59170
|
59171
|
59267
|
59268
|
59269
|
59270
|
59271
|
59463
|
59516
|
59517
|
59518
|
59519
|
59520
|
59561
|
59562
|
59586
|
59587
|
59888
|
59889
|
60902
|
60903
|
60904
|
60905
|
60906
|
60986
|
61737
|
62375
|
62376
|
62380
|
63257
|
63282
|
63362
|
63363
|
63364
|
63365
|
63366
|
63367
|
64235
|
65073
|
65074
|
65075
|
65076
|
65077
|
67721
|
67722
|
67723
|
67724
|
67725
|
67879
|
67929
|
67930
|
67931
|
67932
|
67933
|
67934
|
68392
|
68393
|
68394
|
68395
|
68396
|
68397
|
71634
|
71635
|
71636
|
71637
|
71638
|
72890
|
73145
|
74859
|
74860
|
74861
|
74862
|
74863
|
74864
|
74865
|
74866
|
75444
|
75479
|
76594
|
77249
|
77250
|
77607
|
77608
|
77609
|
77610
|
77611
|
77612
|
77613
|
77770
|
77771
|
77772
|
77773
|
77774
|
79035
|
80523
|
80524
|
80525
|
80526
|
80527
|
80528
|
80529
|
80530
|
80531
|
80532
|
80533
|
80534
|
80535
|
83547
|
85394
|
85677
|
85678
|
85679
|
85680
|
85681
|
85682
|
85683
|
85684
|
85685
|
85686
|
85687
|
85688
|
85689
|
85690
|
85691
|
92595
|
92596
|
92597
|
92598
|
100079
|
110383
|
110384
|
110386
|
110387
|
110388
|
110389
|
113541
|
113905
|
115501
|
115502
|
115503
|
115504
|
115505
|
115506
|
115507
|
115508
|
115509
|
115510
|
115511
|
118554
|
118555
|
118556
|
118557
|
118558
|
118559
|
119095
|
119097
|
119099
|
119100
|
119101
|
119102
|
131619
|
131620
|
131621
|
131622
|
131623
|
131624
|
131625
|
131626
|
131634
|
131635
|
131636
|
131637
|
131638
|
131639
|
131640
|
131641
|
131667
|
132199
|
133596
|
133597
|
133598
|
133599
|
133600
|
133601
|
133602
|
133603
|
133604
|
133605
|
133678
|
137219
|
137220
|
137221
|
137222
|
137223
|
137224
|
137225
|
137226
|
137227
|
137228
|
137229
|
139378
|
139379
|
139380
|
139381
|
139382
|
139599
|
139600
|
139601
|
139602
|
139603
|
139851
|
140150
|
141176
|
144257
|
144258
|
144259
|
144260
|
144261
|
144262
|
144264
|
144268
|
144269
|
144270
|
144271
|
144272
|
144273
|
151438
|
151439
|
151440
|
151441
|
151442
|
151443
|
151444
|
151445
|
151446
|
151447
|
151448
|
151449
|
151450
|
156340
|
156341
|
156342
|
156343
|
156344
|
156345
|
156346
|
156347
|
156348
|
156349
|
156350
|
156351
|
156352
|
156353
|
156354
|
156355
|
157656
|
157657
|
157658
|
157659
|
157660
|
157661
|
157662
|
157663
|
157664
|
157665
|
157666
|
157667
|
157668
|
157669
|
157670
|
157671
|
157672
|
167805
|
167806
|
167807
|
167808
|
167809