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