Add a chart showing all events in admin stats

Not sure it's useful, but it makes the main admin stats page a bit more
interesting.
This commit is contained in:
Javi Martín
2024-04-25 02:11:16 +02:00
parent 14454bdd45
commit b5d12959a0
11 changed files with 101 additions and 25 deletions

View File

@@ -1,6 +1,34 @@
require "rails_helper"
describe Ahoy::Chart do
describe ".active_events_data_points" do
it "groups several events together" do
create(:budget_investment, created_at: "2010-01-01")
create(:budget_investment, created_at: "2010-01-02")
create(:legislation_annotation, created_at: "2010-01-01")
create(:legislation_annotation, created_at: "2010-01-03")
expect(Ahoy::Chart.active_events_data_points).to eq({
x: ["2010-01-01", "2010-01-02", "2010-01-03"],
"Budget investments created" => [1, 1, 0],
"Legislation annotations created" => [1, 0, 1]
})
end
it "sorts events alphabetically" do
create(:budget_investment, created_at: "2010-01-01")
create(:legislation_annotation, created_at: "2010-01-01")
I18n.with_locale(:es) do
expect(Ahoy::Chart.active_events_data_points.keys).to eq([
:x,
"Anotaciones creadas",
"Proyectos de gasto creados"
])
end
end
end
describe "#data_points" do
it "raises an exception for unknown events" do
chart = Ahoy::Chart.new(:mystery)