Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate age stats based on the participation date #5533

Merged
merged 3 commits into from May 17, 2024
Merged

Conversation

javierm
Copy link
Member

@javierm javierm commented May 13, 2024

References

Objectives

  • Display the participation stats by age at the moment the participation process took place

Notes

As mentioned in the commit message, in the case of polls we could slightly improve this behavior by using the information in the age column in the poll_voters table. The difference wouldn't be very significant, though, since the stats are shown by age groups, and only a small percentage of people would change their age group (and only to the nearest one) between the time they participate and the time the process ends.

@javierm javierm added the Bug label May 13, 2024
@javierm javierm self-assigned this May 13, 2024
@javierm javierm added this to Reviewing in Consul Democracy May 13, 2024
We were already testing it as part of the statisticable concern, but
it's easier to understand when we have specific tests for it as well.

Note that we're using `eq` insteab of `be` because it's what we use most
often in the test. For consistency, we're also changing the tesst in
budget stats so it uses `eq`.
We were calculating the age stats based on the age of the users who
participated... at the moment where we were calculating the stats. That
means that, if 20 years ago, 1000 people who were 16 years old
participated, they would be shown as having 36 years in the stats.

Instead, we want to show the stats at the time when the process took
place, so we're implementing a `participation_date` method.

Note that, for polls, we could actually use the `age` column in the
`poll_voters` table. However, doing so would be harder, would only work
for polls but not for budgets, and it wouldn't be statistically very
relevant, since the stats are shown by age groups, and only a small
percentage of people would change their age group (and only to the
nearest one) between the time they participate and the time the process
ends.

We might use the `poll_voters` table in the future, though, since we
have a similar issue with geozones and genders, and using the
information in `poll_voters` would solve it as well (only for polls,
though).

Also note that we're using the `ends_at` dates because some people but
be too young to vote when a process starts but old enough to vote when
the process ends.

Finally, note that we might need to change the way we calculate the
participation date for a budget, since some budgets might not enabled
every phase. Not sure how stats work in that scenario (even before these
changes).
Using `>` and `<` for dates is a bit confusing because it usually
requires mentally translating `<` into "before" and `>` into "after",
meaning it takes a few seconds to check which is the starting date and
which is the ending date. When using a range, it's easier to see which
is which.

Note that we were using `>` and `<`, but now we're using the equivalent
of `>=` and `<=`. This makes sense IMHO, since the beginning of the year
and the end of the year should also be included in this case.
Consul Democracy automation moved this from Reviewing to Testing May 17, 2024
@javierm javierm merged commit 6eadf3c into master May 17, 2024
13 checks passed
Consul Democracy automation moved this from Testing to Release 2.2.0 May 17, 2024
@javierm javierm deleted the age_stats branch May 17, 2024 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Consul Democracy
  
Release 2.2.0
Development

Successfully merging this pull request may close these issues.

None yet

2 participants