aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2015-12-28 18:46:13 +0100
committerHarald Eilertsen <haraldei@anduin.net>2015-12-28 18:48:26 +0100
commit48bb021c0092b343ef387780c43c875b92e8a739 (patch)
tree41dec24d19a43833ea9e4d82502312d1bb0830d3
parenta8c79cac4d1d2ef98a9fe28a728abce1493411e4 (diff)
downloadhmnoweb-48bb021c0092b343ef387780c43c875b92e8a739.tar.gz
hmnoweb-48bb021c0092b343ef387780c43c875b92e8a739.tar.bz2
hmnoweb-48bb021c0092b343ef387780c43c875b92e8a739.zip
Add simple year review script.
-rw-r--r--script/year-review.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/script/year-review.rb b/script/year-review.rb
new file mode 100644
index 0000000..3e25b1d
--- /dev/null
+++ b/script/year-review.rb
@@ -0,0 +1,18 @@
+#!/usr/bin/env ruby
+#
+# Run with reils runner like this:
+#
+# RAILS_ENV=production rails runner script/year-review.rb
+#
+# Thie ensures it runs in the context of the application.
+
+def normalize(t)
+ t.gsub("'", '"')
+end
+
+cat = Refinery::Blog::Category.where(:title => "Omtaler").first
+start_date = Date.new(Date.today.year, 01, 01)
+posts = cat.posts.where("published_at > :date", { :date => start_date })
+posts.each do |p|
+ puts "'#{normalize(p.title)}', #{p.published_at}, #{p.author.username}, http://heavymetal.no/blog/posts/#{p.slug}"
+end