Permalink
Browse files

Fix references

  • Loading branch information...
avsej committed Aug 21, 2012
1 parent 0c7628a commit 4bedfcc90112dbd1c7875a169be3b30b8409480e
Showing with 23 additions and 1 deletion.
  1. +0 −1 script/export.rb
  2. +23 −0 script/validate.rb
View
@@ -100,7 +100,6 @@ class Brewery < ActiveRecord::Base
doc["style"] = item.style.style_name if item.style
doc["category"] = item.category.cat_name if item.category
id = uuid.next[22..-1]
- mapping[item.id] = id
File.open("out/beers/#{id}.json", "w") do |f|
f.write(Yajl::Encoder.encode(doc))
end
View
@@ -0,0 +1,23 @@
+#encoding: utf-8
+
+require 'yajl'
+
+mapping = {}
+datadir = File.expand_path("#{File.dirname(__FILE__)}/..")
+
+Dir["#{datadir}/breweries/*.json"].each do |file|
+ id = file[%r{/([^/]*)\.json$}, 1]
+ mapping[id] = File.read(file)
+end
+
+missing = []
+Dir["#{datadir}/beers/*.json"].each do |file|
+ id = file[%r{/([^/]*)\.json$}, 1]
+ beer = Yajl::Parser.parse(File.read(file))
+ unless mapping[beer["brewery_id"]]
+ missing << beer["brewery_id"]
+ end
+end
+
+puts missing.uniq
+puts missing.count

0 comments on commit 4bedfcc

Please sign in to comment.