Skip to content

Fix/genootschapen dyslexia#612

Open
TimonBoer wants to merge 8 commits intostagingfrom
fix/genootschapen-dyslexia
Open

Fix/genootschapen dyslexia#612
TimonBoer wants to merge 8 commits intostagingfrom
fix/genootschapen-dyslexia

Conversation

@TimonBoer
Copy link

@TimonBoer TimonBoer commented Feb 16, 2026

Checklist

  • changed all occerences of 'genootschapen' to 'genootschappen'
  • added a database migration to update all previous activities

Summary

Fixed genootschapen error

Other information

Also in amber-ui

Summary by CodeRabbit

  • Bug Fixes

    • Corrected the spelling of the "Genootschappen" activity category; existing records have been migrated so they display and behave correctly.
  • Tests

    • Updated test data and specs to use the corrected category so tests reflect production values.
  • Chores

    • Added a migration and bumped the database schema version to record and apply the correction.

…s migrating the current database so all current genootschapen in the database are correct
@coderabbitai
Copy link

coderabbitai bot commented Feb 16, 2026

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Walkthrough

Corrects a spelling error: changes Activity category "genootschapen" to "genootschappen" in the model, updates existing records via a migration, adjusts test factories/specs, and bumps the schema version.

Changes

Cohort / File(s) Summary
Model
app/models/activity.rb
Fixed typo in Activity.categories ("genootschapen" → "genootschappen").
Migration
db/migrate/20260216222433_fix_genootschapen_dyslexia.rb
Adds migration that updates records from genre: "genootschapen""genootschappen" in up, and reverses in down using find_each + update!.
Tests & Factories
spec/factories/activities.rb, spec/models/activity_spec.rb
Updated factory and spec sample data to use corrected category string.
Schema
db/schema.rb
Bumped ActiveRecord schema version/timestamp to reflect the new migration (7.1 → 7.2).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

status:ready to review

Suggested reviewers

  • DrumsnChocolate
  • ToMaarton

Poem

🐰 I nibbled a typo, small and bright,
One letter hopped back into light.
I bounced through models, tests, and schema,
Now "genootschappen" sings like a dream-a. ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description includes the required checklist with completed items and a summary, but lacks critical testing verification details and missing issue references that the template suggests. Include evidence of database migration testing from staging (db:reset and db:migrate steps) and add issue references using 'fixes #xyz' format to clearly link this fix to tracked issues.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change—fixing a typo of 'genootschapen' to 'genootschappen'—which aligns with the primary focus of this changeset across model, migration, test, and factory files.

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

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/genootschapen-dyslexia

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.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
Verify each finding against the current code and only fix it if needed.


In `@db/migrate/20260216222433_fix_genootschapen_dyslexia.rb`:
- Around line 1-8: The migration FixGenootschapenDyslexia uses Activity.where
with capitalized category strings that don't match stored lowercase values;
update the up and down methods to query and update the actual lowercase category
names (use "genootschappen" in the up WHERE and target, and "genootschapen" in
the down WHERE and target) so the Activity.where(...).update_all(...) calls
match existing rows; alternatively, use a case-insensitive SQL condition if you
prefer, but ensure both up and down use matching casing or equivalent matching
logic.

@codecov
Copy link

codecov bot commented Feb 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.92%. Comparing base (ca06416) to head (8840eac).
⚠️ Report is 2 commits behind head on staging.

Additional details and impacted files
@@           Coverage Diff            @@
##           staging     #612   +/-   ##
========================================
  Coverage    99.92%   99.92%           
========================================
  Files          197      197           
  Lines         2665     2665           
========================================
  Hits          2663     2663           
  Misses           2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

TimonBoer and others added 3 commits February 16, 2026 23:58
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
db/migrate/20260216222433_fix_genootschapen_dyslexia.rb (1)

2-4: Consider also migrating stale users.ical_categories values.

The users table has an ical_categories array column (see db/schema.rb line 565) that stores user iCal filter preferences. Any user who previously selected "genootschapen" will have that misspelled string persisted there. After this migration fixes activities.category to "genootschappen", those users' iCal filters will silently match nothing. A companion update on users may be warranted:

# In the up method, after fixing activities:
User.where("'genootschapen' = ANY(ical_categories)").find_each do |user|
  user.update_columns(
    ical_categories: user.ical_categories.map { |c| c == "genootschapen" ? "genootschappen" : c }
  )
end
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@db/migrate/20260216222433_fix_genootschapen_dyslexia.rb` around lines 2 - 4,
The migration updates Activity.category but misses stale user iCal preferences;
add logic in the up method to find User records where the ical_categories array
contains "genootschapen" and replace that element with "genootschappen" (use
User.where with an ANY check or equivalent, iterate with find_each and
update_columns to avoid callbacks), and ensure the down method (if present)
symmetrically reverts user ical_categories from "genootschappen" back to
"genootschapen" to keep rollbacks consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@db/migrate/20260216222433_fix_genootschapen_dyslexia.rb`:
- Around line 1-10: Remove the stray closing token at the end of the migration
file: the extra `end` after the class declaration (in the file containing class
FixGenootschapenDyslexia and its up/down methods) is unmatched and causes a
SyntaxError; delete that final `end` so the class and its methods
(Activity.where(...).update_all(...) in up and down) are properly closed.

---

Nitpick comments:
In `@db/migrate/20260216222433_fix_genootschapen_dyslexia.rb`:
- Around line 2-4: The migration updates Activity.category but misses stale user
iCal preferences; add logic in the up method to find User records where the
ical_categories array contains "genootschapen" and replace that element with
"genootschappen" (use User.where with an ANY check or equivalent, iterate with
find_each and update_columns to avoid callbacks), and ensure the down method (if
present) symmetrically reverts user ical_categories from "genootschappen" back
to "genootschapen" to keep rollbacks consistent.

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)
db/migrate/20260216222433_fix_genootschapen_dyslexia.rb (1)

3-5: Prefer update_all over find_each + update! for this data migration.

The current approach has two drawbacks:

  1. Performance — emits one UPDATE per matching row instead of a single bulk SQL statement. For even a few hundred records this is orders of magnitude slower.
  2. Reliabilityupdate! raises ActiveRecord::RecordInvalid if any record fails validation mid-loop. On non-transactional DDL engines (e.g. MySQL) this can leave the table half-migrated with no automatic rollback.

update_all is the idiomatic Rails pattern here: it issues a single UPDATE … WHERE statement, bypasses callbacks and validations (appropriate for a typo fix), and never leaves the table in a partial state.

♻️ Proposed refactor
 class FixGenootschapenDyslexia < ActiveRecord::Migration[7.2]
   def up
-    Activity.where(category: 'genootschapen').find_each do |activity|
-      activity.update!(category: 'genootschappen')
-    end
+    Activity.where(category: 'genootschapen').update_all(category: 'genootschappen')
   end

   def down
-    Activity.where(category: 'genootschappen').find_each do |activity|
-      activity.update!(category: 'genootschapen')
-    end
+    Activity.where(category: 'genootschappen').update_all(category: 'genootschapen')
   end
 end

Also applies to: 9-11

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

In `@db/migrate/20260216222433_fix_genootschapen_dyslexia.rb` around lines 3 - 5,
Replace the row-by-row migration that uses Activity.where(category:
'genootschapen').find_each { |activity| activity.update!(category:
'genootschappen') } with a single bulk update using Activity.where(category:
'genootschapen').update_all(category: 'genootschappen') (and change the other
similar block at lines 9-11) so the migration issues one SQL UPDATE, bypasses
validations/callbacks, and avoids partial commits; locate the code in this
migration file around the Activity.where(...) usages and swap the find_each +
update! pattern to update_all.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@db/migrate/20260216222433_fix_genootschapen_dyslexia.rb`:
- Around line 3-5: Replace the row-by-row migration that uses
Activity.where(category: 'genootschapen').find_each { |activity|
activity.update!(category: 'genootschappen') } with a single bulk update using
Activity.where(category: 'genootschapen').update_all(category: 'genootschappen')
(and change the other similar block at lines 9-11) so the migration issues one
SQL UPDATE, bypasses validations/callbacks, and avoids partial commits; locate
the code in this migration file around the Activity.where(...) usages and swap
the find_each + update! pattern to update_all.

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.

1 participant