From cb0ea71dddbfd9fc168d6eee341d9e5251521e79 Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Sun, 5 Nov 2023 12:56:45 +0000 Subject: [PATCH] Bug 16122: (QA follow-up) Perltidy, fix spelling and db comments * COMMENT in database update and kohastructure didn't match up * Fix some localuse to local use in text/descriptions * Perltidy Signed-off-by: Katrin Fischer --- C4/Circulation.pm | 12 ++++---- api/v1/swagger/definitions/item.yaml | 2 +- .../atomicupdate/bug_16122_atomicupdate.pl | 30 +++++++++++-------- .../update_localuse_from_statistics.pl | 17 +++++------ 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 227dbe98f5..2a5a1993f2 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -830,7 +830,7 @@ sub CanBookBeIssued { #increment items.localuse my $localuse_count = $item_object->localuse; $localuse_count++; - $item_object->localuse( $localuse_count )->store; + $item_object->localuse($localuse_count)->store; ModDateLastSeen( $item_object->itemnumber ); # FIXME Move to Koha::Item return( { STATS => 1 }, {}); @@ -2148,11 +2148,11 @@ sub AddReturn { $doreturn = 0; # No issue, no borrowernumber. ONLY if $doreturn, *might* you have a $borrower later. # Record this as a local use, instead of a return, if the RecordLocalUseOnReturn is on - if (C4::Context->preference("RecordLocalUseOnReturn")) { - $localuse_count++; - $item->localuse( $localuse_count )->store; - $messages->{'LocalUse'} = 1; - $stat_type = 'localuse'; + if ( C4::Context->preference("RecordLocalUseOnReturn") ) { + $localuse_count++; + $item->localuse($localuse_count)->store; + $messages->{'LocalUse'} = 1; + $stat_type = 'localuse'; } } diff --git a/api/v1/swagger/definitions/item.yaml b/api/v1/swagger/definitions/item.yaml index b719043dc5..7d9eb69b12 100644 --- a/api/v1/swagger/definitions/item.yaml +++ b/api/v1/swagger/definitions/item.yaml @@ -117,7 +117,7 @@ properties: type: - integer - "null" - description: Number of times this item has been recorded for localuse + description: Number of times this item has been recorded for local use holds_count: type: - integer diff --git a/installer/data/mysql/atomicupdate/bug_16122_atomicupdate.pl b/installer/data/mysql/atomicupdate/bug_16122_atomicupdate.pl index b423ae618d..bc69d7e62b 100755 --- a/installer/data/mysql/atomicupdate/bug_16122_atomicupdate.pl +++ b/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 tables", + 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'"; } }, -} + } diff --git a/misc/maintenance/update_localuse_from_statistics.pl b/misc/maintenance/update_localuse_from_statistics.pl index 5da3b79e3c..c0bf2f761c 100755 --- a/misc/maintenance/update_localuse_from_statistics.pl +++ b/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 local use statistics information.\n"; } } -my ( $help ); +my ($help); my $result = GetOptions( - 'help|h' => \$help, + 'help|h' => \$help, ); usage() if $help; -- 2.30.2