Skip to content

Commit

Permalink
Bing support for mentions
Browse files Browse the repository at this point in the history
  • Loading branch information
tashian committed Jun 27, 2011
1 parent 5ddca41 commit c91cfd4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/models/person.rb
Expand Up @@ -8,7 +8,7 @@ class Person < ActiveRecord::Base
# for geometry options
has_attached_file :photo, :styles => {:full => '90', :thumb => '50x50#'}, :convert_options => { :all => '-gravity north'}

acts_as_noteworthy :with => [:official_name], :geo => "state.name"
acts_as_noteworthy :with => [:official_name], :geo => "state.try(:name)"

validates_inclusion_of :gender, :in => %w(M F), :allow_blank => true
validates_presence_of :first_name, :last_name
Expand Down
1 change: 1 addition & 0 deletions config/initializers/govkit.rb
Expand Up @@ -7,5 +7,6 @@
config.ftm_apikey = ApiKeys.follow_the_money
config.opencongress_apikey = ApiKeys.opencongress
config.technorati_apikey = ApiKeys.technorati
config.bing_appid = ApiKeys.bing
end
end
24 changes: 12 additions & 12 deletions lib/open_gov/mentions.rb
Expand Up @@ -27,24 +27,24 @@ def import_people
private

def make_mentions(obj)
puts "#{obj.to_param}"
raw_mentions = obj.raw_mentions

raw_mentions[:google_news].map { |c| make_mention(obj, c, "Google News") }
raw_mentions[:google_blogs].map { |c| make_mention(obj, c, "Google Blogs") }
[:bing, :google_news, :google_blogs].each do |type|
raw_mentions[type].map { |c| make_mention(obj, c) }
end

obj.save!
end

def make_mention(owner, mention, source)
owner.mentions.find_or_create_by_url(mention.url) do |c|
c.source = mention.source[0..253]
c.date = Date.valid_date!(mention.date)
c.weight = mention.weight
c.title = mention.title
c.excerpt = mention.excerpt
c.search_source = source
end
def make_mention(owner, mention)
c = owner.mentions.find_or_create_by_url(mention.url)
c.source = mention.source[0..253]
c.date = Date.valid_date!(mention.date)
c.weight = mention.weight
c.title = mention.title
c.excerpt = mention.excerpt
c.search_source = mention.search_source
c.save!
end
end
end

0 comments on commit c91cfd4

Please sign in to comment.