Fix bugs for FGU remote_annoucement

Handle exception when category is missing
This commit is contained in:
Manson Wang 2013-10-02 10:25:27 +08:00
parent f851ad0e27
commit f715924929
1 changed files with 2 additions and 1 deletions

View File

@ -3,7 +3,7 @@ require 'open-uri'
require 'json' require 'json'
require 'date' require 'date'
@db = Mongo::Connection.new("localhost", 27017).db("fgu_orbit") @db = Mongo::Connection.new("localhost", 27017).db("test_site")
@coll_bulletin = @db["bulletins"] @coll_bulletin = @db["bulletins"]
@coll_cat = @db["bulletin_categories"] @coll_cat = @db["bulletin_categories"]
@ -23,6 +23,7 @@ def get_remote_bulletins_json(url)
lang = b[1]=='zh-tw' ? "zh_tw".to_sym : "en".to_sym lang = b[1]=='zh-tw' ? "zh_tw".to_sym : "en".to_sym
next if b[2]=="" next if b[2]==""
next if @categories["#{b[7]}"].nil?
bulletin = { _type: "Bulletin", bulletin = { _type: "Bulletin",
postdate: Time.parse(b[8]), postdate: Time.parse(b[8]),