From d10b6476610a8ccf892033b1beb52e33d8eadda1 Mon Sep 17 00:00:00 2001 From: Bernie Chiu Date: Tue, 12 Nov 2013 17:35:54 +0800 Subject: [PATCH] Add resque job for NTU GA Announcemnet feed --- app/jobs/get_announcement_from_ntu_ga_rss.rb | 7 +++++++ config/resque_schedule.yml | 6 ++++++ .../announcement/lib/rss_ntu_ga_aggregate.rb | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 app/jobs/get_announcement_from_ntu_ga_rss.rb diff --git a/app/jobs/get_announcement_from_ntu_ga_rss.rb b/app/jobs/get_announcement_from_ntu_ga_rss.rb new file mode 100644 index 000000000..e7c76dc4f --- /dev/null +++ b/app/jobs/get_announcement_from_ntu_ga_rss.rb @@ -0,0 +1,7 @@ +class GetAnnouncementFromNtuGaRss + @queue = :high + + def self.perform() + %x(ruby "#{Rails.root}/vendor/built_in_modules/announcement/lib/rss_ntu_ga_aggregate.rb") + end +end \ No newline at end of file diff --git a/config/resque_schedule.yml b/config/resque_schedule.yml index 3a18d0e3f..e6030def1 100644 --- a/config/resque_schedule.yml +++ b/config/resque_schedule.yml @@ -33,3 +33,9 @@ get_announcement_from_rss: class: GetAnnouncementFromRss args: description: Loop through the announcement RSS until 24h ago + +get_announcement_from_ntu_ga_rss: + cron: 0 0 [2,12] * * * + class: GetAnnouncementFromNtuGaRss + args: + description: Update announcement RSS to primary NTU_GA site diff --git a/vendor/built_in_modules/announcement/lib/rss_ntu_ga_aggregate.rb b/vendor/built_in_modules/announcement/lib/rss_ntu_ga_aggregate.rb index c15751801..b61333391 100644 --- a/vendor/built_in_modules/announcement/lib/rss_ntu_ga_aggregate.rb +++ b/vendor/built_in_modules/announcement/lib/rss_ntu_ga_aggregate.rb @@ -30,7 +30,7 @@ SITES.each do |name, url| feed.items.each do |item| category = item.category.to_s.gsub(/\<(\/)*category\>/, '') - if item.pubDate > two_weeks_ago + if item.pubDate > yesterday recent_feed[item.title.strip] = { date: item.pubDate, description: item.description.gsub("\r\n", '
').strip, link: item.link, category: category } end