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

Add options to show advanced stats #3520

Merged
merged 9 commits into from
May 23, 2019
Merged

Conversation

javierm
Copy link
Member

@javierm javierm commented May 21, 2019

References

Objectives

  • Add option to show the advanced stats in polls
  • Add option to show stats, results and advanced stats in budgets

Visual Changes

Fieldset with fields to enable stats and results for budgets

Release notes

⚠️ To update existing stats and result permissions, run:

bin/rake stats_and_results:migrate_to_reports RAILS_ENV=production

lib/migrations/reports.rb Show resolved Hide resolved
@@ -62,7 +63,7 @@ def destroy
def budget_params
descriptions = Budget::Phase::PHASE_KINDS.map{|p| "description_#{p}"}.map(&:to_sym)
valid_attributes = [:phase, :currency_symbol] + descriptions
params.require(:budget).permit(*valid_attributes, translation_params(Budget))
params.require(:budget).permit(*valid_attributes, *report_attributes, translation_params(Budget))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [103/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)

@javierm javierm force-pushed the backport-remove_custom_poll_group_file branch from 98b4a9e to d4017a6 Compare May 21, 2019 16:26
@javierm javierm force-pushed the backport-refactor_stats_enabled branch from dded561 to d151805 Compare May 21, 2019 16:27
@javierm javierm force-pushed the backport-remove_custom_poll_group_file branch from d4017a6 to 2d29243 Compare May 22, 2019 09:49
This table will store which reports (stats, results, ...) will be shown
for a certain process (polls, budgets, ...).

Note Rails fails to save a poll and its report when both are new records
if we add a `validate :process, presence: true` rule. Since it caused a
lot of trouble when creating records for tests during factories rule
completely. Instead, I've created the `results_enabled=` and
`stats_enabled=` methods, so tests are easier to set up, while also
automatically creating a report if it doesn't already exist. This also
decouples form structure and database implemenation.

Originally I named this table `enabled_reports` and instead of having
`stats` and `results` columns, it had an `enabled` column and a `kind`
column, which would be set to "stats" or "results". However, although
that table would allow us to add arbitrary reports easily, I found the
way we had to handle the `has_many` relationship was a bit too complex.
We're going to add an `advanced_stats` report, and having 3 identical
sets of methods would be too much duplication.
They're easier to test and to read in the model.
@javierm javierm force-pushed the backport-refactor_stats_enabled branch from d151805 to 13e68e4 Compare May 22, 2019 09:50
@javierm javierm force-pushed the backport-refactor_stats_enabled branch from 13e68e4 to 9ae0cbb Compare May 22, 2019 10:48
@javierm javierm changed the base branch from backport-remove_custom_poll_group_file to master May 23, 2019 11:07
@javierm javierm merged commit 387488a into master May 23, 2019
@javierm javierm deleted the backport-refactor_stats_enabled branch May 23, 2019 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants