Bug 14598: (DB update) fix NULL itemtypes in statistics on 'return' rows
This patch introduces an updatedatabase.pl entry that takes care of
updating existing statistics rows.
It does so by looping on the statistics rows, collecting itemnumber occurences
that are have NULL itemtypes.
It then chooses the right itemtype following what is proposed on bug 14651, and
then updates the rows in statistics using the calculated itemtype.
Regards
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 2cdec7ff91)
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
This commit is contained in:
parent
4df3dbbdde
commit
95c65c5a89
|
|
@ -11837,6 +11837,46 @@ if ( CheckVersion($DBversion) ) {
|
|||
}
|
||||
|
||||
|
||||
$DBversion = "3.23.00.XXX";
|
||||
if ( CheckVersion($DBversion) ) {
|
||||
|
||||
$sth = $dbh->prepare(q{
|
||||
SELECT s.itemnumber, i.itype, b.itemtype FROM
|
||||
( SELECT DISTINCT itemnumber
|
||||
FROM statistics
|
||||
WHERE type="return" AND itemtype IS NULL ) s
|
||||
LEFT JOIN
|
||||
( SELECT itemnumber,biblionumber, itype
|
||||
FROM items ) i
|
||||
ON (s.itemnumber=i.itemnumber)
|
||||
LEFT JOIN
|
||||
( SELECT biblionumber, itemtype
|
||||
FROM biblioitems ) b
|
||||
ON (i.biblionumber=b.biblionumber)
|
||||
});
|
||||
$sth->execute();
|
||||
|
||||
my $update_sth = $dbh->prepare(q{
|
||||
UPDATE statistics
|
||||
SET itemtype=?
|
||||
WHERE itemnumber=? AND itemtype IS NULL
|
||||
});
|
||||
my $ilevel_itypes = C4::Context->preference('item-level_itypes');
|
||||
|
||||
while ( my ($itemnumber,$item_itype,$biblio_itype) = $sth->fetchrow_array ) {
|
||||
|
||||
my $effective_itemtype = $ilevel_itypes
|
||||
? $item_itype // $biblio_itype
|
||||
: $biblio_itype;
|
||||
warn "item-level_itypes set but no itype defined for item ($itemnumber)"
|
||||
if $ilevel_itypes and !defined $item_itype;
|
||||
$update_sth->execute( $effective_itemtype, $itemnumber );
|
||||
}
|
||||
|
||||
print "Upgrade to $DBversion done (Bug 14598: itemtype is not set on statistics by C4::Circulation::AddReturn)\n";
|
||||
SetVersion($DBversion);
|
||||
}
|
||||
|
||||
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
|
||||
# SEE bug 13068
|
||||
# if there is anything in the atomicupdate, read and execute it.
|
||||
|
|
|
|||
Loading…
Reference in New Issue