Class: WelcomeController

Inherits:
ApplicationController show all
Defined in:
app/controllers/welcome_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/welcome_controller.rb', line 2

def index
  ids = []

  @posts_top = posts_top.where.not(id: ids).limit(3)
  ids += @posts_top.pluck(:id)

  @posts_most_discussed = Post.published.where.not(id: ids).most_discussed.newer_than(1.week.ago).limit(6)
  ids += @posts_most_discussed.pluck(:id)

  @posts_featured = Post.published.where('blogs.featured = ?', true).joins(:blog).where.not('posts.id IN (?)', ids).joins(:blog).recent.limit(6)
  ids += @posts_featured.pluck(:id)

  @posts_recent = stream_scope.where.not(id: ids).recent.limit(30)
  ids += @posts_recent.pluck(:id)
end