Skip to content

Instantly share code, notes, and snippets.

@pgwillia
pgwillia / open_access.rb
Created March 14, 2025 22:20
Open access report for ERA
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)]
@pgwillia
pgwillia / publishing_datacite_dois.rb
Created March 13, 2025 21:09
Creating a list of publishing doi's from json export files
require 'csv'
require 'json'
CSV.open('publishing_datacite_dois.csv', 'wb') do |csv|
csv << ['doi', 'title', 'url']
["10.18733.json", "10.20360.json", "10.21225.json", "10.21971.json", "10.18740.json", "10.20361.json", "10.21432.json", "10.21991.json", "10.25336.json"].each do |filename|
file = File.open filename
data = JSON.load file
data["data"].each do |doi|
csv << [doi["attributes"]["doi"], doi["attributes"]["titles"][0]["title"], doi["attributes"]["url"]]
@pgwillia
pgwillia / open_access.csv
Last active February 25, 2025 20:42
ERA Open Access report
year count community collection collection url
2025 22 The department of Cat The annals of 'Cat International' http://era.lvh.me:3000/communities/16ebf0dd-19f0-4ee7-a8f5-dfd533652a81/collections/786ee7fe-c345-4a92-8a3e-833724737f62
2025 2 The department of Cat Theses about cats http://era.lvh.me:3000/communities/16ebf0dd-19f0-4ee7-a8f5-dfd533652a81/collections/618912fe-0d3f-470b-bb99-1ee7bacd69a3
2025 22 The department of Unicorn The annals of 'Unicorn International' http://era.lvh.me:3000/communities/d49ff70a-24fd-42a5-97d0-ac1c7747f56e/collections/99df8858-f7bc-4c25-9dc2-cc7181ced3fc
2025 22 Special reports about dogs The annals of 'Dog International' http://era.lvh.me:3000/communities/0917355b-39a7-4484-bdc7-43e9a6a0ee39/collections/2b8f986f-5123-4148-82fb-56794da56cc9
2025 2 Special reports about dogs Theses about dogs http://era.lvh.me:3000/communities/0917355b-39a7-4484-bdc7-43e9a6a0ee39/collections/61618a4e-16a7-4814-bd23-80afbc38f396
2025 2 The department of Unicorn Theses about unicorns http://era.lv
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 4.
title,url,change
"The effects of Racer 5 India Pale Ale, Bear Republic Bre on librarians",http://era.lvh.me:3000/items/75304ee2-b398-4f9b-9e3a-ac6184ba575b,"{""visibility""=>[""http://terms.library.ualberta.ca/public"", ""http://terms.library.ualberta.ca/authenticated""], ""updated_at""=>[Wed, 19 Feb 2025 20:18:01.903024000 UTC +00:00, Wed, 19 Feb 2025 21:53:11.875437000 UTC +00:00]}"
The effects of Celebrator Doppelbock on librarians,http://era.lvh.me:3000/items/1114f5e1-1066-4ed4-97cf-f8b9cefbfa18,"{""visibility""=>[""http://terms.library.ualberta.ca/public"", ""http://terms.library.ualberta.ca/authenticated""], ""updated_at""=>[Wed, 19 Feb 2025 20:18:01.972254000 UTC +00:00, Wed, 19 Feb 2025 21:53:11.929598000 UTC +00:00]}"
The effects of Samuel Smith’s Oatmeal Stout on librarians,http://era.lvh.me:3000/items/c158881f-cf20-4b5c-a8f5-e2bc41765e03,"{""visibility""=>[""http://terms.library.ualberta.ca/public"", ""http://terms.library.ualberta.ca/authenticated""], ""updated_at""=>[Wed, 19 Feb 2025 20:18:02.050
builder = Nokogiri::XML::Builder.new do |xml|
xml.send('input-forms') {
xml.send('form-value-pairs') {
CONTROLLED_VOCABULARIES[:jupiter_core].keys.each do |vocab_key|
xml.send('value-pairs') {
xml.send('value-pairs-name', vocab_key.to_s)
if Item.rdf_annotation_for_attr(vocab_key).exists?
xml.send('dc-terms',RDF::URI(Item.rdf_annotation_for_attr(vocab_key).first.predicate).pname.to_s) # TODO acts_as_rdfable
else
xml.send('dc-terms',RDF::URI(Thesis.rdf_annotation_for_attr(vocab_key).first.predicate).pname.to_s) # TODO acts_as_rdfable
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 18 columns, instead of 4 in line 3.
community id,community title,collection id,collection link,collection title,item,thesis,edits in last month,edits in last quarter,edits in the last year,duplicate files,shared objects,file size,public,authenticated,embargo,private,draft
21fdad84-77ca-4935-9111-a37a650674e7,The department of Cat,08296bc7-3635-4138-9f79-f554f655c079,http://era.lvh.me:3000/communities/21fdad84-77ca-4935-9111-a37a650674e7/collections/08296bc7-3635-4138-9f79-f554f655c079,The annals of 'Cat International',26,1,41,41,41,1,3,132474,23,1,2,1,0
012f68f2-773f-48ca-9a2f-626a0c7091ef,The Everything Department,0d9542d7-fd21-4335-9b78-0318f20f75b0,http://era.lvh.me:3000/communities/012f68f2-773f-48ca-9a2f-626a0c7091ef/collections/0d9542d7-fd21-4335-9b78-0318f20f75b0,Articles about the relationship between Libraries and non-Libraries,5,3,64,64,64,14,0,1190960,4,0,4,0,0
012f68f2-773f-48ca-9a2f-626a0c7091ef,The Everything Department,1207633a-c4c2-4373-b8b6-0f8279d53df8,http://era.lvh.me:3000/communities/012f68f2-773f-48ca-9a2f-626a0c7091ef/col
@pgwillia
pgwillia / collection_sizes.csv
Last active December 5, 2024 19:45
ERA collections total file sizes
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 4 columns, instead of 2 in line 6.
collection link,collection title,collection size,collection size for humans
http://era.lvh.me:3000/communities/3fab823b-df63-4964-92cd-4d96fb5df3bd/collections/1580d0cc-7c29-44f7-b8ea-983e7588a054,The annals of 'Cat International',132474,129 KB
http://era.lvh.me:3000/communities/3fab823b-df63-4964-92cd-4d96fb5df3bd/collections/336277df-b05f-49c0-856c-b9224642126a,Theses about cats,132474,129 KB
http://era.lvh.me:3000/communities/541e0055-813d-4178-ac36-a94b79cd4127/collections/388bb612-5d5c-4cb9-9f7d-15ccb3f32046,The annals of 'Dog International',132474,129 KB
http://era.lvh.me:3000/communities/541e0055-813d-4178-ac36-a94b79cd4127/collections/808aecb8-c30a-4cdd-b8ad-fea08e45596d,Theses about dogs,132474,129 KB
http://era.lvh.me:3000/communities/11d1643e-0ea8-4b2f-adaa-3a2d2018f803/collections/e9ad79cb-bc09-4fbb-8847-d16711ade4e1,The annals of 'Unicorn International',1323434,1.26 MB
http://era.lvh.me:3000/communities/11d1643e-0ea8-4b2f-adaa-3a2d2018f803/collections/7ffbc573-ff92-4d00-95ee-a60eaf584ca8,Theses a
@pgwillia
pgwillia / destroy_papertrail_report.rb
Last active May 12, 2025 16:57
Reports from ERA/jupiter a) of all destroyed objects tracked by papertrail b) of all items/theses with handles c) items and theses that are drafts or private d) visibility after embargo values d) items and theses with no DOI
CSV.open('destroyed.csv', 'wb') do |csv|
csv << ['item type', 'item id', 'item destroyed at']
PaperTrail::Version.where(event: 'destroy').each do |item|
csv << [item.item_type, item.item_id, item.created_at]
end
end
@pgwillia
pgwillia / docker-compose.yml
Last active July 15, 2024 15:19
Found a openstack swift with keystone. Has potential for testing changes to pmpy. More documentation at https://github.com/kklopfenstein/openstack-swift-keystone-docker. Start with `docker compose up -d`
services:
swift:
# useful if you need to re-run the tests/spec
# https://docs.openstack.org/ocata/cli-reference/swift.html
# manual steps to set environment variables and create container
# swift auth -v -U test:tester -K testing -A http://localhost:8080/auth/v1.0
# swift auth
# swift post ERA
image: kklopfenstein/openstack-swift-keystone-docker
environment: