From b678846f5c9fbe0c47fbbac59efbb65751fc88aa Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Thu, 26 Nov 2020 19:11:58 +0100 Subject: [PATCH] exclude draft dois in database from export. #676 --- app/controllers/exports_controller.rb | 2 +- app/models/client.rb | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/exports_controller.rb b/app/controllers/exports_controller.rb index d5681859f..049d5e604 100644 --- a/app/controllers/exports_controller.rb +++ b/app/controllers/exports_controller.rb @@ -396,7 +396,7 @@ def repositories csv = headers.to_csv # get doi counts from database - dois_by_client = DataciteDoi.group(:datacentre).count + dois_by_client = DataciteDoi.where(type: "DataciteDoi").where(aasm_state: ["findable", "registered"]).group(:datacentre).count clients.each do |client| # Limit for salesforce default of max 80 chars diff --git a/app/models/client.rb b/app/models/client.rb index f686c57cf..029dacbdf 100644 --- a/app/models/client.rb +++ b/app/models/client.rb @@ -662,11 +662,12 @@ def self.export_doi_counts(query: nil) "Repository Name", "Repository ID", "Organization", - "doisTotal", - "missing", + "DOIs in Index", + "DOIs in Database", + "DOIs missing", ] - dois_by_client = DataciteDoi.group(:datacentre).count + dois_by_client = DataciteDoi.where(type: "DataciteDoi").group(:datacentre).count rows = clients.reduce([]) do |sum, client| db_total = dois_by_client[client.id.to_i].to_i @@ -694,7 +695,7 @@ def self.export_doi_counts(query: nil) sum end - csv = [headers] + rows + csv = [CSV.generate_line(headers)] + rows logger.warn "Found #{csv.size} repositories with missing DOIs."