diff options
author | Rhenium <rhenium@rhe.jp> | 2014-02-21 16:32:57 +0900 |
---|---|---|
committer | Rhenium <rhenium@rhe.jp> | 2014-02-21 16:32:57 +0900 |
commit | 6fceb087af629e7723c51607eb89db345c20eccb (patch) | |
tree | 73b1c172f21264fe04f5119d8a8b07d7437ed1c1 /app/models | |
parent | ed505e5e31da82c0f3f293cd8e66ef8b2664195d (diff) | |
download | aclog-6fceb087af629e7723c51607eb89db345c20eccb.tar.gz |
fix tweets#user_discovered_by
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/tweet.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/app/models/tweet.rb b/app/models/tweet.rb index a89288c..e0cb347 100644 --- a/app/models/tweet.rb +++ b/app/models/tweet.rb @@ -27,9 +27,10 @@ class Tweet < ActiveRecord::Base scope :discovered_by, -> user { load_count = all.limit_value.to_i + all.offset_value.to_i load_count = nil if load_count == 0 - un = [:favorites, :retweets].map {|m| user.__send__(m).select(:tweet_id).order(tweet_id: :desc).limit(load_count).to_sql }.join(") UNION (") - joins("INNER JOIN ((#{un})) reactions ON reactions.tweet_id = tweets.id") + un = [:favorites, :retweets].map {|m| joins(m).where(m => { user: user }).order(id: :desc).limit(load_count).to_sql }.map {|m| "(#{m})" }.join(" UNION ") + + from("(#{un}) AS tweets") } def twitter_url |