Main Koha release repository https://koha-community.org
Find a file
Fridolin Somers 18afaf438b
Bug 24527: misc/cronjobs/update_totalissues.pl problem with multiple items
misc/cronjobs/update_totalissues.pl when issuing statistics table, no-incremental,  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.
So when running it sets 0 to the biblio that had a value from first
query.

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')

Test plan :
1) Begin with an empty database
2) Create a biblio 1 with no items
3) Create a biblio 2 with 3 items
4) Create a biblio 3 with 2 items
5) Checkout and checkin all items of biblio 2
6) Checkout and checkin the firt item of biblio 3
7) run misc/cronjobs/update_totalissues.pl --use-stats -v
8) Check biblio 1 has biblioitems.totalissues = 0
9) Check biblio 2 has biblioitems.totalissues = 3
10) Without patch the biblio 3 has biblioitems.totalissues = 0
11) With patch the biblio 3 has biblioitems.totalissues = 1
12) Check misc/cronjobs/update_totalissues.pl --incremental is OK

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2020-02-24 13:14:24 +00:00
acqui Bug 21921: Add date publication year to biblio Z39.50 search form in acquisition 2020-02-17 13:44:34 +00:00
admin Bug 17702: Add UI to manage account credit types 2020-02-20 14:46:33 +00:00
api/v1 Bug 24592: Reword LOST_RETURN to LOST_FOUND 2020-02-13 15:58:49 +00:00
authorities Bug 24103: Add option to dump search query to templates 2020-02-19 15:58:41 +00:00
basket
C4 Bug 24705: Holds placed via SIP will be given first priority 2020-02-24 09:57:07 +00:00
catalogue Bug 18433: Allow to select results to export in item search 2020-02-19 16:07:58 +00:00
cataloguing Bug 24103: Add option to dump search query to templates 2020-02-19 15:58:41 +00:00
circ Bug 23084: Replace grep {^$var$} with grep {$_ eq $var} 2020-02-17 10:44:45 +00:00
clubs Bug 23084: Replace grep {^$var$} with grep {$_ eq $var} 2020-02-17 10:44:45 +00:00
course_reserves
debian Bug 24588: (RM follow-up) Update debian/control 2020-02-21 17:13:17 +00:00
docs Koha 19.12 - Dobbie is a free elf... 2019-12-02 17:13:15 +00:00
errors Bug 23329: Move error page to its own subroutine 2019-11-27 11:30:19 +00:00
etc Bug 22220: Fix bib Apache rewrite rule for intranet 2020-01-20 14:03:49 +00:00
ill
installer Bug 24707: Remove AMICUS from default fr-CA z39.50 servers 2020-02-24 10:03:32 +00:00
Koha Bug 24588: Prevent e-mails from Koha to be flagged as spam 2020-02-21 16:06:18 +00:00
koha-tmpl Bug 24711: Don't add logout input to login form 2020-02-24 09:55:48 +00:00
labels Bug 7468: Use Modern::Perl 2020-01-21 11:29:22 +00:00
members Bug 22359: Prevent undercollection at the server 2020-02-21 15:39:41 +00:00
misc Bug 24527: misc/cronjobs/update_totalissues.pl problem with multiple items 2020-02-24 13:14:24 +00:00
offline_circ
opac Bug 23482: Fix BakerTaylor cover images on lists 2020-02-21 15:44:01 +00:00
OpenILS
patron_lists
patroncards
plugins
pos Bug 24477: Require takepayment permission in pos/pay.pl 2020-01-23 08:51:36 +00:00
reports Bug 23084: Replace grep {^$var$} with grep {$_ eq $var} 2020-02-17 10:44:45 +00:00
reserve Bug 14711: Change prototype for AddReserve - pass a hashref 2020-02-11 14:32:47 +00:00
reviews Bug 18789: Send Koha::Patron object to the templates 2018-02-16 13:03:58 -03:00
rotating_collections
serials Bug 14711: Change prototype for AddReserve - pass a hashref 2020-02-11 14:32:47 +00:00
services
skel
suggestion Bug 23594: Restore previous view after delete or update itemtype 2020-01-30 10:56:57 +00:00
svc Bug 23427: Simplify sort logic 2019-11-07 13:25:10 +00:00
t Bug 24705: Add tests 2020-02-24 09:57:01 +00:00
tags
tmp/modified_authorities
tools Bug 14647: (follow-up) Changes to script 2020-02-20 08:59:31 +00:00
virtualshelves Bug 23084: Replace grep {^$var$} with grep {$_ eq $var} 2020-02-17 10:44:45 +00:00
xt
.editorconfig
.eslintrc.json Bug 23834: Add default ESLint configuration 2019-11-03 08:02:39 +00:00
.gitignore
.htaccess Fix file permissions: if it is not a script, it should not be executable. 2010-04-16 00:40:34 -04:00
.mailmap
.scss-lint.yml
about.pl Bug 19735: Add support for max_ver 2020-02-12 16:33:02 +00:00
changelanguage.pl
cpanfile Bug 24588: Prevent e-mails from Koha to be flagged as spam 2020-02-21 16:06:18 +00:00
fix-perl-path.PL
gulpfile.js
help.pl
INSTALL
Koha.pm Bug 17702: DBRev 19.12.00.029 2020-02-20 14:51:24 +00:00
koha_perl_deps.pl
kohaversion.pl
LICENSE
mainpage.pl
Makefile.PL Bug 19735: Move Perl deps definitions into a cpanfile 2020-02-12 16:33:02 +00:00
MANIFEST.SKIP
package.json Bug 23025: security vulnerability detected in fstream < 1.0.12 defined in yarn.lock 2019-11-27 11:30:17 +00:00
README
README.md
README.robots
rewrite-config.PL
yarn.lock Bug 23025: Update yarn.lock 2019-11-27 11:30:17 +00:00

Koha is a free software integrated library system (ILS).

Koha is distributed under the GNU GPL version 3 or later.

Note: This is a synced mirror of the official Koha repo.

Note: Koha does not accept pull requests from git hosting sites.

Note: This project has its own bug tracker, to report a bug or submit a patch visit http://bugs.koha-community.org.

For guidelines on submitting patches for Koha please visit https://wiki.koha-community.org/wiki/SubmitingAPatch

The developers handbook can be found at https://wiki.koha-community.org/wiki/Developer_handbook

http://koha-community.org/

Koha Logo