app/models/observation.rb
def queue_for_sharing
    u = self.user
    ["facebook","twitter"].each do |provider_name|
      explicitly_shared = send("#{provider_name}_sharing") == "1"
      explicitly_not_shared = send("#{provider_name}_sharing") == "0"
      implicitly_shared = u.prefs["share_observations_on_#{provider_name}"]
      user_wants_to_share = explicitly_shared || (implicitly_shared && !explicitly_not_shared)
      if u.send("#{provider_name}_identity") && user_wants_to_share
        # don't queue up more than one job for the given sharing medium. 
        # when the job is run, it will also share any observations made since this one. 
        # observation aggregation for twitter happens in share_on_twitter.
        # fb aggregation happens on their end via open graph aggregations.
        unless Delayed::Job.exists?(["handler LIKE ?", "%user_id: #{u.id}\n%share_on_#{provider_name}%"])
          self.delay(:priority => USER_INTEGRITY_PRIORITY, :run_at => 1.hour.from_now).send("share_on_#{provider_name}")
        end
      end
    end
    true
  end
# Share this and any future observations on twitter and/or fb (depending on user preferences)
Share this and any future observations on twitter and/or fb (depending on user preferences)
Share this and any future observations on twitter and / or fb ( depending on user preferences )
def queue_for_sharing
    u = self.user
    ["facebook","twitter"].each do |provider_name|
      explicitly_shared = send("#{provider_name}_sharing") == "1"
      explicitly_not_shared = send("#{provider_name}_sharing") == "0"
      implicitly_shared = u.prefs["share_observations_on_#{provider_name}"]
      user_wants_to_share = explicitly_shared || (implicitly_shared && !explicitly_not_shared)
      if u.send("#{provider_name}_identity") && user_wants_to_share
        unless Delayed::Job.exists?(["handler LIKE ?", "%user_id: #{u.id}\n%share_on_#{provider_name}%"])
          self.delay(:priority => USER_INTEGRITY_PRIORITY, :run_at => 1.hour.from_now).send("share_on_#{provider_name}")
        end
      end
    end
    true
  end
def queue_for_sharing u = self . user [ "facebook" , "twitter" ] . each do | provider_name | explicitly_shared = send ( "#{provider_name}_sharing" ) == "1" explicitly_not_shared = send ( "#{provider_name}_sharing" ) == "0" implicitly_shared = u . prefs [ "share_observations_on_#{provider_name}" ] user_wants_to_share = explicitly_shared || ( implicitly_shared && ! explicitly_not_shared ) if u . send ( "#{provider_name}_identity" ) && user_wants_to_share unless Delayed :: Job . exists? ( [ "handler LIKE ?" , "%user_id: #{u.id}\n%share_on_#{provider_name}%" ] ) self . delay ( :priority => USER_INTEGRITY_PRIORITY , :run_at => 1 . hour . from_now ) . send ( "share_on_#{provider_name}" ) end end end true end
Share this and any future observations on twitter and/or fb (depending on user preferences)
Share this and any future observations on twitter and / or fb ( depending on user preferences )
# don't queue up more than one job for the given sharing medium.  # when the job is run, it will also share any observations made since this one.  # observation aggregation for twitter happens in share_on_twitter. # fb aggregation happens on their end via open graph aggregations.