Bugzilla – Attachment 54338 Details for
Bug 17089
Move the star ratings related code to Koha::Ratings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17089: Koha::Ratings - Remove C4::Ratings
Bug-17089-KohaRatings---Remove-C4Ratings.patch (text/plain), 5.40 KB, created by
Marcel de Rooy
on 2016-08-12 08:19:04 UTC
(
hide
)
Description:
Bug 17089: Koha::Ratings - Remove C4::Ratings
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2016-08-12 08:19:04 UTC
Size:
5.40 KB
patch
obsolete
>From d8f418fd0d24b7300adb7d56307b4a7fb2d81552 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 9 Aug 2016 15:01:05 +0100 >Subject: [PATCH] Bug 17089: Koha::Ratings - Remove C4::Ratings >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Ratings.pm | 184 --------------------------------------------------------- > 1 file changed, 184 deletions(-) > delete mode 100644 C4/Ratings.pm > >diff --git a/C4/Ratings.pm b/C4/Ratings.pm >deleted file mode 100644 >index 061d42b..0000000 >--- a/C4/Ratings.pm >+++ /dev/null >@@ -1,184 +0,0 @@ >-package C4::Ratings; >- >-# Copyright 2011 KohaAloha, NZ >-# Parts copyright 2011, Catalyst IT, NZ. >-# >-# 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 <http://www.gnu.org/licenses>. >- >-use strict; >-use warnings; >-use Carp; >-use Exporter; >-use POSIX; >-use C4::Debug; >-use C4::Context; >- >-use Koha::Database; >- >-use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); >- >-BEGIN { >- @ISA = qw(Exporter); >- >- @EXPORT = qw( >- &GetRating >- ); >-} >- >-=head1 NAME >- >-C4::Ratings - a module to manage user ratings of Koha biblios >- >-=head1 DESCRIPTION >- >-Ratings.pm provides simple functionality for a user to 'rate' a biblio, and to retrieve a biblio's rating info >- >-the 4 subroutines allow a user to add, delete modify and retrieve rating info for a biblio. >- >-The rating can be from 1 to 5 stars, (5 stars being the highest rating) >- >-=head1 SYNOPSIS >- >-Get a rating for a bib >- my $rating_hashref = GetRating( $biblionumber, undef ); >- my $rating_hashref = GetRating( $biblionumber, $borrowernumber ); >- >- >-All subroutines in Ratings.pm return a hashref which contain 4 keys >- >-for example, after executing this statement below... >- >- my $rating_hashref = GetRating ( $biblionumber, $borrowernumber ) ; >- >-$rating_hashref now contains a hashref that looks like this... >- >- $rating = { >- rating_avg => '2', >- rating_avg_int => '2.3', >- rating_total => '432', >- rating_value => '5' >- } >- >-they 4 keys returned in the hashref are... >- >- rating_avg: average rating of a biblio >- rating_avg_int: average rating of a biblio, rounded to 1dp >- rating_total: total number of ratings of a biblio >- rating_value: logged-in user's rating of a biblio >- >-=head1 BUGS >- >-Please use bugs.koha-community.org for tracking bugs. >- >-=head1 SOURCE AVAILABILITY >- >-The source is available from the koha-community.org git server >-L<http://git.koha-community.org> >- >-=head1 AUTHOR >- >-Original code: Mason James <mtj@kohaaloha.com> >- >-=head1 COPYRIGHT >- >-Copyright (c) 2011 Mason James <mtj@kohaaloha.com> >- >-=head1 LICENSE >- >-C4::Ratings is free software. You can redistribute it and/or >-modify it under the same terms as Koha itself. >- >-=head1 CREDITS >- >- Mason James <mtj@kohaaloha.com> >- Koha Dev Team <http://koha-community.org> >- >- >-=head2 GetRating >- >- GetRating($biblionumber, [$borrowernumber]) >- >-Get a rating for a bib >- my $rating_hashref = GetRating( $biblionumber, undef ); >- my $rating_hashref = GetRating( $biblionumber, $borrowernumber ); >- >-This returns the rating for the supplied biblionumber. It will also return >-the rating that the supplied user gave to the provided biblio. If a particular >-value can't be supplied, '0' is returned for that value. >- >-=head3 RETURNS >- >-A hashref containing: >- >-=over >- >-=item * rating_avg - average rating of a biblio >- >-=item * rating_avg_int - average rating of a biblio, rounded to 1dp >- >-=item * rating_total - total number of ratings of a biblio >- >-=item * rating_value - logged-in user's rating of a biblio >- >-=back >- >-=cut >- >-sub GetRating { >- my ( $biblionumber, $borrowernumber ) = @_; >- >- my $ratings = Koha::Database->new()->schema->resultset('Rating')->search( >- { >- biblionumber => $biblionumber, >- } >- ); >- >- my $sum = $ratings->get_column('rating_value')->sum(); >- my $total = $ratings->count(); >- >- my ( $avg, $avg_int ) = 0; >- >- if ( $sum and $total ) { >- eval { $avg = $sum / $total }; >- } >- >- $avg_int = sprintf( "%.1f", $avg ); >- $avg = sprintf( "%.0f", $avg ); >- >- my %rating_hash; >- $rating_hash{rating_total} = $total || 0; >- $rating_hash{rating_avg} = $avg || 0; >- $rating_hash{rating_avg_int} = $avg_int || 0; >- >- if ($borrowernumber) { >- my $rating = Koha::Database->new()->schema->resultset('Rating')->find( >- { >- biblionumber => $biblionumber, >- borrowernumber => $borrowernumber, >- } >- ); >- return unless $rating; >- $rating_hash{'rating_value'} = $rating->rating_value(); >- } >- else { >- $rating_hash{rating_value} = undef; >- } >- >- return \%rating_hash; >-} >- >-1; >-__END__ >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17089
:
54207
|
54208
|
54209
|
54210
|
54211
|
54212
|
54213
|
54214
|
54225
|
54230
|
54231
|
54232
|
54233
|
54234
|
54235
|
54236
|
54237
|
54238
|
54332
|
54333
|
54334
|
54335
|
54336
|
54337
| 54338 |
54339
|
54340
|
54341