Commit Graph

36 Commits

Author SHA1 Message Date
Javi Martín
b5d12959a0 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.
2024-05-09 14:28:32 +02:00
Javi Martín
f7e2d724dd Replace ahoy events with real data
We were tracking some events with Ahoy, but in an inconsistent way. For
example, we were tracking when a debate was created, but (probably
accidentally) we were only tracking proposals when they were created
from the management section. For budget investments and their supports,
we weren't using Ahoy events but checking their database tables instead.
And we were only using ahoy events for the charts; for the other stats,
we were using the real data.

While we could actually fix these issues and start tracking events
correctly, existing production data would remain broken because we
didn't track a certain event when it happened. And, besides, why should
we bother, for instance, to track when a debate is created, when we can
instead access that information in the debates table?

There are probably some features related to tracking an event and their
visits, but we weren't using them, and we were storing more user data
than we needed to.

So we're removing the track events, allowing us to simplify the code and
make it more consistent. We aren't removing the `ahoy_events` table in
case existing Consul Democracy installations use it, but we'll remove it
after releasing version 2.2.0 and adding a warning in the release notes.

This change fixes the proposal created chart, since we were only
tracking proposals created in the management section, and opens the
possibility to add more charts in the future using data we didn't track
with Ahoy.

Also note the "Level 2 user Graph" test wasn't testing the graph, so
we're changing it in order to test it. We're also moving it next to the
other graphs test and, since we were tracking the event when we were
confirming the phone, we're renaming to "Level 3 users".

Finally, note that, since we were tracking events when something was
created, we're including the `with_hidden` scope. This is also
consistent with the other stats shown in the admin section as well as
the public stats.
2024-05-09 14:28:32 +02:00
Javi Martín
0b2975194b 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.
2024-05-09 14:28:31 +02:00
Javi Martín
646dccca0a Rename event_types variable to event_names
This is consistent with the `name` column in `ahoy_events`.
2024-05-09 14:28:31 +02:00
Javi Martín
9491b20314 Extract method to get vote counts by votable type 2023-08-30 14:46:34 +02:00
Javi Martín
b536a7cb77 Extract component for supporting budget admin stats
This is consistent with the component for balloting stats. We're about
to change both components, and the changes are easier to follow if
they're similar.

We're also using consistent names in methods.
2023-02-20 14:21:22 +01:00
Javi Martín
76b08398cf Extract component for balloting budget admin stats
We're also moving the tests, but we're keeping one system test in order
to test the controller and the navigation to get to this page.

Note we're slightly changing the order of the methods in the component;
the order of the instance variables was `user_`, `vote_`, `vote_`,
`user_`, which was hard to follow.
2023-02-20 14:20:50 +01:00
Javi Martín
69dda19af7 Add and apply Rails/PluckId rubocop rule 2021-08-09 23:52:47 +02:00
Senén Rodero Rodríguez
9b2d349e21 Create SDG stats page 2021-01-23 12:23:29 +01:00
Javi Martín
4658e18db5 Re-add and apply Rails/UniqBeforePluck rule
We removed it in commit d639cd58 because it recommended using `uniq`
where `distinct` was more appropriate. This has been fixed in
rubocop-rails 2.6.0.
2020-10-26 11:26:34 +01:00
Javi Martín
eafb4018bf Apply Style/CollectionMethods rubocop rule
We were already using `map` and `reduce` almost everywhere.
2019-10-26 13:03:49 +02:00
Javi Martín
db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00
Javi Martín
f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00
Julian Herrero
fd71ed825b Avoid error when accessing final votes stats before balloting phase
When accessing the URL `/admin/stats/budget_balloting?budget_id=X'
for a budget in a phase prior to the balloting phase, the following
error was raised due to the stats where not calculated yet.
Instead, we'll now show a flash message.

NoMethodError:
  undefined method `[]' for nil:NilClass
  ./app/controllers/admin/stats_controller.rb:82
2019-06-10 17:28:16 +02:00
voodoorai2000
d0b8fef6b3 Delete spending proposals 2019-05-31 18:22:59 +02:00
Juanjo Bazán
110ee961e3 adds budget stats for final voting to admin stats 2019-05-16 14:45:46 +02:00
Juanjo Bazán
5be54b57da reduces current admin budget stats as supporting phase 2019-05-16 14:45:45 +02:00
rgarcia
11437a1d40 add budget investment stats 2019-05-16 13:41:49 +02:00
rgarcia
cfe3f95f5c moves graphs to individual views 2019-05-16 13:37:47 +02:00
Julian Herrero
d24376f6ad Use double quotes in controllers/ 2019-03-13 22:19:49 +01:00
Angel Perez
9029acd440 Fix Rubocop warnings for Admin controllers [ci skip] 2018-09-07 13:59:07 -04:00
Bertocq
c0dcd03bab Prevent valuation comments from appearing in public pages 2018-01-31 18:14:11 +01:00
iagirre
5a3e701e8d Polls' stats migrated from Madrid's fork and sortable functions added for tables 2017-10-23 13:19:22 +02:00
rgarcia
b1fa2d22f7 only count active users in stats 2017-06-13 12:59:04 +02:00
Alberto Garcia Cabeza
60d08ab565 improves query on admin stats controller 2017-04-26 13:12:55 +02:00
Alberto Garcia Cabeza
45af9ce5aa adds budget investments numbers and chart on admin stats 2017-04-25 16:46:20 +02:00
rgarcia
bb3c4c6399 adds consistency to ruby code style
Keep a blank line before and after private
Keep a blank line before and after protected
Remove extra empty line at class body end
Remove extra blank line
Add final newline
Use 2 (not 3) spaces for indentation
Use 2 (not 4) spaces for indentation
Remove space before comma
Add space after comma
Remove trailing whitespaces
Remove unnecessary spacing
Use snake_case for variable names
Do not use then for multi-line if
Remove unused block argument - i
Use the new Ruby 1.9 hash syntax
Remove unused assignment to variable
Indent when as deep as case
Align attributes
Align end with def
2016-11-15 11:18:43 +01:00
rgarcia
3c2098eb14 improves legibility of counts 2016-06-16 18:40:05 +02:00
rgarcia
b7e3129ec1 uses more efficient count 2016-06-16 18:35:34 +02:00
rgarcia
0abc9c8376 adds stats for direct messages and proposal notifications 2016-06-16 17:42:16 +02:00
Juanjo Bazán
65335d1344 optimizes stat query 2016-05-20 11:05:10 +02:00
palomahnhp
bf5d253e12 Merge branch 'master' into tracking_user_verifications_and_others
Conflicts:
	app/controllers/admin/stats_controller.rb
	db/dev_seeds.rb
2016-04-20 11:44:33 +02:00
inobcr
e2610e15e7 Add_stats_for_Investment_Proyect_#918 2016-03-21 18:18:18 +01:00
palomahnhp
7d4936b577 track user verification and add statistics of verified users who did not vote proposals 2016-03-13 21:38:05 +01:00
rgarcia
dc52271881 displays stats summary 2015-09-26 13:07:21 +02:00
Juanjo Bazán
8c99c6a5f0 refactors stats and optimizes js
JS libraries for stats (d3, c3, etc.) only load now when needed (stats/show)
2015-09-23 19:37:24 +02:00