Bugzilla – Attachment 150623 Details for
Bug 16122
Item record needs to keep local use count
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16122: Add maintenance script to update items.localuse from stats
Bug-16122-Add-maintenance-script-to-update-itemslo.patch (text/plain), 2.78 KB, created by
Lucas Gass (lukeg)
on 2023-05-03 23:26:54 UTC
(
hide
)
Description:
Bug 16122: Add maintenance script to update items.localuse from stats
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2023-05-03 23:26:54 UTC
Size:
2.78 KB
patch
obsolete
>From d0eb696b7c168dbe33343eb5113a6da3133ad265 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Wed, 3 May 2023 23:24:53 +0000 >Subject: [PATCH] Bug 16122: Add maintenance script to update items.localuse > from stats > >--- > .../update_localuse_from_statistics.pl | 88 +++++++++++++++++++ > 1 file changed, 88 insertions(+) > create mode 100755 misc/maintenance/update_localuse_from_statistics.pl > >diff --git a/misc/maintenance/update_localuse_from_statistics.pl b/misc/maintenance/update_localuse_from_statistics.pl >new file mode 100755 >index 0000000000..b087ca7953 >--- /dev/null >+++ b/misc/maintenance/update_localuse_from_statistics.pl >@@ -0,0 +1,88 @@ >+#!/usr/bin/perl >+# >+# Copyright (C) 2023 ByWater Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use strict; >+use warnings; >+ >+use Koha::Script; >+use C4::Context; >+use Koha::Items; >+use Koha::Statistics; >+use Getopt::Long qw( GetOptions ); >+use Pod::Usage qw( pod2usage ); >+ >+ >+sub usage { >+ pod2usage( -verbose => 2 ); >+ exit; >+} >+ >+sub update_localuse { >+ >+ my $dbh = C4::Context->dbh; >+ >+ my $itemsth = $dbh->prepare("SELECT * FROM items"); >+ $itemsth->execute(); >+ >+ # Loop through each item and update it with statistics info >+ while (my $item = $itemsth->fetchrow_hashref) { >+ my $itemnumber = $item->{'itemnumber'}; >+ >+ # Update the item with statistics info >+ my $item_obj = Koha::Items->find($itemnumber); >+ >+ my $localuse_count = Koha::Statistics->search( { itemnumber => $itemnumber, type => 'localuse' } )->count; >+ $item_obj->localuse( $localuse_count ); >+ $item_obj->store; >+ >+ print "Updated item $itemnumber with localuse statistics info.\n"; >+ } >+} >+ >+my ( $help ); >+my $result = GetOptions( >+ 'help|h' => \$help, >+); >+ >+usage() if $help; >+ >+update_localuse(); >+ >+=head1 NAME >+ >+update_local_use_from_statistics.pl >+ >+=head1 SYNOPSIS >+ >+ update_localuse_from_statistics.pl >+ update_localuse_from_statistics.pl --help >+ >+=head1 DESCRIPTION >+ >+This script updates the items.localuse column with data from the statistics table to make sure the two tables are congruent. >+ >+=over 8 >+ >+=item B<--help> >+ >+Prints this help >+ >+=back >+ >+=cut >-- >2.30.2
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 16122
:
149281
|
149282
|
149283
|
149284
|
150231
|
150232
|
150233
|
150234
|
150235
|
150236
|
150623
|
150693
|
153193
|
153196
|
153197
|
153198
|
153199
|
153200
|
158466
|
158467
|
158468
|
158469
|
158470
|
158471
|
161001
|
161002
|
161003
|
161004
|
161005
|
161006
|
161144
|
161145
|
161146
|
161147
|
161148
|
161149
|
161150
|
161151
|
161153
|
161154
|
161155
|
161156
|
161157
|
161158
|
161159
|
161160
|
163072
|
163073
|
163074
|
163075
|
163076
|
163077
|
163243
|
163244
|
163245
|
163246
|
163247
|
163248
|
163296
|
163297
|
163298
|
163299
|
163300
|
163301
|
163302
|
163303
|
165313
|
165314
|
165315
|
165316
|
165317
|
165318
|
165319
|
165320