From bb8a15c601fb568e98cc3367bf614ab9d1a0f259 Mon Sep 17 00:00:00 2001 From: Anna Headley Date: Mon, 11 May 2020 13:10:10 -0400 Subject: [PATCH 1/3] Don't include coins without filesets in "to label" report refs #3848 --- lib/tasks/numismatics.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/numismatics.rake b/lib/tasks/numismatics.rake index 4ba74da41f..1b8b329ebf 100644 --- a/lib/tasks/numismatics.rake +++ b/lib/tasks/numismatics.rake @@ -30,7 +30,7 @@ namespace :numismatics do csv << headers coins.to_a.each do |coin| labels = Wayfinder.for(coin).decorated_members.map { |fs| fs.title.first } - unless labels.include? "Obverse" + if labels.present? && !labels.include?("Obverse") row = [coin.id.to_s, coin.coin_number, labels.join(";")] csv << row end From bdff33973cf1349f67f7963f05030e2c81b5eb3a Mon Sep 17 00:00:00 2001 From: Anna Headley Date: Mon, 11 May 2020 13:17:44 -0400 Subject: [PATCH 2/3] Exclude coins with a "reverse" from "to label" report --- lib/tasks/numismatics.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/numismatics.rake b/lib/tasks/numismatics.rake index 1b8b329ebf..8abed2ce31 100644 --- a/lib/tasks/numismatics.rake +++ b/lib/tasks/numismatics.rake @@ -30,7 +30,7 @@ namespace :numismatics do csv << headers coins.to_a.each do |coin| labels = Wayfinder.for(coin).decorated_members.map { |fs| fs.title.first } - if labels.present? && !labels.include?("Obverse") + if labels.present? && !(labels.include?("Obverse") || labels.include?("Reverse")) row = [coin.id.to_s, coin.coin_number, labels.join(";")] csv << row end From 51c69bf90eef3a0783e227df8942b396ff858902 Mon Sep 17 00:00:00 2001 From: Anna Headley Date: Mon, 11 May 2020 13:21:52 -0400 Subject: [PATCH 3/3] Don't check each coin for members; use query service --- lib/tasks/numismatics.rake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/tasks/numismatics.rake b/lib/tasks/numismatics.rake index 8abed2ce31..61efdd880d 100644 --- a/lib/tasks/numismatics.rake +++ b/lib/tasks/numismatics.rake @@ -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 } - if labels.present? && !(labels.include?("Obverse") || labels.include?("Reverse")) + unless labels.include?("Obverse") || labels.include?("Reverse") row = [coin.id.to_s, coin.coin_number, labels.join(";")] csv << row end