Bug 15839: Koha::Reviews - Remove getnumberofreviews
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 16 Feb 2016 16:28:09 +0000 (16:28 +0000)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 9 Sep 2016 10:29:58 +0000 (10:29 +0000)
Signed-off-by: Marc Veron <veron@veron.ch>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

C4/Review.pm
mainpage.pl
opac/opac-showreviews.pl
reviews/reviewswaiting.pl
tools/tools-home.pl

index 0c27833..b76b1e9 100644 (file)
@@ -27,7 +27,7 @@ use vars qw(@ISA @EXPORT);
 BEGIN {
     require Exporter;
     @ISA    = qw(Exporter);
-    @EXPORT = qw(savereview updatereview numberofreviews numberofreviewsbybiblionumber);
+    @EXPORT = qw(savereview updatereview numberofreviewsbybiblionumber);
 }
 
 =head1 NAME
@@ -40,7 +40,6 @@ C4::Review - Perl Module containing routines for dealing with reviews of items
 
   savereview($biblionumber,$borrowernumber,$review);
   updatereview($biblionumber,$borrowernumber,$review);
-  my $count=numberofreviews($status);
   my $count=numberofreviewsbybiblionumber($biblionumber);
 
 =head1 DESCRIPTION
@@ -83,25 +82,6 @@ sub updatereview {
     $sth->execute( $review, $borrowernumber, $biblionumber );
 }
 
-=head2 numberofreviews
-
-  my $count=numberofreviews( [$status] );
-
-Return the number of reviews where in the 'reviews' database : 'approved' = $status
-(By default $status = 1)
-
-=cut
-
-sub numberofreviews {
-    my ($param) = @_;
-    my $status = ( defined($param) ? $param : 1 );
-    my $dbh    = C4::Context->dbh;
-    my $query  = "SELECT count(*) FROM reviews WHERE approved=?";
-    my $sth    = $dbh->prepare($query);
-    $sth->execute($status);
-    return $sth->fetchrow;
-}
-
 =head2 numberofreviewsbybiblionumber
 
   my $count=numberofreviewsbybiblionumber($biblionumber);
index f4efc65..258a9d5 100755 (executable)
@@ -25,11 +25,11 @@ use C4::Output;
 use C4::Auth;
 use C4::Koha;
 use C4::NewsChannels; # GetNewsToDisplay
-use C4::Review qw/numberofreviews/;
 use C4::Suggestions qw/CountSuggestion/;
 use C4::Tags qw/get_count_by_tag_status/;
 use Koha::Patron::Modifications;
 use Koha::Patron::Discharge;
+use Koha::Reviews;
 
 my $query = new CGI;
 
@@ -62,7 +62,7 @@ my $branch =
   ? C4::Context->userenv()->{'branch'}
   : undef;
 
-my $pendingcomments    = numberofreviews(0);
+my $pendingcomments    = Koha::Reviews->search({ approved => 0 })->count;
 my $pendingtags        = get_count_by_tag_status(0);
 my $pendingsuggestions = CountSuggestion("ASKED");
 my $pending_borrower_modifications = Koha::Patron::Modifications->pending_count( $branch );
index 69c0869..a88a74e 100755 (executable)
@@ -85,7 +85,7 @@ my $reviews = Koha::Reviews->search(
     }
 )->unblessed;
 my $marcflavour      = C4::Context->preference("marcflavour");
-my $hits = numberofreviews(1);
+my $hits = Koha::Reviews->search({ approved => 1 })->count;
 my $i = 0;
 my $latest_comment_date;
 for my $result (@$reviews){
index 74b92f5..017e162 100755 (executable)
@@ -43,7 +43,7 @@ my $status   = $query->param('status') || 0;
 my $reviewid = $query->param('reviewid');
 my $page     = $query->param('page') || 1;
 my $count    = C4::Context->preference('numSearchResults') || 20;
-my $total    = numberofreviews($status);
+my $total    = Koha::Reviews->search({ approved => $status })->count;
 
 if ( $op eq 'approve' ) {
     my $review = Koha::Reviews->find( $reviewid );
index 1a1ce30..86cfb03 100755 (executable)
 # You should have received a copy of the GNU General Public License
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 
-use strict;
-use warnings;
+use Modern::Perl;
 
 use CGI qw ( -utf8 );
 use C4::Auth;
 use C4::Output;
-use C4::Review qw/numberofreviews/;
 use C4::Tags qw/get_count_by_tag_status/;
+use Koha::Reviews;
 
 my $query = new CGI;
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
@@ -36,7 +35,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     }
 );
 
-my $pendingcomments = numberofreviews(0);
+my $pendingcomments = Koha::Reviews->search({ approved => 0 })->count;
 my $pendingtags = get_count_by_tag_status(0);
 
 $template->param(