Class: EvilQuery::MultiStream

Inherits:
Base
  • Object
show all
Defined in:
lib/evil_query.rb

Instance Method Summary collapse

Methods inherited from Base

#fetch_ids!, #id_sql

Constructor Details

#initialize(user, order, max_time, include_spotlight) ⇒ MultiStream


45
46
47
48
49
50
51
# File 'lib/evil_query.rb', line 45

def initialize(user, order, max_time, include_spotlight)
  @user = user
  @class = Post
  @order = order
  @max_time = max_time
  @include_spotlight = include_spotlight
end

Instance Method Details

#aspects_post_ids!Object


60
61
62
63
# File 'lib/evil_query.rb', line 60

def aspects_post_ids!
  Rails.logger.debug("[EVIL-QUERY] aspect_post_ids!")
  @user.visible_shareable_ids(Post, :limit => 15, :order => "#{@order} DESC", :max_time => @max_time, :all_aspects? => true, :by_members_of => @user.aspect_ids)
end

#community_spotlight_posts!Object


75
76
77
# File 'lib/evil_query.rb', line 75

def community_spotlight_posts!
  Post.all_public.where(:author_id => fetch_ids!(Person.community_spotlight, 'people.id'))
end

#followed_tags_posts!Object


65
66
67
68
# File 'lib/evil_query.rb', line 65

def followed_tags_posts!
  Rails.logger.debug("[EVIL-QUERY] followed_tags_posts!")
  StatusMessage.public_tag_stream(@user.followed_tag_ids)
end

#ids!(query) ⇒ Object


79
80
81
# File 'lib/evil_query.rb', line 79

def ids!(query)
  fetch_ids!(query.for_a_stream(@max_time, @order), 'posts.id')
end

#make_relation!Object


53
54
55
56
57
58
# File 'lib/evil_query.rb', line 53

def make_relation!
  Rails.logger.debug("[EVIL-QUERY] make_relation!")
  post_ids = aspects_post_ids! + ids!(followed_tags_posts!) + ids!(mentioned_posts)
  post_ids += ids!(community_spotlight_posts!) if @include_spotlight
  Post.where(:id => post_ids)
end

#mentioned_postsObject


70
71
72
73
# File 'lib/evil_query.rb', line 70

def mentioned_posts
  Rails.logger.debug("[EVIL-QUERY] mentioned_posts")
  StatusMessage.where_person_is_mentioned(@user.person)
end