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

Returns a new instance of MultiStream.


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

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


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

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

#community_spotlight_posts!Object


84
85
86
# File 'lib/evil_query.rb', line 84

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

#followed_tags_posts!Object


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

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

#ids!(query) ⇒ Object


88
89
90
# File 'lib/evil_query.rb', line 88

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

#make_relation!Object


62
63
64
65
66
67
# File 'lib/evil_query.rb', line 62

def make_relation!
  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


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

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