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

@@ -1,6 +1,6 @@
class Admin::StatsController < Admin::BaseController
def show
@event_names = Ahoy::Event.distinct.order(:name).pluck(:name)
@event_names = Ahoy::Chart.active_event_names
@visits = Visit.count
@debates = Debate.with_hidden.count
@@ -34,7 +34,7 @@ class Admin::StatsController < Admin::BaseController
@event = params[:event]
if params[:event]
@count = Ahoy::Event.where(name: params[:event]).count
@count = Ahoy::Chart.new(params[:event]).count
else
@count = params[:count]
end