mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 20:44:40 +08:00
DEV: Ability to collect stats without exposing them via API (#23933)
This adds the ability to collect stats without exposing them
among other stats via API.
The most important thing I wanted to achieve is to provide
an API where stats are not exposed by default, and a developer
has to explicitly specify that they should be
exposed (`expose_via_api: true`). Implementing an opposite
solution would be simpler, but that's less safe in terms of
potential security issues.
When working on this, I had to refactor the current solution.
I would go even further with the refactoring, but the next steps
seem to be going too far in changing the solution we have,
and that would also take more time. Two things that can be
improved in the future:
1. Data structures for holding stats can be further improved
2. Core stats are hard-coded in the About template (it's hard
to fix it without correcting data structures first, see point 1):
63a0700d45/app/views/about/index.html.erb (L61-L101)
The most significant refactorings are:
1. Introducing the `Stat` model
2. Aligning the way the core and the plugin stats' are registered
This commit is contained in:

committed by
GitHub

parent
bdb81b5346
commit
d91456fd53
@ -79,8 +79,8 @@ describe Chat::Statistics do
|
||||
it "counts non-deleted messages created in all status channels in the time period accurately" do
|
||||
about_messages = described_class.about_messages
|
||||
expect(about_messages[:last_day]).to eq(1)
|
||||
expect(about_messages["7_days"]).to eq(3)
|
||||
expect(about_messages["30_days"]).to eq(7)
|
||||
expect(about_messages[:"7_days"]).to eq(3)
|
||||
expect(about_messages[:"30_days"]).to eq(7)
|
||||
expect(about_messages[:previous_30_days]).to eq(2)
|
||||
expect(about_messages[:count]).to eq(10)
|
||||
end
|
||||
@ -90,8 +90,8 @@ describe Chat::Statistics do
|
||||
it "counts open channels created in the time period accurately" do
|
||||
about_channels = described_class.about_channels
|
||||
expect(about_channels[:last_day]).to eq(1)
|
||||
expect(about_channels["7_days"]).to eq(3)
|
||||
expect(about_channels["30_days"]).to eq(5)
|
||||
expect(about_channels[:"7_days"]).to eq(3)
|
||||
expect(about_channels[:"30_days"]).to eq(5)
|
||||
expect(about_channels[:previous_30_days]).to eq(1)
|
||||
expect(about_channels[:count]).to eq(6)
|
||||
end
|
||||
@ -101,8 +101,8 @@ describe Chat::Statistics do
|
||||
it "counts any users who have sent any message to a chat channel in the time periods accurately" do
|
||||
about_users = described_class.about_users
|
||||
expect(about_users[:last_day]).to eq(1)
|
||||
expect(about_users["7_days"]).to eq(2)
|
||||
expect(about_users["30_days"]).to eq(3)
|
||||
expect(about_users[:"7_days"]).to eq(2)
|
||||
expect(about_users[:"30_days"]).to eq(3)
|
||||
expect(about_users[:previous_30_days]).to eq(2)
|
||||
expect(about_users[:count]).to eq(4)
|
||||
end
|
||||
|
Reference in New Issue
Block a user