From 7efca14176b1e9a79e15cad11e434beeb0cc30f3 Mon Sep 17 00:00:00 2001 From: Ryan Scherle Date: Tue, 4 Apr 2023 21:01:18 +0000 Subject: [PATCH] calculate tiered prices by sponsor, not journal --- lib/tasks/stash_engine_tasks.rake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/tasks/stash_engine_tasks.rake b/lib/tasks/stash_engine_tasks.rake index dd7ba5857b..32aaace19d 100644 --- a/lib/tasks/stash_engine_tasks.rake +++ b/lib/tasks/stash_engine_tasks.rake @@ -593,6 +593,7 @@ namespace :identifiers do CSV.open(tiered_filename, 'w') do |csv| csv << %w[SponsorName JournalName Count Price] sponsor_summary = [] + sponsor_total_count = 0 StashEngine::JournalOrganization.all.each do |org| journals = org.journals_sponsored_deep journals.each do |j| @@ -605,13 +606,16 @@ namespace :identifiers do sponsor_summary << [item['DOI'], j.title, item['ApprovalDate']] end end - csv << [org.name, j.title, journal_item_count, tiered_price(journal_item_count)] + csv << [org.name, j.title, journal_item_count, ''] + sponsor_total_count += journal_item_count end next if sponsor_summary.blank? + csv << [org.name, 'TOTAL', sponsor_total_count, tiered_price(sponsor_total_count)] write_tiered_sponsor_summary(name: org.name, file_prefix: prefix, report_period: time_period, table: sponsor_summary) sponsor_summary = [] + sponsor_total_count = 0 end end