Bugzilla – Attachment 136603 Details for
Bug 30650
Add a curbside pickup module
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30650: Add filter_by_scheduled_today
Bug-30650-Add-filterbyscheduledtoday.patch (text/plain), 5.31 KB, created by
Jonathan Druart
on 2022-06-27 13:26:30 UTC
(
hide
)
Description:
Bug 30650: Add filter_by_scheduled_today
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-06-27 13:26:30 UTC
Size:
5.31 KB
patch
obsolete
>From 66b1510a63e373bd55a9a6eeba9f02f995ea9b00 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 10 May 2022 10:42:51 +0200 >Subject: [PATCH] Bug 30650: Add filter_by_scheduled_today > >A bit of cleaning > >Sponsored-by: Association KohaLa - https://koha-fr.org/ >--- > Koha/CurbsidePickup.pm | 3 +-- > Koha/CurbsidePickups.pm | 12 ++++++++++++ > circ/curbside_pickups.pl | 8 +++----- > mainpage.pl | 3 +-- > opac/opac-curbside-pickups.pl | 9 +++------ > t/db_dependent/Koha/CurbsidePickups.t | 6 +++++- > 6 files changed, 25 insertions(+), 16 deletions(-) > >diff --git a/Koha/CurbsidePickup.pm b/Koha/CurbsidePickup.pm >index c82c7fa3148..703a11be4f3 100644 >--- a/Koha/CurbsidePickup.pm >+++ b/Koha/CurbsidePickup.pm >@@ -68,9 +68,8 @@ sub new { > branchcode => $params->{branchcode}, > borrowernumber => $params->{borrowernumber}, > delivered_datetime => undef, >- scheduled_pickup_datetime => { '>' => \'DATE(NOW())' }, > } >- ); >+ )->filter_by_scheduled_today; > Koha::Exceptions::CubsidePickup::TooManyPickups->throw( > branchcode => $params->{branchcode}, > borrowernumber => $params->{borrowernumber} >diff --git a/Koha/CurbsidePickups.pm b/Koha/CurbsidePickups.pm >index b30b003b3cb..97eaa8faef1 100644 >--- a/Koha/CurbsidePickups.pm >+++ b/Koha/CurbsidePickups.pm >@@ -20,6 +20,7 @@ use Modern::Perl; > use Carp; > > use Koha::Database; >+use Koha::DateUtils qw( dt_from_string ); > > use Koha::CurbsidePickup; > >@@ -82,6 +83,17 @@ sub filter_by_delivered { > return $self->search( { delivered_datetime => { -not => undef } } ); > } > >+=head3 filter_by_scheduled_today >+ >+Filter by pickups that are scheduled today >+ >+=cut >+sub filter_by_scheduled_today { >+ my ($self) = @_; >+ my $dtf = Koha::Database->new->schema->storage->datetime_parser; >+ return $self->search( { scheduled_pickup_datetime => { '>' => $dtf->format_date(dt_from_string) } } ); >+} >+ > =head2 Internal Methods > > =cut >diff --git a/circ/curbside_pickups.pl b/circ/curbside_pickups.pl >index 8fdc150ee14..a849f8f938d 100755 >--- a/circ/curbside_pickups.pl >+++ b/circ/curbside_pickups.pl >@@ -61,9 +61,8 @@ if ( $op eq 'find-patron' ) { > branchcode => $branchcode, > borrowernumber => $patron->id, > delivered_datetime => undef, >- scheduled_pickup_datetime => { '>' => \'DATE(NOW())' }, > } >- ); >+ )->filter_by_scheduled_today; > } else { > push @messages, { > type => 'error', >@@ -143,10 +142,9 @@ $template->param( > policy => Koha::CurbsidePickupPolicies->find({ branchcode => $branchcode }), > curbside_pickups => Koha::CurbsidePickups->search( > { >- branchcode => $branchcode, >- scheduled_pickup_datetime => { '>' => \'DATE(NOW())' }, >+ branchcode => $branchcode, > } >- ), >+ )->filter_by_scheduled_today, > ); > > >diff --git a/mainpage.pl b/mainpage.pl >index b34a46d8ed4..f5872e65bbb 100755 >--- a/mainpage.pl >+++ b/mainpage.pl >@@ -114,9 +114,8 @@ if ( C4::Context->preference('CurbsidePickup') ) { > new_curbside_pickups => Koha::CurbsidePickups->search( > { > branchcode => $homebranch, >- scheduled_pickup_datetime => { '>' => \'DATE(NOW())' }, > } >- )->filter_by_to_be_staged >+ )->filter_by_to_be_staged->filter_by_scheduled_today, > ); > } > >diff --git a/opac/opac-curbside-pickups.pl b/opac/opac-curbside-pickups.pl >index 2a8a1ab64a0..7e32a027294 100755 >--- a/opac/opac-curbside-pickups.pl >+++ b/opac/opac-curbside-pickups.pl >@@ -108,20 +108,17 @@ $template->param( > patron_curbside_pickups => Koha::CurbsidePickups->search( > { > borrowernumber => $logged_in_patron->borrowernumber, >- scheduled_pickup_datetime => { '>' => \'DATE(NOW())' }, > }, > { > order_by => { -asc => 'scheduled_pickup_datetime' } > } >- ), >+ )->filter_by_scheduled_today, > curbside_pickups => Koha::CurbsidePickups->search( >- { >- scheduled_pickup_datetime => { '>' => \'DATE(NOW())' }, >- }, >+ {}, > { > order_by => { -asc => 'scheduled_pickup_datetime' } > } >- ), >+ )->filter_by_scheduled_today, > ); > > output_html_with_http_headers $input, $cookie, $template->output, undef, >diff --git a/t/db_dependent/Koha/CurbsidePickups.t b/t/db_dependent/Koha/CurbsidePickups.t >index bb8adcdd2ac..db66d81f89e 100755 >--- a/t/db_dependent/Koha/CurbsidePickups.t >+++ b/t/db_dependent/Koha/CurbsidePickups.t >@@ -147,7 +147,7 @@ subtest 'Create a pickup' => sub { > }; > > subtest 'workflow' => sub { >- plan tests => 9; >+ plan tests => 11; > > my $pickups = > Koha::CurbsidePickups->search( { branchcode => $library->branchcode } ); >@@ -184,6 +184,10 @@ subtest 'workflow' => sub { > is( $cp->status, 'delivered' ); > is( $pickups->filter_by_delivered->count, 1 ); > >+ is( $pickups->filter_by_scheduled_today->count, 1 ); >+ $cp->scheduled_pickup_datetime($today->clone->subtract(days => 1))->store; >+ is( $pickups->filter_by_scheduled_today->count, 0 ); >+ > $cp->delete; > }; > >-- >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 30650
:
136584
|
136585
|
136586
|
136587
|
136588
|
136589
|
136590
|
136591
|
136592
|
136593
|
136594
|
136595
|
136596
|
136597
|
136598
|
136599
|
136600
|
136601
|
136602
|
136603
|
136604
|
136605
|
136606
|
136607
|
136608
|
136609
|
136610
|
137095
|
137100
|
137199
|
137211
|
137212
|
137277
|
137278
|
137279
|
137280
|
137281
|
137282
|
137283
|
137284
|
137285
|
137286
|
137287
|
137288
|
137289
|
137290
|
137291
|
137292
|
137293
|
137294
|
137295
|
137296
|
137297
|
137298
|
137299
|
137300
|
137301
|
137302
|
137303
|
137304
|
137305
|
137306
|
137307
|
138261
|
138262
|
138263
|
138264
|
138265
|
138266
|
138267
|
138268
|
138269
|
138270
|
138271
|
138272
|
138273
|
138274
|
138275
|
138276
|
138277
|
138278
|
138279
|
138280
|
138281
|
138282
|
138283
|
138284
|
138285
|
138286
|
138287
|
138288
|
138289
|
138290
|
138291
|
138292
|
138319
|
138320
|
138321
|
138322
|
138323
|
138324
|
138325
|
138330
|
138331
|
138332
|
138333
|
138334
|
138335
|
138336
|
138337
|
138338
|
138339
|
138340
|
138341
|
138342
|
138343
|
138344
|
138345
|
138346
|
138347
|
138348
|
138349
|
138350
|
138351
|
138352
|
138353
|
138354
|
138355
|
138356
|
138357
|
138358
|
138359
|
138360
|
138361
|
138362
|
138363
|
138364
|
138365
|
138366
|
138367
|
138368
|
138369
|
138375
|
138401
|
138610