Bugzilla – Attachment 189552 Details for
Bug 20125
Add a cron script to claim late orders
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20125: (QA follow-up) change from SQL query to Koha::Objects
Bug-20125-QA-follow-up-change-from-SQL-query-to-Ko.patch (text/plain), 2.43 KB, created by
Arthur Suzuki
on 2025-11-13 12:39:33 UTC
(
hide
)
Description:
Bug 20125: (QA follow-up) change from SQL query to Koha::Objects
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2025-11-13 12:39:33 UTC
Size:
2.43 KB
patch
obsolete
>From ad0e28cce141a1eb63ea169df947aab475893d3a Mon Sep 17 00:00:00 2001 >From: Arthur Suzuki <arthur.suzuki@biblibre.com> >Date: Thu, 13 Nov 2025 12:36:11 +0000 >Subject: [PATCH] Bug 20125: (QA follow-up) change from SQL query to > Koha::Objects > >--- > misc/cronjobs/ordersClaim.pl | 37 +++++++++++++++++++----------------- > 1 file changed, 20 insertions(+), 17 deletions(-) > >diff --git a/misc/cronjobs/ordersClaim.pl b/misc/cronjobs/ordersClaim.pl >index 280f7a3fba..d010812576 100755 >--- a/misc/cronjobs/ordersClaim.pl >+++ b/misc/cronjobs/ordersClaim.pl >@@ -39,6 +39,7 @@ use Pod::Usage; > > use C4::Letters qw( GetPreparedLetter EnqueueLetter ); > use Koha::Acquisition::Orders; >+use Koha::DateUtils qw( dt_from_string output_pref ); > > =head1 NAME > >@@ -114,23 +115,25 @@ while ( my ( $basketno, $orderids ) = each %$baskets_orders ) { > $delay = $bookseller->deliverytime || 0; > } > >- my $dbh = C4::Context->dbh; >- >- my $orderids_str = join( ',', ('?') x @$orderids ); >- my $orders = $dbh->selectall_arrayref( >- qq{ >- SELECT aqorders.*, aqbasket.*, biblio.*, >- COUNT(aqorders_claims.claimed_on) AS claims_count, >- MAX(aqorders_claims.claimed_on) AS last_claim >- FROM aqorders >- LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber >- LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno >- LEFT JOIN aqorders_claims ON aqorders.ordernumber = aqorders_claims.ordernumber >- WHERE aqorders.ordernumber IN ($orderids_str) >- HAVING claims_count <= $max_claims >- AND (last_claim IS NULL or last_claim <= DATE_SUB(CAST(now() AS date),INTERVAL $claimed_for DAY)) >- }, { Slice => {} }, @$orderids >- ); >+ my $orders = []; >+ my $order_objects = Koha::Acquisition::Orders->search( { ordernumber => { -in => $orderids } } ); >+ while ( my $order = $order_objects->next ) { >+ my $claims_count = $order->claims_count; >+ my $last_claim = dt_from_string( $order->claimed_date ); >+ >+ next if $claims_count > $max_claims; >+ next if $last_claim && $last_claim > dt_from_string->subtract( days => $claimed_for ); >+ >+ my $result = { >+ %{ $order->unblessed }, >+ %{ $order->basket->unblessed }, >+ %{ $order->biblio->unblessed }, >+ claims_count => $claims_count, >+ last_claim => $last_claim, >+ }; >+ >+ push @$orders, $result; >+ } > > next unless @$orders; > >-- >2.39.5
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 20125
:
71139
|
71274
|
74767
|
74837
|
74838
|
74839
|
112977
|
112981
|
185807
| 189552 |
189634
|
189635