Class: PopularEntries

Inherits:
Object
  • Object
show all
Defined in:
app/services/popular_entries.rb

Class Method Summary collapse

Class Method Details

.month(count) ⇒ Object

Parameters:

  • count (Integer)


17
18
19
# File 'app/services/popular_entries.rb', line 17

def self.month(count)
  Post.of_type('blog_post').visible.posted_after(1.month.ago).popular.first(count)
end

.overall(count) ⇒ Object

Parameters:

  • count (Integer)


22
23
24
# File 'app/services/popular_entries.rb', line 22

def self.overall(count)
  Post.of_type('blog_post').visible.popular.first(count)
end

.prepare(count = 5) ⇒ Object

Parameters:

  • count (Integer) (defaults to: 5)


3
4
5
6
7
8
9
# File 'app/services/popular_entries.rb', line 3

def self.prepare(count = 5)
  {
      week: week(count),
      month: month(count),
      overall: overall(count)
  }
end

.week(count) ⇒ Object

Parameters:

  • count (Integer)


12
13
14
# File 'app/services/popular_entries.rb', line 12

def self.week(count)
  Post.of_type('blog_post').visible.posted_after(7.days.ago).popular.first(count)
end