Skip to content

Commit

Permalink
use join instead of sub-select
Browse files Browse the repository at this point in the history
  • Loading branch information
acmetech committed Mar 24, 2014
1 parent e8c17db commit f4fb6b2
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions app/models/socializer/activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,14 @@ def self.stream(provider: nil, actor_uid:, viewer_id:)
def self.build_query(viewer_id:)
# for an activity to be interesting, it must correspond to one of these verbs
verbs_of_interest = %w(post share)
verbs_of_interest = Verb.where(name: verbs_of_interest)

# privacy_levels
privacy_level = Socializer::Audience.privacy_level
privacy_public = privacy_level.find_value(:public).value
privacy_circles = privacy_level.find_value(:circles).value
privacy_limited = privacy_level.find_value(:limited).value

query = joins(:audiences).where(verb_id: verbs_of_interest, target_id: nil)
query = joins(:audiences, :verb).where(verb: { name: verbs_of_interest }, target_id: nil)

query.where { (audiences.privacy_level == privacy_public) |
((audiences.privacy_level == privacy_circles) & `#{viewer_id}`.in(my { build_circles_subquery })) |
Expand Down

0 comments on commit f4fb6b2

Please sign in to comment.