[Koha-bugs] [Bug 24527] New: misc/cronjobs/update_totalissues.pl problem with multiple items

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Jan 28 16:04:23 CET 2020


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24527

            Bug ID: 24527
           Summary: misc/cronjobs/update_totalissues.pl problem with
                    multiple items
 Change sponsored?: ---
           Product: Koha
           Version: master
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P5 - low
         Component: Command-line Utilities
          Assignee: koha-bugs at lists.koha-community.org
          Reporter: fridolin.somers at biblibre.com
        QA Contact: testopia at bugs.koha-community.org
                CC: robin at catalyst.net.nz

misc/cronjobs/update_totalissues.pl when issuing statistics table has a problem
for biblio with multiple items.
The first SQL query gets the biblios linked to items with issues in statistics
:

SELECT biblio.biblionumber, COUNT(statistics.itemnumber) FROM biblio LEFT JOIN
items ON (biblio.biblionumber=items.biblionumber) LEFT JOIN statistics ON
(items.itemnumber=statistics.itemnumber) WHERE statistics.type = 'issue' $limit
GROUP BY biblio.biblionumber

The second SQL query is :
SELECT biblio.biblionumber, 0 FROM biblio LEFT JOIN items ON
(biblio.biblionumber=items.biblionumber) LEFT JOIN statistics ON
(items.itemnumber=statistics.itemnumber) WHERE statistics.itemnumber IS NULL
GROUP BY biblio.biblionumber

The problem is that this second query will set to 0 where ANY item has no entry
in statistics table.

I think the best fix is to use "WHERE statistics.type = 'issue'" inside que
JOIN :
LEFT JOIN statistics ON (items.itemnumber=statistics.itemnumber AND
statistics.type = 'issue')

-- 
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.


More information about the Koha-bugs mailing list