changeset 66:1161ad2a4390

Take care of rt removal from gem api Double the default count since filtering is done at gem level, not api.
author nanaya <me@myconan.net>
date Tue, 01 Dec 2015 01:34:12 +0900
parents eecb35eac2f3
children 5dd24a65547b
files app/controllers/tweets_controller.rb app/models/tweet.rb app/views/tweets/show.atom.builder
diffstat 3 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/app/controllers/tweets_controller.rb	Tue Dec 01 01:27:22 2015 +0900
+++ b/app/controllers/tweets_controller.rb	Tue Dec 01 01:34:12 2015 +0900
@@ -6,7 +6,7 @@
 
   def show
     client = Tweet.new(params[:id])
-    @tweets = client.timeline
+    @tweets = client.timeline :exclude_replies => true, :count => 40
     @user = client.user
   rescue Twitter::Error::NotFound
     head :not_found
--- a/app/models/tweet.rb	Tue Dec 01 01:27:22 2015 +0900
+++ b/app/models/tweet.rb	Tue Dec 01 01:34:12 2015 +0900
@@ -1,8 +1,8 @@
 class Tweet
-  def timeline
+  def timeline(options = {})
     @timeline ||=
-      Rails.cache.fetch({ :timeline => @twitter_id }, :expires_in => 5.minutes) do
-        @client.user_timeline(@twitter_id)
+      Rails.cache.fetch({ :timeline => @twitter_id, :options => options }, :expires_in => 5.minutes) do
+        @client.user_timeline(@twitter_id, options)
       end
   end
 
--- a/app/views/tweets/show.atom.builder	Tue Dec 01 01:27:22 2015 +0900
+++ b/app/views/tweets/show.atom.builder	Tue Dec 01 01:34:12 2015 +0900
@@ -3,7 +3,6 @@
   feed.updated @tweets.first.try(:created_at) || Time.at(0)
 
   @tweets.each do |tweet|
-    next if tweet.in_reply_to_status_id.present?
     feed.entry tweet, :url => tweet.uri, :updated => tweet.created_at do |entry|
       entry.title tweet.created_at.rfc2822
       entry.content render(:partial => "tweet", :formats => :html, :locals => { :tweet => tweet }), :type => "html"