diff --git a/C4/Accounts.pm b/C4/Accounts.pm index 6d8208980b..ffbd2d9bb3 100644 --- a/C4/Accounts.pm +++ b/C4/Accounts.pm @@ -28,7 +28,6 @@ BEGIN { } use C4::Context; -use C4::Stats; use C4::Members; use Koha::Account; use Koha::Account::Lines; diff --git a/C4/Circulation.pm b/C4/Circulation.pm index c3a056272f..9277d95fa8 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -83,7 +83,6 @@ use Try::Tiny; use JSON; use C4::Context; -use C4::Stats qw( UpdateStats ); use C4::Reserves qw( CheckReserves CanItemBeReserved MoveReserve ModReserve ModReserveMinusPriority IsAvailableForItemLevelRequest ); use C4::Biblio qw( UpdateTotalIssues ); @@ -123,6 +122,7 @@ use Koha::SearchEngine::Indexer; use Koha::Exceptions::Checkout; use Koha::Plugins; use Koha::Recalls; +use Koha::Statistic; use Koha::Library::Hours; use Koha::Library::FloatLimits; use Carp qw( carp ); @@ -885,7 +885,7 @@ sub CanBookBeIssued { if ( $patron->category->category_type eq 'X' && ( $item_object->barcode ) ) { # stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 . - C4::Stats::UpdateStats( + Koha::Statistic->new( { branch => C4::Context->userenv->{'branch'}, type => 'localuse', @@ -897,7 +897,7 @@ sub CanBookBeIssued { location => $item_object->location, interface => C4::Context->interface, } - ); + )->store(); my $block_lost_return = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0; ModDateLastSeen( $item_object->itemnumber, $block_lost_return ); # FIXME Move to Koha::Item return ( { STATS => 1, }, {} ); @@ -1985,7 +1985,7 @@ sub AddIssue { } # Record the fact that this book was issued. - C4::Stats::UpdateStats( + Koha::Statistic->new( { branch => C4::Context->userenv->{'branch'}, type => ( $onsite_checkout ? 'onsite_checkout' : 'issue' ), @@ -1998,7 +1998,7 @@ sub AddIssue { ccode => $item_object->ccode, categorycode => $patron->categorycode } - ); + )->store(); # Send a checkout slip. my $circulation_alert = 'C4::ItemCirculationAlertPreference'; @@ -2717,7 +2717,7 @@ sub AddReturn { # Record the fact that this book was returned. my $categorycode = $patron_unblessed ? $patron_unblessed->{categorycode} : undef; - C4::Stats::UpdateStats( + Koha::Statistic->new( { branch => $branch, type => $stat_type, @@ -2729,7 +2729,8 @@ sub AddReturn { categorycode => $categorycode, interface => C4::Context->interface, } - ) unless ( $skip_localuse && !$issue ); + )->store() + unless ( $skip_localuse && !$issue ); # Send a check-in slip. # NOTE: borrower may be undef. Do not try to send messages then. if ($patron) { @@ -3747,7 +3748,7 @@ sub AddRenewal { )->store(); # Add the renewal to stats - C4::Stats::UpdateStats( + Koha::Statistic->new( { branch => $item_object->renewal_branchcode( { branch => $branch } ), type => 'renew', @@ -3760,7 +3761,7 @@ sub AddRenewal { categorycode => $patron->categorycode, interface => C4::Context->interface, } - ); + )->store(); #Update borrowers.lastseen try { diff --git a/C4/Stats.pm b/C4/Stats.pm deleted file mode 100644 index d4e877fcff..0000000000 --- a/C4/Stats.pm +++ /dev/null @@ -1,66 +0,0 @@ -package C4::Stats; - -# Copyright 2000-2002 Katipo Communications -# -# 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 . - -use Modern::Perl; -use base 'Exporter'; - -BEGIN { - our @EXPORT_OK = qw( - UpdateStats - ); -} - -use Koha::Statistics; - -=head1 NAME - -C4::Stats - Update Koha statistics (log) - -=head1 SYNOPSIS - - use C4::Stats; - -=head1 DESCRIPTION - -The functions of this module deals with statistics table of Koha database. - -=head1 FUNCTIONS - -=head2 UpdateStats - - C4::Stats::UpdateStats($params); - - This is a (legacy) alias for Koha::Statistic->new($params)->store. - Please see Koha::Statistic module. - -=cut - -sub UpdateStats { - my $params = shift; - Koha::Statistic->new($params)->store; -} - -1; -__END__ - -=head1 AUTHOR - -Koha Development Team - -=cut diff --git a/Koha/Account.pm b/Koha/Account.pm index d78247409d..39ad641b77 100644 --- a/Koha/Account.pm +++ b/Koha/Account.pm @@ -25,7 +25,6 @@ use Try::Tiny qw( catch try ); use C4::Letters; use C4::Log qw( logaction ); -use C4::Stats qw( UpdateStats ); use C4::Overdues qw(GetFine); use C4::Context; @@ -38,6 +37,7 @@ use Koha::Account::DebitTypes; use Koha::Exceptions; use Koha::Exceptions::Account; use Koha::Plugins; +use Koha::Statistic; =head1 NAME @@ -286,7 +286,7 @@ sub add_credit { } )->store(); - C4::Stats::UpdateStats( + Koha::Statistic->new( { branch => $library_id, type => lc($credit_type), @@ -294,7 +294,8 @@ sub add_credit { borrowernumber => $self->{patron_id}, interface => $interface, } - ) if grep { $credit_type eq $_ } ( 'PAYMENT', 'WRITEOFF' ); + )->store() + if grep { $credit_type eq $_ } ( 'PAYMENT', 'WRITEOFF' ); Koha::Plugins->call( 'after_account_action', diff --git a/Koha/BackgroundJob/PseudonymizeStatistic.pm b/Koha/BackgroundJob/PseudonymizeStatistic.pm index 963f68287e..440ecca7da 100644 --- a/Koha/BackgroundJob/PseudonymizeStatistic.pm +++ b/Koha/BackgroundJob/PseudonymizeStatistic.pm @@ -18,6 +18,7 @@ package Koha::BackgroundJob::PseudonymizeStatistic; use Modern::Perl; use Koha::PseudonymizedTransactions; +use Koha::Statistic; use base 'Koha::BackgroundJob'; diff --git a/Koha/ILL/Request.pm b/Koha/ILL/Request.pm index a18cc617bc..7ae66ca634 100644 --- a/Koha/ILL/Request.pm +++ b/Koha/ILL/Request.pm @@ -45,6 +45,7 @@ use Koha::Items; use Koha::Libraries; use Koha::AdditionalContents; use Koha::Patron; +use Koha::Statistic; use C4::Circulation qw( CanBookBeIssued AddIssue ); @@ -2275,7 +2276,7 @@ Actions to be done after the request has been completed sub after_completed { my ($self) = @_; - C4::Stats::UpdateStats( + Koha::Statistic->new( { borrowernumber => $self->borrowernumber // undef, branch => $self->branchcode, @@ -2287,7 +2288,7 @@ sub after_completed { location => undef, type => 'illreq_comp', } - ); + )->store(); } =head3 after_created @@ -2301,7 +2302,7 @@ Actions to be done after the request has been fully created sub after_created { my ($self) = @_; - C4::Stats::UpdateStats( + Koha::Statistic->new( { borrowernumber => $self->borrowernumber // undef, branch => $self->branchcode, @@ -2313,7 +2314,7 @@ sub after_created { location => undef, type => 'illreq_created', } - ); + )->store(); } =head3 requested_partners diff --git a/Koha/Item.pm b/Koha/Item.pm index 2381f553bf..4b0b29cbeb 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -57,6 +57,7 @@ use Koha::StockRotationItem; use Koha::StockRotationRotas; use Koha::TrackedLinks; use Koha::Policy::Holds; +use Koha::Statistic; use base qw(Koha::Object); @@ -267,7 +268,7 @@ Record a statistics entry for this item (e.g. on store or delete). sub _add_statistic { my ( $self, $type ) = @_; - C4::Stats::UpdateStats( + Koha::Statistic->new( { borrowernumber => undef, branch => C4::Context->userenv ? C4::Context->userenv->{branch} : undef, @@ -278,7 +279,7 @@ sub _add_statistic { location => $self->location, type => $type, } - ); + )->store(); } =head3 delete diff --git a/Koha/Recalls.pm b/Koha/Recalls.pm index 3d608b5ad3..fa5d6ecb40 100644 --- a/Koha/Recalls.pm +++ b/Koha/Recalls.pm @@ -24,8 +24,7 @@ use Koha::Database; use Koha::Recall; use Koha::DateUtils qw( dt_from_string ); use Koha::Plugins; - -use C4::Stats qw( UpdateStats ); +use Koha::Statistic; use base qw(Koha::Objects); @@ -191,7 +190,7 @@ sub add_recall { $item = Koha::Items->find($itemnumber); # add to statistics table - C4::Stats::UpdateStats( + Koha::Statistic->new( { branch => C4::Context->userenv->{'branch'}, type => 'recall', @@ -202,7 +201,7 @@ sub add_recall { categorycode => $checkout->patron->categorycode, interface => $interface, } - ); + )->store(); Koha::Plugins->call( 'after_recall_action', diff --git a/members/pay.pl b/members/pay.pl index 8e013f414c..e0436668e4 100755 --- a/members/pay.pl +++ b/members/pay.pl @@ -35,7 +35,6 @@ use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_htt use CGI qw ( -utf8 ); use C4::Members; use C4::Accounts; -use C4::Stats; use C4::Koha; use C4::Overdues; use Koha::Patrons; diff --git a/misc/maintenance/pseudonymize_statistics.pl b/misc/maintenance/pseudonymize_statistics.pl index 8b2aa4ef65..88a6f8e3ff 100755 --- a/misc/maintenance/pseudonymize_statistics.pl +++ b/misc/maintenance/pseudonymize_statistics.pl @@ -21,6 +21,7 @@ use Pod::Usage qw( pod2usage ); use Koha::DateUtils qw( dt_from_string format_sqldatetime ); use Koha::Script; +use Koha::Statistic; use Koha::Statistics; use Koha::PseudonymizedTransactions; diff --git a/offline_circ/enqueue_koc.pl b/offline_circ/enqueue_koc.pl index 6cfa0017ae..f54a07504f 100755 --- a/offline_circ/enqueue_koc.pl +++ b/offline_circ/enqueue_koc.pl @@ -27,7 +27,6 @@ use C4::Context; use C4::Accounts; use C4::Circulation qw( AddOfflineOperation ); use C4::Members; -use C4::Stats; use Koha::Checkouts; use Koha::UploadedFiles; use Koha::Items; diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 0a4f2b5237..63883147b9 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -59,6 +59,7 @@ use Koha::Account::Offsets; use Koha::ActionLogs; use Koha::Notice::Messages; use Koha::Cache::Memory::Lite; +use Koha::Statistics; my $builder = t::lib::TestBuilder->new; diff --git a/t/db_dependent/Koha/Pseudonymization.t b/t/db_dependent/Koha/Pseudonymization.t index bc6a97c6cf..aef92be88d 100755 --- a/t/db_dependent/Koha/Pseudonymization.t +++ b/t/db_dependent/Koha/Pseudonymization.t @@ -25,12 +25,12 @@ use Test::Warn; use Try::Tiny; use C4::Circulation qw( AddIssue AddReturn ); -use C4::Stats qw( UpdateStats ); use Koha::Database; use Koha::DateUtils qw( dt_from_string ); use Koha::Patrons; use Koha::PseudonymizedTransactions; +use Koha::Statistic; use Koha::Statistics; use t::lib::TestBuilder; diff --git a/t/db_dependent/Koha/Statistic.t b/t/db_dependent/Koha/Statistic.t index 8be5576e1e..566abccbe6 100755 --- a/t/db_dependent/Koha/Statistic.t +++ b/t/db_dependent/Koha/Statistic.t @@ -23,6 +23,7 @@ use Test::More tests => 3; use Test::Warn; use Koha::DateUtils qw(dt_from_string); +use Koha::Statistic; use Koha::Statistics; use Koha::Database; diff --git a/t/db_dependent/Koha/Statistics.t b/t/db_dependent/Koha/Statistics.t index d21e59db2f..c20577ce98 100755 --- a/t/db_dependent/Koha/Statistics.t +++ b/t/db_dependent/Koha/Statistics.t @@ -25,6 +25,7 @@ use Test::Exception; use C4::Context; use Koha::Database; +use Koha::Statistic; use Koha::Statistics; use t::lib::TestBuilder;