Permalink
Browse files

Quick rake task to dump out all artefacts with their sections

This was requested by designers to help understand the shape of the content as
they revisit the navigation for GOV.UK
  • Loading branch information...
1 parent fe3ce13 commit 37ce461d4c64a8399d441cd83a8b80e15b075bad @jystewart jystewart committed Sep 4, 2012
Showing with 30 additions and 0 deletions.
  1. +30 −0 lib/tasks/reports.rake
View
@@ -0,0 +1,30 @@
+namespace :reports do
+ desc "Generate CSV file of all live artefacts"
+ task live_artefacts: :environment do
+ unless ENV['filename']
+ puts "Please specify an output filename, eg: rake reports:live_artefacts filename=blah.csv"
+ exit(1)
+ end
+
+ column_headings = [:name, :format, :url, :sections]
+
+ require 'csv'
+
+ puts "Generating CSV"
+
+ CSV.open(ENV['filename'], 'w') do |csv|
+ csv << column_headings.collect { |ch| ch.to_s.humanize }
+ Artefact.where(state: 'live').each do |a|
+ row = [
+ a.name,
+ a.kind,
+ "https://www.gov.uk/#{a.slug}"
+ ]
+ row += a.sections.collect { |t| t.title }
+ csv << row
+ print "."
+ end
+ end
+ puts
+ end
+end

0 comments on commit 37ce461

Please sign in to comment.