Bugzilla – Attachment 3585 Details for
Bug 6025
Script to recreate entries in the statistics table from the issues and oldissues table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed Patch
0001-Bug-6025-MT2889-Adds-a-script-that-re-create-missing.patch (text/plain), 3.18 KB, created by
Chris Cormack
on 2011-03-31 20:31:55 UTC
(
hide
)
Description:
Proposed Patch
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2011-03-31 20:31:55 UTC
Size:
3.18 KB
patch
obsolete
>From cba2d84dca1b54f0bf48ae93e793a7aac04f8cbc Mon Sep 17 00:00:00 2001 >From: Matthias Meusburger <matthias.meusburger@biblibre.com> >Date: Tue, 25 May 2010 15:36:36 +0200 >Subject: [PATCH] Bug 6025 : MT2889: Adds a script that re-create missing statistics from issues and old_issues tables > >--- > misc/recreateIssueStatistics.pl | 71 +++++++++++++++++++++++++++++++++++++++ > 1 files changed, 71 insertions(+), 0 deletions(-) > create mode 100644 misc/recreateIssueStatistics.pl > >diff --git a/misc/recreateIssueStatistics.pl b/misc/recreateIssueStatistics.pl >new file mode 100644 >index 0000000..a87d25b >--- /dev/null >+++ b/misc/recreateIssueStatistics.pl >@@ -0,0 +1,71 @@ >+#!/usr/bin/perl >+ >+# Copyright Biblibre 2010 >+ >+# 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 2 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, write to the Free Software Foundation, Inc., 59 Temple Place, >+# Suite 330, Boston, MA 02111-1307 USA >+# >+ >+# Re-create statistics from issues and old_issues tables >+# (please note that this is not an accurate process) >+ >+# If the issue is still in the issues table, we can re-create issues or renewals >+# If the issue is already in the old_issues table, we can re-create returns >+ >+use strict; >+use warnings; >+use C4::Context; >+use C4::Items; >+use Data::Dumper; >+ >+my $dbh = C4::Context->dbh; >+ >+foreach my $table ('issues', 'old_issues') { >+ >+ print "looking for missing statistics from the $table table\n"; >+ >+ my $query = "SELECT * from $table where itemnumber is not null"; >+ >+ my $sth = $dbh->prepare($query); >+ $sth->execute; >+ while (my $hashref = $sth->fetchrow_hashref) { >+ >+ my $ctnquery = "SELECT count(*) as cnt FROM statistics WHERE borrowernumber = ? AND itemnumber = ? AND datetime = ?"; >+ my $substh = $dbh->prepare($ctnquery); >+ $substh->execute($hashref->{'borrowernumber'}, $hashref->{'itemnumber'}, $hashref->{'timestamp'}); >+ my $count = $substh->fetchrow_hashref->{'cnt'}; >+ if ($count == 0) { >+ my $insert = "INSERT INTO statistics (datetime, branch, value, type, other, itemnumber, itemtype, borrowernumber) >+ VALUES(?, ?, ?, ?, ?, ?, ?, ?)"; >+ $substh = $dbh->prepare($insert); >+ >+ my $type = ($table eq 'old_issues') ? 'return' : ($hashref->{'renewals'} ? 'renew' : 'issue') ; >+ my $item = GetItem($hashref->{'itemnumber'}); >+ >+ $substh->execute( >+ $hashref->{'timestamp'}, >+ $hashref->{'branchcode'}, >+ 0, >+ $type, >+ '', >+ $hashref->{'itemnumber'}, >+ $item->{'itype'}, >+ $hashref->{'borrowernumber'} >+ ); >+ print "timestamp: $hashref->{'timestamp'} branchcode: $hashref->{'branchcode'} type: $type itemnumber: $hashref->{'itemnumber'} itype: $item->{'itype'} borrowernumber: $hashref->{'borrowernumber'}\n"; >+ } >+ >+ } >+} >-- >1.7.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 6025
:
3585
|
3588
|
5441
|
7438