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

--- Comment #9 from Nick Clemens (kidclamp) <[email protected]> ---
Created attachment 210084
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210084&action=edit
Bug 42217: Prevent re-harvested data from duplicating usage

A second harvest of a month that was already stored added a new
erm_usage_mus row next to the old one as soon as the count differed, so
the monthly usage was duplicated and the yearly totals doubled. A month
that the provider later corrected to zero was never touched, because
CounterFile skipped every zero cell before it reached the database.

UsageObject->monthly_usages now identifies a row by every column except
usage_count (usage object, provider, year, month, metric type, report
type and, where the report has them, access type and yop) and for each
monthly usage passed in:
- adds a row when none exists
- skips the row when the count is unchanged
- updates the row in place when the count changed
- deletes the rows when the count is zero; zero months are not stored
Duplicates left by earlier harvests are removed and the oldest row is
kept. The rows of the usage object are read once per call and every
change of one call runs in one transaction. CounterFile passes all the
months of a report row in one call, including the zero months.

The job report gains an updated_mus counter next to added_mus and
skipped_mus.

Sponsored-by: Karlsruhe Institute of Technology (KIT)
Assisted-by: Sonnet 5 (Anthropic)
Signed-off-by: Clemens Tubach <[email protected]>
Signed-off-by: Nick Clemens <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to