Bug 37706

Summary: Date filter not used in circulation report
Product: Koha Reporter: Andreas Jonsson <andreas.jonsson>
Component: ReportsAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low    
Version: 23.11   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:

Description Andreas Jonsson 2024-08-22 07:25:09 UTC
I noticed that the cirulation report was putting a significant load on the system so I added some debug logging to reports/issues_stats.pl to see what was going on:

    use Data::Dumper;
    warn Dumper([$line, $column, $podsp, $type, $daysel, $monthsel, $calc, \@filters, $attribute_filters]);
    my $results = calculate( $line, $column, $podsp, $type, $daysel, $monthsel, $calc, \@filters, $attribute_filters);


and:

    warn "strsth: $strsth";
    my $sth = $dbh->prepare($strsth);

and:

    warn "strsth2: $strsth2";
    my $sth2 = $dbh->prepare($strsth2);

As you can see a filter was selected for the date period:


2024/08/22 08:02:52] [WARN] $VAR1 = [
  'branch',
  'itemtype',
  '',
  'issue',
  '',
  '',
  '1',
  [
    '2024-08-21',
    '2024-08-21',
  ...

We get a warnings because the date validation tries to numerically compare the date strings (which will cause the validation to always succeed even when selecting a start date greater than the end date):

[2024/08/22 08:02:52] [WARN] Argument "2024-08-21" isn't numeric in numeric lt (<) at /usr/share/koha/intranet/cgi-bin/reports/issues_stats.pl line 216.
[2024/08/22 08:02:52] [WARN] Argument "2024-08-21" isn't numeric in numeric lt (<) at /usr/share/koha/intranet/cgi-bin/reports/issues_stats.pl line 216.

But neither sql queries refer to the selected date period:

[2024/08/22 08:02:52] [WARN] strsth: SELECT distinctrow branch FROM statistics  LEFT JOIN borrowers ON (statistics.borrowernumber = borrowers.borrowernumber)  WHERE branch IS NOT NULL  AND branch != ''  AND branch LIKE ?  group by branch order by branch  at /usr/share/koha/intranet/cgi-bin/reports/issues_stats.pl line 327.
[2024/08/22 08:03:28] [WARN] strsth2: SELECT distinctrow itemtype FROM statistics LEFT JOIN borrowers ON (statistics.borrowernumber = borrowers.borrowernumber)  WHERE itemtype IS NOT NULL AND itemtype != ''  group by itemtype order by itemtype  at /usr/share/koha/intranet/cgi-bin/reports/issues_stats.pl line 418.

So, the date filter is not actually used (other than for claiming that it was used in the generated report).