Extract model to handle chart data

We're adding it inside the Ahoy module because the Ahoy::DataSource
class is also in that module. We might move it to a different place in
the future.
This commit is contained in:
Javi Martín
2024-04-24 00:53:25 +02:00
parent 4e72cbe42e
commit 0b2975194b
3 changed files with 23 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ class Admin::Api::StatsController < Admin::Api::BaseController
ds = Ahoy::DataSource.new
if params[:event].present?
ds.add params[:event].titleize, Ahoy::Event.where(name: params[:event]).group_by_day(:time).count
ds.add params[:event].titleize, Ahoy::Chart.new(params[:event]).group_by_day(:time).count
end
if params[:visits].present?