Bugzilla – Attachment 176300 Details for
Bug 11530
Recalculating an item's total issue count with update_totalissues.pl ignores deleted items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11530: Add a use-deleted-items option to totalissues.pl
Bug-11530-Add-a-use-deleted-items-option-to-totali.patch (text/plain), 3.30 KB, created by
David Nind
on 2025-01-09 20:07:33 UTC
(
hide
)
Description:
Bug 11530: Add a use-deleted-items option to totalissues.pl
Filename:
MIME Type:
Creator:
David Nind
Created:
2025-01-09 20:07:33 UTC
Size:
3.30 KB
patch
obsolete
>From e3005c94dbf39883357099e8088cf1d1bdef7505 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Sat, 21 Dec 2024 12:55:14 +0000 >Subject: [PATCH] Bug 11530: Add a use-deleted-items option to totalissues.pl > >Some libraries would like to keep the usage from deleted items when calculating >total issues from the items. > >To test: >0 - Apply patch >1 - Checkout/Check in an item several times >2 - perl misc/cronjobs/update_totalissues.pl --use-items >3 - Note the 942$o in the record has the correct count >4 - Delete the item >5 - perl misc/cronjobs/update_totalissues.pl --use-items >6 - Note record count now goes to 0 >8 - perl misc/cronjobs/update_totalissues.pl --use-items --use-deleted-items >9 - Note record count correctly restored > >Signed-off-by: David Nind <david@davidnind.com> >--- > misc/cronjobs/update_totalissues.pl | 38 ++++++++++++++++++----------- > 1 file changed, 24 insertions(+), 14 deletions(-) > >diff --git a/misc/cronjobs/update_totalissues.pl b/misc/cronjobs/update_totalissues.pl >index 10763617d0..56f66dbc21 100755 >--- a/misc/cronjobs/update_totalissues.pl >+++ b/misc/cronjobs/update_totalissues.pl >@@ -46,24 +46,26 @@ my $test_only = 0; > my $want_help = 0; > my $since; > my $interval; >-my $usestats = 0; >-my $useitems = 0; >-my $incremental = 0; >-my $progress = 100; >+my $usestats = 0; >+my $useitems = 0; >+my $include_deleted = 0; >+my $incremental = 0; >+my $progress = 100; > my $unit; > > my $command_line_options = join( " ", @ARGV ); > > my $result = GetOptions( >- 'v|verbose' => \$verbose, >- 't|test' => \$test_only, >- 's|since=s' => \$since, >- 'i|interval=s' => \$interval, >- 'use-stats' => \$usestats, >- 'use-items' => \$useitems, >- 'incremental' => \$incremental, >- 'p|progress=i' => \$progress, >- 'h|help' => \$want_help >+ 'v|verbose' => \$verbose, >+ 't|test' => \$test_only, >+ 's|since=s' => \$since, >+ 'i|interval=s' => \$interval, >+ 'use-stats' => \$usestats, >+ 'use-items' => \$useitems, >+ 'use-deleted-items' => \$include_deleted, >+ 'incremental' => \$incremental, >+ 'p|progress=i' => \$progress, >+ 'h|help' => \$want_help > ); > > binmode( STDOUT, ":encoding(UTF-8)" ); >@@ -109,7 +111,10 @@ cronlogaction( { action => 'End', info => "COMPLETED" } ); > exit 0; > > sub process_items { >- my $query = "SELECT items.biblionumber, SUM(items.issues) FROM items GROUP BY items.biblionumber;"; >+ my $query = >+ $include_deleted >+ ? "SELECT all_items.biblionumber, SUM(all_items.issues) FROM (SELECT items.biblionumber,items.issues FROM items UNION ALL SELECT deleteditems.biblionumber, deleteditems.issues FROM deleteditems) all_items GROUP BY all_items.biblionumber;" >+ : "SELECT items.biblionumber, SUM(items.issues) FROM items GROUP BY items.biblionumber;"; > process_query($query); > } > >@@ -243,6 +248,11 @@ options, by definition. Also note that if both --use-stats and > --use-items are specified, the count of biblios processed will be > misleading. > >+=item B<--use-deleted-items> >+ >+Only applies when using items as above, will include deleted items in the total >+count of issues for the bibliographic records. >+ > =item B<-s|--since=DATE> > > Only process issues recorded in the statistics table since DATE. >-- >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 11530
:
175880
|
175881
| 176300 |
176301