Skip to content

Commit

Permalink
Distributions debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
ewlarson committed Nov 21, 2024
1 parent df53a4d commit 9dc0596
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 8 additions & 2 deletions app/models/asset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@ def to_aardvark_reference
hash = {}
if dct_references_uri_key.present?
reference_type = ReferenceType.find_by_name(dct_references_uri_key)
hash[:url] = full_file_url
hash[:label] = label if reference_type.reference_uri.to_s == "http://schema.org/downloadUrl"
hash[reference_type.reference_uri.to_s] = if reference_type.reference_uri.to_s == "http://schema.org/downloadUrl"
{
"url" => full_file_url,
"label" => label
}
else
full_file_url
end
end
hash
end
Expand Down
5 changes: 2 additions & 3 deletions app/models/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def distributions_csv
csv << [friendlier_id, ReferenceType.find_by(reference_uri: key).name, download["url"], download["label"]]
end
else
csv << [friendlier_id, ReferenceType.find_by(reference_uri: key).name, value, nil]
csv << [friendlier_id, ReferenceType.find_by(reference_uri: key)&.name, value, nil]
end
end
csv
Expand All @@ -203,11 +203,10 @@ def apply_assets(distributions)
# - Via DocumentAssets (Assets)
# - With Downloadable URI
if distributable_assets.present?

distributable_assets.each do |asset|
if asset.dct_references_uri_key == "download"
distributions["http://schema.org/downloadUrl"] ||= []
distributions["http://schema.org/downloadUrl"] << asset.to_aardvark_reference
distributions["http://schema.org/downloadUrl"] << asset.to_aardvark_reference["http://schema.org/downloadUrl"]
else
distributions.merge!(asset.to_aardvark_reference)
end
Expand Down

0 comments on commit 9dc0596

Please sign in to comment.