Merge branch '1017_ntu_ga_rss' of https://github.com/Rulingcom/orbit into 1017_ntu_ga_rss

This commit is contained in:
Bernie Chiu 2013-11-22 17:42:51 +08:00
commit 40b9448a0e
1 changed files with 3 additions and 3 deletions

View File

@ -7,8 +7,8 @@ DB_NAME = "production_0"
# Create a hash rss site list from mongodb
db = Mongo::Connection.new("localhost", 27017).db("#{DB_NAME}")
SITES = Hash[ db["announcement_feeds"].find().entries.collect {|f| [ f["name"], f["link"] ]} ]
CATEGORIES = db["announcement_feeds"].find().entries.map {|f| f["category"] }
SITES = Hash[ db["announcement_feeds"].find().entries.collect {|f| [ f["name"], f["link"] ] } ]
CATEGORIES = Array(db["announcement_feeds"].find().entries.collect {|f| f["categories"] })
yesterday = Time.now - 86400
two_weeks_ago = Time.new - 60 * 60 * 24 * 14
@ -24,7 +24,7 @@ SITES.each_with_index do |(name, url), i|
feed.items.each do |item|
category = item.category.to_s.gsub(/\<(\/)*category\>/, '')
if item.pubDate > yesterday && (CATEGORIES[i] == category || CATEGORIES[i] == "all")
if item.pubDate > yesterday && CATEGORIES[i].include?(category)
recent_feed[item.title.strip] = { date: item.pubDate, description: item.description.gsub("\r\n", '<br/>').strip,
link: item.link, category: category, source: name }
end