https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38822 --- Comment #22 from Clemens Tubach <clemens.tubach@kit.edu> --- Created attachment 209378 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=209378&action=edit Bug 38822: Add a period index and the erm_counter_log_summary view The data providers summary page needs one row per usage data provider, report type and harvest year, with the status of the latest counter log for each month. This patch adds the database side of that: - An index on erm_counter_logs (usage_data_provider_id, report_type, report_year, report_month), the natural key of a harvested month. It serves the view below, the Import logs tab and the retry lookup. - A view erm_counter_log_summary, in kohastructure.sql next to erm_usage_yus. It keeps the newest log of each month (by importdate, then id) with a window function and pivots the twelve statuses into month_1 to month_12. Logs without a single-month period (multi-month harvests, uploads covering several months) are not included. MIN(erm_counter_log_id) gives the row a stable primary key for DBIC. The derived table is materialised on every query, so the view scans the single-month logs each time. With the index this stays in milliseconds for tens of thousands of logs. updatedatabase runs the atomicupdate files in name order, so this file runs before bug_41307.pl, which adds the report_type, report_year, report_month and status columns the index and the view read. The file adds them too, under the same guards, so the first run of updatedatabase works in either order and the file that runs second skips them. Sponsored-by: Karlsruhe Institute of Technology (KIT) Assisted-by: Fable 5.1 (Anthropic) Signed-off-by: Clemens Tubach <clemens.tubach@kit.edu> -- You are receiving this mail because: You are watching all bug changes.