From 48f1119a547a9bb280b6a27c4524302cb3716e71 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marc=20V=C3=A9ron?= Date: Wed, 27 Apr 2016 12:38:58 +0200 Subject: [PATCH] Bug 12721: (followup) Replace mysqlism by DBIx::Class This patch removes the mysqlism (see comment #18) Signed-off-by: Chris Cormack Signed-off-by: Katrin Fischer Fixed QA tools complaints about missing lines before and after =cut in POD. Signed-off-by: Brendan Gallagher (cherry picked from commit ef97b6b301a5c1a9ef5c63cc93933bf7442513fc) Signed-off-by: Julian Maurice (cherry picked from commit 8fb9837adeecce2896085d9f3d463633a2cbb8ae) Signed-off-by: Chris Cormack --- C4/Members/Statistics.pm | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/C4/Members/Statistics.pm b/C4/Members/Statistics.pm index c491819a1e..b8b3a0f61a 100644 --- a/C4/Members/Statistics.pm +++ b/C4/Members/Statistics.pm @@ -48,8 +48,8 @@ our $fields = get_fields(); Get fields form syspref 'StatisticsFields' Returns list of valid fields, defaults to 'location|itype|ccode' if syspref is empty or does not contain valid fields -=cut +=cut sub get_fields { @@ -59,14 +59,11 @@ sub get_fields { if ( $syspref ) { my @ret; my @spfields = split ('\|', $syspref); - my $dbh=C4::Context->dbh; - my $sth = $dbh->prepare('SHOW COLUMNS FROM items'); - $sth->execute; - my $dbfields = $sth->fetchall_hashref('Field'); - $sth->finish(); + my $schema = Koha::Database->new()->schema(); + my @columns = $schema->source('Item')->columns; foreach my $fn ( @spfields ) { - push ( @ret, $fn ) if ( $dbfields->{ $fn } ); + push ( @ret, $fn ) if ( grep(/^$fn$/, @columns) ); } $ret = join( '|', @ret); } @@ -76,7 +73,9 @@ sub get_fields { =head2 construct_query Build a sql query from a subquery Adds statistics fields to the select and the group by clause + =cut + sub construct_query { my $count = shift; my $subquery = shift; @@ -95,7 +94,9 @@ sub construct_query { =head2 GetTotalIssuesTodayByBorrower Return total issues for a borrower at this current day + =cut + sub GetTotalIssuesTodayByBorrower { my ($borrowernumber) = @_; my $dbh = C4::Context->dbh; @@ -114,7 +115,9 @@ sub GetTotalIssuesTodayByBorrower { =head2 GetTotalIssuesReturnedTodayByBorrower Return total issues returned by a borrower at this current day + =cut + sub GetTotalIssuesReturnedTodayByBorrower { my ($borrowernumber) = @_; my $dbh = C4::Context->dbh; @@ -128,7 +131,9 @@ sub GetTotalIssuesReturnedTodayByBorrower { =head2 GetPrecedentStateByBorrower Return the precedent state (before today) for a borrower of his checkins and checkouts + =cut + sub GetPrecedentStateByBorrower { my ($borrowernumber) = @_; my $dbh = C4::Context->dbh; -- 2.39.5