Permalink
Browse files

Removed Twitter code from Rails app (in Java app. now.)

  • Loading branch information...
1 parent b91aaaa commit b359bb6febbcbe1004e41b287f7099018bda63c0 @paulmwatson committed Mar 19, 2009
Showing with 3 additions and 309 deletions.
  1. +0 −76 app/controllers/mentions_controller.rb
  2. +0 −1 app/views/cities/index.html.erb
  3. +3 −3 app/views/site/about.html.erb
  4. +0 −1 config/routes.rb
  5. +0 −228 public/index.html
@@ -11,10 +11,6 @@ def index
@range_start = @range_center - (@range / 2)
@range_end = @range_center + (@range / 2)
- # Data is updated hourly for today
- last_update = History.find :first, :conditions => {:city_id => @city.id, :phrase_id => @phrase.id}, :order => :last_get
- update(@phrase, @city, @range_center) if params[:update] || !last_update || last_update.last_get < (Time.now - (60 * 60))
-
@mentions = Mention.find :all, :select => "DATE(mentioned_at) as mentioned_at_date, mentioned_at, substring_index(mentioner, ' (', 1) as mentioner_stripped, mentioner, link, exact_location", :group => 'mentioned_at_date, mentioner_stripped', :conditions => {:phrase_id => @phrase.id, :city_id => @city.id, :mentioned_at => ("#{@range_start.year}-#{@range_start.month.to_s.rjust(2, '0')}-#{@range_start.day.to_s.rjust(2, '0')} 00:00".."#{@range_end.year}-#{@range_end.month.to_s.rjust(2, '0')}-#{@range_end.day.to_s.rjust(2, '0')} 23:59")}, :order => :mentioned_at
@twenty_four_hour_count = Mention.find :all, :select => "DATE(mentioned_at) as mentioned_at_date, mentioned_at, substring_index(mentioner, ' (', 1) as mentioner_stripped, mentioner, link, exact_location", :group => 'mentioner_stripped, mentioned_at_date', :conditions => {:phrase_id => @phrase.id, :city_id => @city.id, :mentioned_at => ("#{@range_center.year}-#{@range_center.month.to_s.rjust(2, '0')}-#{@range_center.day.to_s.rjust(2, '0')} 00:00".."#{@range_center.year}-#{@range_center.month.to_s.rjust(2, '0')}-#{@range_center.day.to_s.rjust(2, '0')} 23:59")}
begin
@@ -23,48 +19,6 @@ def index
@graph_max = 0
end
end
-
- def update(phrase, city, sample_date)
- require 'hpricot'
- require 'open-uri'
-
- location = get_location(city.name, city.country)
-
- search_radius = 10
-
- day = "%02d" % sample_date.day
- month = "%02d" % sample_date.month
- year = sample_date.year
- twitter_geo_search_url = "http://search.twitter.com/search.atom?q=#{phrase.search.gsub(' ', '%20')}&geocode=#{location.latitude}%2C#{location.longitude}%2C#{search_radius}km&rpp=100&since=#{year}-#{month}-#{day}&until=#{year}-#{month}-#{day}"
- begin
- tweet_doc = open(twitter_geo_search_url) { |f| Hpricot(f) }
- history = History.find(:first, :conditions => {:city_id => @city.id, :phrase_id => @phrase.id}) || History.new
- history.city_id = city.id
- history.phrase_id = phrase.id
- history.last_get = Time.now
- history.save
- rescue
- end
-
- if tweet_doc
- tweets = tweet_doc.search('//entry')
-
- tweets.each do |tweet|
- link = tweet.search('//link')[0].attributes['href']
- mention = Mention.find(:first, :conditions => {:link => link}) || Mention.new
- mention.link = link
- mention.mentioner = tweet.search('//name').text
- mention.mentioned_at = tweet.search('//published').text
- mention.exact_location = tweet.search('//google:location').text
- get_location(mention.exact_location, city.country)
- mention.city = city
- mention.phrase = phrase
- mention.message = tweet.search('//title').text
- mention.source_id = tweet.search('//id').text.split(':')[2]
- mention.save
- end
- end
- end
def get_location(city, country)
require 'hpricot'
@@ -94,34 +48,4 @@ def get_location(city, country)
end
location
end
-
- # Temporary import of Dan's 60 days of data
- def import_60_days
- require 'hpricot'
-
- cities = City.find :all
- cities.each do |city|
- phrases = Phrase.find :all
- phrases.each do |phrase|
- puts "Importing #{city.name} - #{phrase.title}"
- doc = open("./public/temp/60days/#{city.name.gsub(' ', '')}-#{phrase.title.gsub(' ','+')}") { |f| Hpricot(f) }
- tweets = doc.search('//entry')
- tweets.each do |tweet|
- link = tweet.search('//link')[0].attributes['href']
- mention = Mention.find(:first, :conditions => {:link => link}) || Mention.new
- mention.link = link
- mention.mentioner = tweet.search('//name').text
- mention.mentioned_at = tweet.search('//published').text
- mention.exact_location = tweet.search('//google:location').text
- mention.city = city
- mention.phrase = phrase
- mention.message = tweet.search('//title').text
- mention.source_id = tweet.search('//id').text.split(':')[2]
- mention.save
- end
- end
- end
-
- render :text => 'Imported lots'
- end
end
@@ -30,7 +30,6 @@
<a class="forward button" href="http://github.com/paulmwatson/sickcity"><img src="/images/bk2l.png" />Download SickCity</a>
<a class="forward button" href="/about/"><img src="/images/bk2l.png" />About</a>
</div>
-
<script type="text/javascript">
$('.tiny_graph').sparkline();
</script>
@@ -1,12 +1,12 @@
<div class="info" style="background-color: #fff;">
<a href="http://diycity.org"><img src="/images/diycity.png" /></a>
<h1>Realtime disease detection for your city</h1>
- <p>SickCity watches <a href="http://twitter.com">Twitter</a> (and soon <a href="http://facebook.com">Facebook</a>) for any mentions of disease in a city. It then collects this information and presents it over time through graphs.</p>
- <p>SickCity is still quite new. Our algorithms are improving everyday and we are still getting in historical data for some cities.</p>
+ <p>SickCity watches <a href="http://twitter.com">Twitter</a> (and soon <a href="http://facebook.com">Facebook</a>) for any mentions of disease in a city. It then collects this information and presents it over time through graphs. SickCity is still quite new. Our algorithms are improving everyday and we are still getting in historical data for some cities.</p>
+ <p><a href="http://diycity.org/sickcity-realtime-disease-detection-your-city">Help us improve SickCity</a>.</p>
<p>SickCity was built for the <a href="http://diycity.org/sickcity-realtime-disease-detection-your-city">DIYCity Outbreak challenge</a>.</p>
<p>The <a href="http://github.com/paulmwatson/sickcity">source code is on github</a>.</p>
<p>Contributors; Paul Watson, John Geraci, Daniel Greenblatt, A. Chadha, Clint McMahon.</p>
- <p>Contact <a href="mailto:diy@diycity.org">diy@diycity.org</a> for any problems, ideas, concerns etc. Get involved.</p>
+ <p>Contact <a href="mailto:diy@diycity.org">diy@diycity.org</a> for any problems, ideas, concerns etc.</p>
</div>
<div class="navbar">
<a class="back" href="/">Cities<img src="/images/bkr.png" /></a>
View
@@ -9,7 +9,6 @@
map.connect '/:country/:city/:phrase', :controller => 'mentions'
map.connect '/:country/:city/:phrase/:date', :controller => 'mentions'
- map.connect '/:country/:city/:phrase/:date/update', :controller => 'mentions', :update => true
map.resources :cities
Oops, something went wrong.

0 comments on commit b359bb6

Please sign in to comment.