Created
March 14, 2025 22:20
-
-
Save pgwillia/7f845322d93c10e05f26689902a70d69 to your computer and use it in GitHub Desktop.
Open access report for ERA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CSV.open('open_access.csv', 'wb') do |csv| | |
| csv << ['year', 'count', 'community', 'collection', 'collection url'] | |
| open_access_items = Item.select(:member_of_paths, :created_at) | |
| .where(visibility: JupiterCore::VISIBILITY_PUBLIC) | |
| .group_by { |item| item.created_at.year } | |
| open_access_items.each do |year, items| | |
| items.map(&:member_of_paths).flatten.tally.each do |member_of_path, count| | |
| community_id, collection_id = member_of_path.split('/') | |
| csv << [year, count, Community.find(community_id).title, Collection.find(collection_id).title, | |
| Rails.application.routes.url_helpers.community_collection_url(community_id, collection_id)] | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment