lib/tweetable/user.rb in tweetable-0.1.11 vs lib/tweetable/user.rb in tweetable-0.1.13
- old
+ new
@@ -28,20 +28,23 @@
u
end
def update_all(force = false)
return unless needs_update?(force)
- update_info if self.config[:include_on_update].include?(:info)
+
+ update_info if self.config[:include_on_update].include?(:info)
update_friend_ids if self.config[:include_on_update].include?(:friend_ids)
update_follower_ids if self.config[:include_on_update].include?(:follower_ids)
update_friend_messages if self.config[:include_on_update].include?(:friend_messages)
+
self.update(:updated_at => Time.now.utc.to_s)
+
self.config[:include_on_update].include?(:messages) ? update_messages : [] # return newly found messages
end
def update_info
- uid = self.user_id.blank? ? self.screen_name : self.user_id
+ uid = self.screen_name # self.user_id.blank? ? self.screen_name : self.user_id
info = self.client.user(uid)
self.user_id = info[:id]
self.screen_name = info[:screen_name].downcase
self.profile_image_url = info[:profile_image_url]
@@ -59,19 +62,19 @@
fids = self.client.follower_ids(:screen_name => self.screen_name, :page => 1) # limit to 5000 friend ids
fids.each{|fid| self.follower_ids << fid}
end
def update_messages(options = {})
- most_recent_message = self.messages.first(:order => 'DESC', :by => :message_id)
+ most_recent_message = self.messages.sort(:order => 'DESC', :by => :message_id).first
options.merge!(:count => self.config[:max_message_count], :screen_name => self.screen_name)
options[:since_id] = most_recent_message.message_id if most_recent_message
timeline = self.client.user_timeline(options)
build_messages(timeline, self.messages)
end
def update_friend_messages(options = {})
- most_recent_message = self.friend_messages.first(:order => 'DESC', :by => :message_id)
+ most_recent_message = self.friend_messages.sort(:order => 'DESC', :by => :message_id).first
options.merge!(:count => self.config[:max_message_count], :screen_name => self.screen_name)
options[:since_id] = most_recent_message.message_id if most_recent_message
timeline = self.client.friends_timeline(options)
build_messages(timeline, self.friend_messages, :create_user => true)
\ No newline at end of file