Class: Analytic::Period

Inherits:
Object
  • Object
show all
Defined in:
app/models/analytic/period.rb

Constant Summary collapse

PAGES_LIMIT =
8

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(range:) ⇒ Period

Returns a new instance of Period.

Parameters:

  • dates (Range<Time>)


11
12
13
# File 'app/models/analytic/period.rb', line 11

def initialize(range:)
  @range = range
end

Instance Attribute Details

#rangeRange <Time>

Returns:

  • (Range <Time>)


8
9
10
# File 'app/models/analytic/period.rb', line 8

def range
  @range
end

Instance Method Details

#countInteger

Returns:

  • (Integer)


16
# File 'app/models/analytic/period.rb', line 16

delegate :count, to: :views

#distinct_sessions_countInteger

Returns:

  • (Integer)


22
# File 'app/models/analytic/period.rb', line 22

delegate :distinct_sessions_count, to: :views

#distinct_visitors_countInteger

Returns:

  • (Integer)


19
# File 'app/models/analytic/period.rb', line 19

delegate :distinct_visitors_count, to: :views

#pagesArray<Array(String, String, Integer)>

Returns:

  • (Array<Array(String, String, Integer)>)


25
26
27
28
29
30
31
32
# File 'app/models/analytic/period.rb', line 25

def pages
  views
    .group(:host)
    .group(:path)
    .order(count: :desc)
    .limit(PAGES_LIMIT)
    .pluck(:host, :path, Arel.sql('COUNT(*) AS count'))
end