add cached tag xml dump

This commit is contained in:
albert
2013-03-30 12:14:38 -04:00
parent 9e10392482
commit bd28711158
2 changed files with 22 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
class ApiCacheGenerator
def generate_tag_cache
File.open("#{RAILS_ROOT}/public/cache/tags-legacy.xml", "w") do |f|
f.puts('<?xml version="1.0" encoding="UTF-8"?>')
f.puts('<tags type="array">')
Tag.find_each do |tag|
name = CGI.escape_html(tag.name)
id = tag.id.to_s
created_at = tag.created_at.try(:strftime, '%Y-%m-%d %H:%M')
post_count = tag.post_count.to_s
category = tag.category
f.puts('<tag name="' + name + '" id="' + id + '" ambiguous="false" created_at="' + created_at + '" count="' + post_count + '" type="' + category + '"></tag>')
end
f.puts('</tags>')
end
end
end

5
script/fixes/011.rb Normal file
View File

@@ -0,0 +1,5 @@
#!/usr/bin/env ruby
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment'))
require 'benchmark'