-
-
Notifications
You must be signed in to change notification settings - Fork 196
Export citations
Graeme Porteous edited this page Feb 8, 2022
·
1 revision
To export all public citiations from your Alaveteli installation you can use the script below.
include Rails.application.routes.url_helpers
include LinkToHelper
default_url_options[:host] = AlaveteliConfiguration.domain
Citation.all.group_by(&:citable).each do |citable, citations|
case citable
when InfoRequest
next if citable.embargo
public_body = citable.public_body
puts "#{citable.title} - #{public_body.short_name || public_body.name} " \
"(#{request_url(citable)})"
when InfoRequestBatch
next if citable.info_requests.any?(&:embargo)
puts "#{citable.title} - a batch to #{citable.public_bodies.count} " \
"authorities (#{show_alaveteli_pro_batch_request_url(citable)})"
end
citations.each do |c|
puts " #{c.source_url}"
end
end
Save the script as export_citations.rb
in the root directory of your Alaveteli installation and then run:
bundle exec rails runner export_citations.rb