Skip to content

Commit

Permalink
Merge pull request #3889 from pulibrary/3848-coin-files-to-label
Browse files Browse the repository at this point in the history
Don't include coins without filesets in "to label" report
  • Loading branch information
eliotjordan authored May 11, 2020
2 parents 49263b4 + 51c69bf commit 97b0d6c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/tasks/numismatics.rake
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ namespace :numismatics do
metadata_adapter = Valkyrie::MetadataAdapter.find(:indexing_persister)
query_service = metadata_adapter.query_service
CSV.open(Rails.root.join("tmp", "numismatic_coins_to_label.csv"), "wb") do |csv|
coins_without_members = query_service.custom_queries.find_resources_without_members(model: Numismatics::Coin)
coins = query_service.find_all_of_model(model: Numismatics::Coin)
coins_with_members = coins - coins_without_members
headers = ["coin_id", "coin_number", "labels"]
csv << headers
coins.to_a.each do |coin|
coins_with_members.to_a.each do |coin|
labels = Wayfinder.for(coin).decorated_members.map { |fs| fs.title.first }
unless labels.include? "Obverse"
unless labels.include?("Obverse") || labels.include?("Reverse")
row = [coin.id.to_s, coin.coin_number, labels.join(";")]
csv << row
end
Expand Down

0 comments on commit 97b0d6c

Please sign in to comment.