Skip to content

Fix insights#24

Merged
microstudi merged 4 commits intomainfrom
fix/insights
Mar 24, 2026
Merged

Fix insights#24
microstudi merged 4 commits intomainfrom
fix/insights

Conversation

@antopalidi
Copy link
Member

@antopalidi antopalidi commented Mar 20, 2026

Summary by CodeRabbit

  • New Features

    • Pivot table cells now show formatted counts with optional percentage labels; added helper to render count+percentage and CSS to prevent percentage wrapping.
  • Bug Fixes

    • Normalized extra user field configuration values to strings to prevent duplicate categories and incorrect counts.
  • Tests

    • Added specs for symbol-based configuration handling and the new count+percentage helper formatting.

@coderabbitai
Copy link

coderabbitai bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 90023bd4-7146-4f89-9340-e45401b31779

📥 Commits

Reviewing files that changed from the base of the PR and between 609b493 and 2b8c55f.

📒 Files selected for processing (2)
  • app/helpers/decidim/extra_user_fields/admin/insights_helper.rb
  • spec/helpers/decidim/extra_user_fields/admin/insights_helper_spec.rb
🚧 Files skipped from review as they are similar to previous changes (1)
  • spec/helpers/decidim/extra_user_fields/admin/insights_helper_spec.rb

📝 Walkthrough

Walkthrough

Normalizes ExtraUserFields configuration to arrays of strings, adds a helper to render counts with optional percentages, updates the pivot table view to use that helper, adds percentage styling, and expands tests for symbol-configured genders and the new helper.

Changes

Cohort / File(s) Summary
Type Normalization
lib/decidim/extra_user_fields.rb
Overrides singleton methods genders, age_ranges, insight_fields, insight_age_spans to return Array<String> by coercing configured values with Array(...).map(&:to_s).
Pivot table tests
spec/services/decidim/extra_user_fields/pivot_table_builder_spec.rb
Adds a spec context that configures genders as symbols (e.g., [:female, :male]) and verifies the pivot table builder does not create duplicate rows and counts users correctly.
Helper & view
app/helpers/decidim/extra_user_fields/admin/insights_helper.rb, app/views/decidim/extra_user_fields/admin/insights/_pivot_table.html.erb
Adds count_with_percentage(value, total) to format counts with optional one-decimal percentages (suppresses “.0”) and updates pivot table cells and row/column totals to use it (grand total display unchanged).
Styles
app/packs/stylesheets/decidim/extra_user_fields/insights.scss
Adds .insights-table__percentage rule to apply small text (text-xs) and white-space: nowrap to percentage labels.
Helper tests
spec/helpers/decidim/extra_user_fields/admin/insights_helper_spec.rb
Adds tests for count_with_percentage covering formatting, percentage precision, zero-total behavior, and CSS class presence.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hop through configs, turning symbols to strings,
Counting carrots, ages, and all tiny things.
I show the percent with a tidy little cheer,
No duplicates, neat tables—everything clear! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title "Fix insights" is vague and generic, using non-descriptive language that does not convey what specific aspect of insights is being fixed or what the main changes are. Revise the title to be more specific and descriptive, such as "Add percentage formatting to insights pivot table" or "Ensure ExtraUserFields methods return string arrays consistently".
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/insights

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
spec/services/decidim/extra_user_fields/pivot_table_builder_spec.rb (1)

96-100: Rename this example to “rows” for precision.

The assertions check result.row_values, so “rows” would be clearer than “columns”.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@spec/services/decidim/extra_user_fields/pivot_table_builder_spec.rb` around
lines 96 - 100, Rename the example description string from "does not produce
duplicate columns" to "rows" in the spec containing the assertions that inspect
result.row_values; locate the it block that calls subject.call and checks
result.row_values.count(...), and update the example description text to "rows"
so the spec accurately describes what is being tested.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@spec/services/decidim/extra_user_fields/pivot_table_builder_spec.rb`:
- Around line 96-100: Rename the example description string from "does not
produce duplicate columns" to "rows" in the spec containing the assertions that
inspect result.row_values; locate the it block that calls subject.call and
checks result.row_values.count(...), and update the example description text to
"rows" so the spec accurately describes what is being tested.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9f17778a-99ed-4008-8476-56b6066c81cc

📥 Commits

Reviewing files that changed from the base of the PR and between f7c45bf and f03bb97.

📒 Files selected for processing (2)
  • lib/decidim/extra_user_fields.rb
  • spec/services/decidim/extra_user_fields/pivot_table_builder_spec.rb

coderabbitai[bot]

This comment was marked as resolved.

@antopalidi antopalidi requested a review from microstudi March 24, 2026 09:07
Copy link
Member

@microstudi microstudi left a comment

Choose a reason for hiding this comment

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

excelent

@microstudi microstudi merged commit 6f2a132 into main Mar 24, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants