Skip to content

Commit

Permalink
exclude draft dois in database from export. #676
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Nov 26, 2020
1 parent 5a768b5 commit b678846
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/controllers/exports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions app/models/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."

Expand Down

0 comments on commit b678846

Please sign in to comment.