Commit Graph

21 Commits

Author SHA1 Message Date
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
1edf0d937d Move stats graph partial to a component
Note we're naming it "chart" in order to avoid possible conflicts with
the "graph" view when we move it to a component.
2024-05-09 14:28:31 +02:00
Javi Martín
4e9ed4dfa6 Extract component to render links to event stats 2024-05-09 14:28:31 +02:00
Javi Martín
790170a27c Use keyword arguments in tag methods
The interface of this method has changed and uses keyword arguments
instead of a hash of options. This change will be particularly
significant when upgrading to Ruby 3.
2022-08-24 15:10:36 +02:00
Javi Martín
749428d93f Replace content_tag with new tag builder syntax
One of the main advantages of this syntax is we can now omit the content
parameter when it's empty.
2020-04-27 19:26:37 +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
eac7427755 Remove line auto-assigning a variable to nil
This is one of the most strange behaviours in ruby: if a variable
doesn't exist, assigning to itself will return `nil`.

So a line like:

mdmkdfm = ooops if mdmkdfm.respond_to?(:uiqpior)

Surprisingly will not raise any errors: the nonexistent `mdmkdfm`
variable will be evaluated to `nil`, `mdmkdfm.respond_to?(:uiqpior)`
will evaluate to `nil.respond_to?(:uiqpior)`, which will return `false`,
and then the line will be evaluated as `mdmkdfm = ooops if false`, which
will return `nil`.

Maybe in the future Ruby will change this behaviour. We hope CONSUL is
now in better shape if that ever happens :).
2019-09-29 22:52:53 +02:00
Javi Martín
c4c0301f3f Simplify stats images styles
This way we don't need to manually define the width we think the image
we insert in the `::before` pseudoclass is going to take.
2019-05-21 13:50:16 +02:00
Javi Martín
4ade857a1b Extract method to render number and info
We're going to use it in many places, so removing duplication is useful.
2019-05-21 13:50:16 +02:00
Javi Martín
c0044f4e56 Extract method to show stats percentage 2019-05-21 13:50:15 +02:00
Javi Martín
ccaa2e1a77 Remove duplication to calculate percentage 2019-05-21 13:49:42 +02:00
Bertocq
4be44835a8 Add calculate_percentaje helper function to stats helper 2019-05-21 13:26:44 +02:00
rgarcia
cfe3f95f5c moves graphs to individual views 2019-05-16 13:37:47 +02:00
Julian Herrero
b460c024f3 Use double quotes in app/helpers 2019-03-15 09:26:49 +01:00
Bertocq
d7b8777395 Fix all Layout/SpaceAroundEqualsInParameterDefault rubocop issues from rubocop_todo list 2017-06-26 18:03:40 +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
inobcr
e2610e15e7 Add_stats_for_Investment_Proyect_#918 2016-03-21 18:18:18 +01:00
kikito
adc8275f5a moves the admin api inside of the /admin namespace 2015-09-24 12:11:51 +02:00
rgarcia
4897d5df4e makes spaces consistent 2015-09-03 01:29:46 +02:00
Eloy Gomez
5b0cd4a8ba Show charts using c3.js 2015-08-17 19:15:17 +02:00