@@ -, +, @@ --- .../atomicupdate/bug_16122_atomicupdate.pl | 30 +++++++++++-------- .../update_localuse_from_statistics.pl | 17 +++++------ 2 files changed, 25 insertions(+), 22 deletions(-) --- a/installer/data/mysql/atomicupdate/bug_16122_atomicupdate.pl +++ a/installer/data/mysql/atomicupdate/bug_16122_atomicupdate.pl @@ -1,27 +1,31 @@ use Modern::Perl; return { - bug_number => "16122", - description => "Add localuser column to items table", - up => sub { + bug_number => "16122", + description => "Add local use column to items table", + up => sub { my ($args) = @_; - my ($dbh, $out) = @$args{qw(dbh out)}; - if( !column_exists( 'items', 'localuse' ) ) { - $dbh->do(q{ + my ( $dbh, $out ) = @$args{qw(dbh out)}; + if ( !column_exists( 'items', 'localuse' ) ) { + $dbh->do( + q{ ALTER TABLE items ADD COLUMN localuse smallint(6) NULL DEFAULT NULL - COMMENT "item's local use count" + COMMENT "number of times this item has been recorded as local use" AFTER renewals - }); + } + ); say $out "Added column 'items.localuse'"; } - if( !column_exists( 'deleteditems', 'localuse' ) ) { - $dbh->do(q{ + if ( !column_exists( 'deleteditems', 'localuse' ) ) { + $dbh->do( + q{ ALTER TABLE deleteditems ADD COLUMN localuse smallint(6) NULL DEFAULT NULL - COMMENT "deleteditems local use count" + COMMENT "number of times this item has been recorded as local use" AFTER renewals - }); + } + ); say $out "Added column 'deleteditems.localuse'"; } }, -} + } --- a/misc/maintenance/update_localuse_from_statistics.pl +++ a/misc/maintenance/update_localuse_from_statistics.pl @@ -27,7 +27,6 @@ use Koha::Statistics; use Getopt::Long qw( GetOptions ); use Pod::Usage qw( pod2usage ); - sub usage { pod2usage( -verbose => 2 ); exit; @@ -40,20 +39,20 @@ sub update_localuse { my $items = Koha::Items->search(); # Loop through each item and update it with statistics info - while( my $item = $items->next ){ - my $itemnumber = $item->itemnumber; + while ( my $item = $items->next ) { + my $itemnumber = $item->itemnumber; - my $localuse_count = Koha::Statistics->search( { itemnumber => $itemnumber, type => 'localuse' } )->count; - $item->localuse( $localuse_count ); - $item->store; + my $localuse_count = Koha::Statistics->search( { itemnumber => $itemnumber, type => 'localuse' } )->count; + $item->localuse($localuse_count); + $item->store; - print "Updated item $itemnumber with localuse statistics info.\n"; + print "Updated item $itemnumber with localuse statistics info.\n"; } } -my ( $help ); +my ($help); my $result = GetOptions( - 'help|h' => \$help, + 'help|h' => \$help, ); usage() if $help; --