fix dash broad counter
This commit is contained in:
parent
473baa9b95
commit
69ef8fa747
|
@ -4,24 +4,33 @@ module OrbitApp
|
|||
Version = "0.1"
|
||||
|
||||
def display_visitors(options={})
|
||||
impressions = Impression.where(options).and(:referrer.ne => nil).distinct(:session_hash).count
|
||||
map = "function(){ emit( this.referrer,{session_hash: this.session_hash,created_at: this.created_at}); };"
|
||||
reduce = "function(key, values){ var sum = 0; values.forEach(function(doc){sum += doc.amount; }); return {amount: sum};};"
|
||||
if options.blank?
|
||||
impressions = Impression.count #collection.map_reduce(map, reduce,read: :primary, out: "vr")
|
||||
else
|
||||
query = Impression.where(options).selector
|
||||
impressions = Impression.where(options).collection.map_reduce(map, reduce,read: :primary, out: "vr",:query=>query)
|
||||
end
|
||||
impressions.count
|
||||
end
|
||||
|
||||
def display_visitors_today
|
||||
display_visitors(created_at: {'$gte' => Date.today.beginning_of_day, '$lte' => Date.today.end_of_day})
|
||||
display_visitors(created_at: {'$gte' => Date.today.beginning_of_day , '$lte' => DateTime.now})
|
||||
end
|
||||
|
||||
def display_visitors_this_week
|
||||
display_visitors(created_at: {'$gte' => Date.today.beginning_of_week, '$lte' => Date.today.end_of_week})
|
||||
display_visitors(created_at: {'$gte' => Date.today.beginning_of_day - 7.days, '$lte' => DateTime.now})
|
||||
end
|
||||
|
||||
def display_visitors_this_month
|
||||
display_visitors(created_at: {'$gte' => Date.today.beginning_of_month, '$lte' => Date.today.end_of_month})
|
||||
display_visitors(created_at: {'$gte' => Date.today.beginning_of_day - 1.month, '$lte' => DateTime.now})
|
||||
end
|
||||
|
||||
def display_visitors_this_year
|
||||
display_visitors(created_at: {'$gte' => Date.today.beginning_of_year, '$lte' => Date.today.end_of_year})
|
||||
display_visitors(created_at: {'$gte' => Date.today.beginning_of_day - 1.year, '$lte' =>DateTime.now})
|
||||
end
|
||||
end # end of VisitorCounterEval
|
||||
end # of Module
|
||||
end # of OrbitApp
|
||||
|
||||
|
|
Loading…
Reference in New Issue