Fix bugs for FGU remote_annoucement

Added Subtitle support
Handle when there is content in subtitle but no content in text field
This commit is contained in:
Manson Wang 2013-10-02 11:09:08 +08:00
parent f715924929
commit 8200baddbb
1 changed files with 8 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("test_site") @db = Mongo::Connection.new("localhost", 27017).db("fgu_orbit")
@coll_bulletin = @db["bulletins"] @coll_bulletin = @db["bulletins"]
@coll_cat = @db["bulletin_categories"] @coll_cat = @db["bulletin_categories"]
@ -25,6 +25,11 @@ def get_remote_bulletins_json(url)
next if b[2]=="" next if b[2]==""
next if @categories["#{b[7]}"].nil? next if @categories["#{b[7]}"].nil?
if b[5]=="" and b[4]!=""
b[5]=b[4]
b[4]=""
end
bulletin = { _type: "Bulletin", bulletin = { _type: "Bulletin",
postdate: Time.parse(b[8]), postdate: Time.parse(b[8]),
created_at: Time.parse(b[8]), created_at: Time.parse(b[8]),
@ -34,6 +39,7 @@ def get_remote_bulletins_json(url)
is_rejected: false, is_rejected: false,
bulletin_category_id: @categories["#{b[7]}"], bulletin_category_id: @categories["#{b[7]}"],
title: {lang => b[2]}, title: {lang => b[2]},
subtitle: {lang => b[4]},
text: {lang => b[5]}, text: {lang => b[5]},
available_for_zh_tw: true, available_for_zh_tw: true,
available_for_en: true, available_for_en: true,
@ -66,6 +72,7 @@ def get_remote_bulletins_json(url)
:is_rejected => this_bulletin["is_rejected"], :is_rejected => this_bulletin["is_rejected"],
:bulletin_category_id => bulletin[:bulletin_category_id], :bulletin_category_id => bulletin[:bulletin_category_id],
:title => bulletin[:title], :title => bulletin[:title],
:subtitle => bulletin[:subtitle],
:text => bulletin[:text], :text => bulletin[:text],
:available_for_zh_tw => this_bulletin["available_for_zh_tw"], :available_for_zh_tw => this_bulletin["available_for_zh_tw"],
:available_for_en => this_bulletin["available_for_en"], :available_for_en => this_bulletin["available_for_en"],