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

--- Comment #13 from Matt Blenkinsop <[email protected]> ---
Created attachment 209467
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=209467&action=edit
Bug 41307: Backfill the period of existing counter logs and remove duplicated
usage

The counter log rows written before this patch have no report type and
no period, so the data providers summary skips every month harvested
before the upgrade, and the Import logs tab shows those rows without a
report type or a period. Re-harvests before Bug 42217 also left
duplicated rows in erm_usage_mus, which double the yearly totals.

The atomicupdate now backfills the rows that have no period:
- the report type is the one of the counter file
- the months come from the Reporting_Period header row of the file, or
  from its month columns when the file has no such row. Before Bug 41294
  one harvest covered several months, so such a row becomes one row per
  month, all with the same file, import date, user and status
- every month gets status success: the old code only wrote a log row
  after a file was imported
- the background job is not linked
A row whose file has no reporting period is reported and left without a
period. The backfill only reads the first 4000 bytes of each file and
runs again without changes.

It then removes the duplicated monthly usage rows, with the identity of
Bug 42217 (every column except usage_count). The newest row is kept: the
harvest path of 42217 keeps the lowest id because it overwrites the
count, but here there is no harvested count, and the newest row holds
the last count the provider sent.

Test plan:
1. On a database with harvests made before this patch, or after
   UPDATE erm_counter_logs SET report_type = NULL, report_year = NULL,
   report_month = NULL; on a few rows, run updatedatabase: it reports the
   rows updated and added
2. Open the provider, Import logs tab: every old row now shows its report
   type and period; a file that covered several months has one row per
   month, all with the same file name and Download link
3. Open the Summary page: the old months show "Success"
4. Run updatedatabase again: no counter log is changed
5. Duplicate a row of erm_usage_mus with a different usage_count and run
   updatedatabase: the older row is removed and the yearly total of the
   title is correct again

Assisted-by: Fable 5.1 (Anthropic)

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