Conversation
…s migrating the current database so all current genootschapen in the database are correct
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughCorrects 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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…pha/amber-api into fix/genootschapen-dyslexia
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
db/migrate/20260216222433_fix_genootschapen_dyslexia.rb (1)
2-4: Consider also migrating staleusers.ical_categoriesvalues.The
userstable has anical_categoriesarray column (seedb/schema.rbline 565) that stores user iCal filter preferences. Any user who previously selected "genootschapen" will have that misspelled string persisted there. After this migration fixesactivities.categoryto"genootschappen", those users' iCal filters will silently match nothing. A companionupdateonusersmay 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.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
db/migrate/20260216222433_fix_genootschapen_dyslexia.rb (1)
3-5: Preferupdate_alloverfind_each+update!for this data migration.The current approach has two drawbacks:
- Performance — emits one
UPDATEper matching row instead of a single bulk SQL statement. For even a few hundred records this is orders of magnitude slower.- Reliability —
update!raisesActiveRecord::RecordInvalidif 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_allis the idiomatic Rails pattern here: it issues a singleUPDATE … WHEREstatement, 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 endAlso 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.
Checklist
Summary
Fixed genootschapen error
Other information
Also in amber-ui
Summary by CodeRabbit
Bug Fixes
Tests
Chores