← Index
NYTProf Performance Profile   « line view »
For starman worker -M FindBin --max-requests 50 --workers 2 --user=kohadev-koha --group kohadev-koha --pid /var/run/koha/kohadev/plack.pid --daemonize --access-log /var/log/koha/kohadev/plack.log --error-log /var/log/koha/kohadev/plack-error.log -E deployment --socket /var/run/koha/kohadev/plack.sock /etc/koha/sites/kohadev/plack.psgi
  Run on Fri Jan 8 14:31:06 2016
Reported on Fri Jan 8 14:33:30 2016

Filename/home/vagrant/kohaclone/C4/Review.pm
StatementsExecuted 20 statements in 1.43ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11151µs326µsC4::Review::::numberofreviewsC4::Review::numberofreviews
11128µs41µsC4::Review::::BEGIN@20C4::Review::BEGIN@20
11123µs23µsC4::Review::::BEGIN@27C4::Review::BEGIN@27
11119µs26µsC4::Review::::BEGIN@23C4::Review::BEGIN@23
11118µs65µsC4::Review::::BEGIN@25C4::Review::BEGIN@25
11116µs24µsC4::Review::::BEGIN@21C4::Review::BEGIN@21
0000s0sC4::Review::::approvereviewC4::Review::approvereview
0000s0sC4::Review::::deletereviewC4::Review::deletereview
0000s0sC4::Review::::getallreviewsC4::Review::getallreviews
0000s0sC4::Review::::getreviewC4::Review::getreview
0000s0sC4::Review::::getreviewsC4::Review::getreviews
0000s0sC4::Review::::numberofreviewsbybiblionumberC4::Review::numberofreviewsbybiblionumber
0000s0sC4::Review::::savereviewC4::Review::savereview
0000s0sC4::Review::::unapprovereviewC4::Review::unapprovereview
0000s0sC4::Review::::updatereviewC4::Review::updatereview
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package C4::Review;
2
3# Copyright 2000-2002 Katipo Communications
4#
5# This file is part of Koha.
6#
7# Koha is free software; you can redistribute it and/or modify it
8# under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3 of the License, or
10# (at your option) any later version.
11#
12# Koha is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20267µs253µs
# spent 41µs (28+12) within C4::Review::BEGIN@20 which was called: # once (28µs+12µs) by CGI::Compile::ROOT::home_vagrant_kohaclone_mainpage_2epl::BEGIN@28 at line 20
use strict;
# spent 41µs making 1 call to C4::Review::BEGIN@20 # spent 12µs making 1 call to strict::import
21256µs232µs
# spent 24µs (16+8) within C4::Review::BEGIN@21 which was called: # once (16µs+8µs) by CGI::Compile::ROOT::home_vagrant_kohaclone_mainpage_2epl::BEGIN@28 at line 21
use warnings;
# spent 24µs making 1 call to C4::Review::BEGIN@21 # spent 8µs making 1 call to warnings::import
22
23261µs233µs
# spent 26µs (19+7) within C4::Review::BEGIN@23 which was called: # once (19µs+7µs) by CGI::Compile::ROOT::home_vagrant_kohaclone_mainpage_2epl::BEGIN@28 at line 23
use C4::Context;
# spent 26µs making 1 call to C4::Review::BEGIN@23 # spent 7µs making 1 call to C4::Context::import
24
252156µs2112µs
# spent 65µs (18+47) within C4::Review::BEGIN@25 which was called: # once (18µs+47µs) by CGI::Compile::ROOT::home_vagrant_kohaclone_mainpage_2epl::BEGIN@28 at line 25
use vars qw($VERSION @ISA @EXPORT);
# spent 65µs making 1 call to C4::Review::BEGIN@25 # spent 47µs making 1 call to vars::import
26
27
# spent 23µs within C4::Review::BEGIN@27 which was called: # once (23µs+0s) by CGI::Compile::ROOT::home_vagrant_kohaclone_mainpage_2epl::BEGIN@28 at line 34
BEGIN {
28 # set the version for version checking
2912µs $VERSION = 3.07.00.049;
3011µs require Exporter;
31113µs @ISA = qw(Exporter);
3217µs @EXPORT = qw(getreview savereview updatereview numberofreviews numberofreviewsbybiblionumber
33 getreviews getallreviews approvereview unapprovereview deletereview);
341926µs123µs}
# spent 23µs making 1 call to C4::Review::BEGIN@27
35
36=head1 NAME
37
38C4::Review - Perl Module containing routines for dealing with reviews of items
39
40=head1 SYNOPSIS
41
42 use C4::Review;
43
44 my $review=getreview($biblionumber,$borrowernumber);
45 savereview($biblionumber,$borrowernumber,$review);
46 updatereview($biblionumber,$borrowernumber,$review);
47 my $count=numberofreviews($status);
48 my $count=numberofreviewsbybiblionumber($biblionumber);
49 my $reviews=getreviews($biblionumber, $status);
50 my $reviews=getallreviews($status, [$offset], [$row_count]);
51
52=head1 DESCRIPTION
53
54Review.pm provides many routines for manipulating reviews.
55
56=head1 FUNCTIONS
57
58=head2 getreview
59
60 $review = getreview($biblionumber,$borrowernumber);
61
62Takes a borrowernumber and a biblionumber and returns the review of that biblio
63
64=cut
65
66sub getreview {
67 my ( $biblionumber, $borrowernumber ) = @_;
68 my $dbh = C4::Context->dbh;
69 my $query = "SELECT * FROM reviews WHERE biblionumber=? and borrowernumber=?";
70 my $sth = $dbh->prepare($query);
71 $sth->execute( $biblionumber, $borrowernumber );
72 return $sth->fetchrow_hashref();
73}
74
75=head2 savereview
76
77 savereview($biblionumber,$borrowernumber, $review);
78
79Save a review in the 'reviews' database
80
81=cut
82
83sub savereview {
84 my ( $biblionumber, $borrowernumber, $review ) = @_;
85 my $dbh = C4::Context->dbh;
86 my $query = "INSERT INTO reviews (borrowernumber,biblionumber,
87 review,approved,datereviewed) VALUES
88 (?,?,?,0,now())";
89 my $sth = $dbh->prepare($query);
90 $sth->execute( $borrowernumber, $biblionumber, $review );
91}
92
93=head2 updatereview
94
95 updateview($biblionumber,$borrowernumber, $review);
96
97Update the review description in the 'reviews' database
98
99=cut
100
101sub updatereview {
102 my ( $biblionumber, $borrowernumber, $review ) = @_;
103 my $dbh = C4::Context->dbh;
104 my $query = "UPDATE reviews SET review=?,datereviewed=now(),approved=0 WHERE borrowernumber=? and biblionumber=?";
105 my $sth = $dbh->prepare($query);
106 $sth->execute( $review, $borrowernumber, $biblionumber );
107}
108
109=head2 numberofreviews
110
111 my $count=numberofreviews( [$status] );
112
113Return the number of reviews where in the 'reviews' database : 'approved' = $status
114(By default $status = 1)
115
116=cut
117
118
# spent 326µs (51+275) within C4::Review::numberofreviews which was called: # once (51µs+275µs) by CGI::Compile::ROOT::home_vagrant_kohaclone_mainpage_2epl::__ANON__[/home/vagrant/kohaclone/mainpage.pl:107] at line 65 of mainpage.pl
sub numberofreviews {
1191600ns my ($param) = @_;
1201900ns my $status = ( defined($param) ? $param : 1 );
121112µs1137µs my $dbh = C4::Context->dbh;
# spent 137µs making 1 call to C4::Context::dbh
1221900ns my $query = "SELECT count(*) FROM reviews WHERE approved=?";
12318µs2104µs my $sth = $dbh->prepare($query);
# spent 54µs making 1 call to DBI::db::prepare # spent 49µs making 1 call to DBD::mysql::db::prepare
124180µs171µs $sth->execute($status);
# spent 71µs making 1 call to DBI::st::execute
125137µs14µs return $sth->fetchrow;
# spent 4µs making 1 call to DBI::st::fetchrow
126}
127
128=head2 numberofreviewsbybiblionumber
129
130 my $count=numberofreviewsbybiblionumber($biblionumber);
131
132Return the number of reviews approved for a given biblionumber
133
134=cut
135
136sub numberofreviewsbybiblionumber {
137 my ($biblionumber) = @_;
138 my $dbh = C4::Context->dbh;
139 my $query = "SELECT count(*) FROM reviews WHERE biblionumber=? and approved=?";
140 my $sth = $dbh->prepare($query);
141 $sth->execute( $biblionumber, 1 );
142 return $sth->fetchrow;
143}
144
145=head2 getreviews
146
147 my $reviews=getreviews($biblionumber, $status);
148
149Return all reviews where in the 'reviews' database :
150'biblionumber' = $biblionumber and 'approved' = $status
151
152=cut
153
154sub getreviews {
155 my ( $biblionumber, $approved ) = @_;
156 my $dbh = C4::Context->dbh;
157 my $query = "SELECT * FROM reviews WHERE biblionumber=? and approved=? order by datereviewed desc";
158 my $sth = $dbh->prepare($query);
159 $sth->execute( $biblionumber, $approved );
160 return $sth->fetchall_arrayref( {} );
161}
162
163=head2 getallreviews
164
165 my $reviews=getallreviews($status, [$offset], [$row_count]);
166
167Return all reviews where in the 'reviews' database : 'approved' = $status
168
169If offset and row_count are fiven, it's return all reviews between the
170$offset position and the ($offset + $row_count) position.
171(By default : $offset = 0 and $row_count = 20)
172
173=cut
174
175sub getallreviews {
176 my ( $status, $offset, $row_count ) = @_;
177 my @params = ( $status, ( $offset ? $offset : 0 ), ( $row_count ? $row_count : 20 ) );
178 my $dbh = C4::Context->dbh;
179 my $query = "SELECT * FROM reviews WHERE approved=? order by datereviewed desc LIMIT ?, ?";
180 my $sth = $dbh->prepare($query);
181 $sth->execute(@params);
182 return $sth->fetchall_arrayref( {} );
183}
184
185=head2 approvereview
186
187 approvereview($reviewid);
188
189Takes a reviewid and marks that review approved
190
191=cut
192
193sub approvereview {
194 my ($reviewid) = @_;
195 my $dbh = C4::Context->dbh();
196 my $query = "UPDATE reviews
197 SET approved=?
198 WHERE reviewid=?";
199 my $sth = $dbh->prepare($query);
200 $sth->execute( 1, $reviewid );
201}
202
203=head2 unapprovereview
204
205 unapprovereview($reviewid);
206
207Takes a reviewid and marks that review as not approved
208
209=cut
210
211sub unapprovereview {
212 my ($reviewid) = @_;
213 my $dbh = C4::Context->dbh();
214 my $query = "UPDATE reviews
215 SET approved=?
216 WHERE reviewid=?";
217 my $sth = $dbh->prepare($query);
218 $sth->execute( 0, $reviewid );
219}
220
221=head2 deletereview
222
223 deletereview($reviewid);
224
225Takes a reviewid and deletes it
226
227=cut
228
229sub deletereview {
230 my ($reviewid) = @_;
231 my $dbh = C4::Context->dbh();
232 my $query = "DELETE FROM reviews
233 WHERE reviewid=?";
234 my $sth = $dbh->prepare($query);
235 $sth->execute($reviewid);
236}
237
23813µs1;
239__END__