Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Commit

Permalink
Fix user id in API call
Browse files Browse the repository at this point in the history
  • Loading branch information
joegatt committed Sep 8, 2013
1 parent 386a849 commit 061aad5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 7 additions & 8 deletions app/models/pantograph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,19 @@ def self.calculate_after(previous)
def self.update_saved_timeline
min_id = first.nil? ? 0 : first.tweet_id
get_timeline(min_id)
min_id
end

private

def self.get_timeline(min_id)
authenticated_twitter_client.home_timeline(trim_user: true, min_id: min_id).each do |tweet|
user = Pantographer.first_or_create(twitter_user_id: tweet.user.id)
create(
body: sanitize(tweet.text),
external_created_at: tweet.created_at,
tweet_id: tweet.id,
pantographer_id: user.id
)
user = Pantographer.first_or_create(twitter_user_id: tweet.user.id)
create(
body: sanitize(tweet.text),
external_created_at: tweet.created_at,
tweet_id: tweet.id,
pantographer_id: user.id
)
end
end

Expand Down
4 changes: 3 additions & 1 deletion app/models/pantographer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class Pantographer < ActiveRecord::Base

def self.follow_followers
client = Pantographer.authenticated_twitter_client
# REVIEW: Can we just get id using frinds_ids?
# Can we send the array straight to follow/unfollow
followers = client.followers(skip_status: true, include_user_entities: false).to_a
friends = client.friends(skip_status: true, include_user_entities: false).to_a
(friends - followers).each { |user| client.unfollow(user.id) }
Expand All @@ -23,7 +25,7 @@ def self.follow_followers
protected

def get_user_details
twitter_user = Pantographer.authenticated_twitter_client.user(id: twitter_user_id)
twitter_user = Pantographer.authenticated_twitter_client.user(twitter_user_id)
self.twitter_screen_name = twitter_user.screen_name
self.twitter_real_name = twitter_user.name
end
Expand Down

0 comments on commit 061aad5

Please sign in to comment.