Summary: | Recalculating an item's total issue count with update_totalissues.pl ignores deleted items | ||
---|---|---|---|
Product: | Koha | Reporter: | Olli-Antti Kivilahti <olli-antti.kivilahti> |
Component: | Command-line Utilities | Assignee: | Nick Clemens (kidclamp) <nick> |
Status: | Failed QA --- | QA Contact: | Testopia <testopia> |
Severity: | enhancement | ||
Priority: | P5 - low | CC: | david, fridolin.somers, lisette, lucas, victor |
Version: | Main | Keywords: | no-sandbox |
Hardware: | All | ||
OS: | All | ||
Change sponsored?: | --- | Patch complexity: | Trivial patch |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: |
This enhancement to the misc/cronjobs/update_totalissues.pl script[1] adds a new --use-deleted-items option. With this option, a records' usage count will now include deleted items.
[1] This script updates the total issues usage count for a record. For MARC21, this is recorded in 942$o - Koha issues (borrowed), all copies.
|
Version(s) released in: | |
Circulation function: | |||
Attachments: |
Bug 11530: Add a use-deleted-items option to totalissues.pl
Bug 11530: Fix warning of undefined value Bug 11530: Add a use-deleted-items option to totalissues.pl Bug 11530: Fix warning of undefined value Bug 11530: (QA follow-up): fix terminology |
Description
Olli-Antti Kivilahti
2014-01-13 15:14:07 UTC
Since statistics contains only itemnumber, once item deleted we can not link this itemnumber to its biblionumber. (In reply to Fridolin SOMERS from comment #1) > Since statistics contains only itemnumber, once item deleted we can not link > this itemnumber to its biblionumber. What we do is use a union of items and deleteditems in most reports - then you can. Created attachment 175880 [details] [review] Bug 11530: Add a use-deleted-items option to totalissues.pl Some libraries would like to keep the usage from deleted items when calculating total issues from the items. To test: 0 - Apply patch 1 - Checkout/Check in an item several times 2 - perl misc/cronjobs/update_totalissues.pl --use-items 3 - Note the 942$o in the record has the correct count 4 - Delete the item 5 - perl misc/cronjobs/update_totalissues.pl --use-items 6 - Note record count now goes to 0 8 - perl misc/cronjobs/update_totalissues.pl --use-items --use-deleted-items 9 - Note record count correctly restored Created attachment 175881 [details] [review] Bug 11530: Fix warning of undefined value We always check the return of UpdateTotalIssues, we shouldn't let it return null This is a nice fix that I know many libraries will appreciate. Created attachment 176300 [details] [review] Bug 11530: Add a use-deleted-items option to totalissues.pl Some libraries would like to keep the usage from deleted items when calculating total issues from the items. To test: 0 - Apply patch 1 - Checkout/Check in an item several times 2 - perl misc/cronjobs/update_totalissues.pl --use-items 3 - Note the 942$o in the record has the correct count 4 - Delete the item 5 - perl misc/cronjobs/update_totalissues.pl --use-items 6 - Note record count now goes to 0 8 - perl misc/cronjobs/update_totalissues.pl --use-items --use-deleted-items 9 - Note record count correctly restored Signed-off-by: David Nind <david@davidnind.com> Created attachment 176301 [details] [review] Bug 11530: Fix warning of undefined value We always check the return of UpdateTotalIssues, we shouldn't let it return null Signed-off-by: David Nind <david@davidnind.com> Comment on attachment 176300 [details] [review] Bug 11530: Add a use-deleted-items option to totalissues.pl Review of attachment 176300 [details] [review]: ----------------------------------------------------------------- ::: misc/cronjobs/update_totalissues.pl @@ +113,5 @@ > sub process_items { > + my $query = > + $include_deleted > + ? "SELECT all_items.biblionumber, SUM(all_items.issues) FROM (SELECT items.biblionumber,items.issues FROM items UNION ALL SELECT deleteditems.biblionumber, deleteditems.issues FROM deleteditems) all_items GROUP BY all_items.biblionumber;" > + : "SELECT items.biblionumber, SUM(items.issues) FROM items GROUP BY items.biblionumber;"; Just a quick glance at code when passing by: some formatting of the SQL is needed: https://wiki.koha-community.org/wiki/Coding_Guidelines#SQL9:_SELECT Created attachment 177523 [details] [review] Bug 11530: (QA follow-up): fix terminology Even if the script itself has the wrong terminology (issue vs checkout). The POD and help can have the right one. |