-
Notifications
You must be signed in to change notification settings - Fork 5
Add jim dun seed data #686
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,26 +12,32 @@ namespace :test_seeds do | |||||||||
| Rails.logger.info 'Destroying existing seeds...' | ||||||||||
| creator_id = ENV.fetch('SEEDING_CREATOR_ID', TEST_USERS[:jane_doe]) | ||||||||||
| teacher_id = ENV.fetch('SEEDING_TEACHER_ID', TEST_USERS[:john_doe]) | ||||||||||
| teacher_signup_id = TEST_USERS[:jim_dun] | ||||||||||
|
|
||||||||||
| # Hard coded as the student's school needs to match | ||||||||||
| student_ids = [TEST_USERS[:jane_smith], TEST_USERS[:john_smith], TEST_USERS[:emily_ssouser]] | ||||||||||
| school_id = TEST_SCHOOL | ||||||||||
| teacher_signup_school_id = | ||||||||||
| School.find_by(creator_id: teacher_signup_id)&.id | ||||||||||
|
|
||||||||||
| # Remove the roles first | ||||||||||
| Role.where(user_id: teacher_signup_id).destroy_all | ||||||||||
|
Comment on lines
+15
to
+24
|
||||||||||
| Role.where(user_id: [creator_id, teacher_id] + student_ids).destroy_all | ||||||||||
|
|
||||||||||
| # Destroy the project and then the lesson itself (The lesson's `before_destroy` prevents us using destroy) | ||||||||||
| lesson_ids = Lesson.where(school_id:).pluck(:id) | ||||||||||
| Project.where(lesson_id: [lesson_ids]).destroy_all | ||||||||||
| Lesson.where(id: [lesson_ids]).delete_all | ||||||||||
| Project.where(lesson_id: lesson_ids).destroy_all | ||||||||||
| Lesson.where(id: lesson_ids).delete_all | ||||||||||
|
Comment on lines
27
to
+30
|
||||||||||
|
|
||||||||||
| # Destroy the class members and then the class itself | ||||||||||
| school_class_ids = SchoolClass.where(school_id:).pluck(:id) | ||||||||||
|
||||||||||
| school_class_ids = SchoolClass.where(school_id:).pluck(:id) | |
| school_class_ids = SchoolClass.where(school_id: [school_id, teacher_signup_school_id].compact).pluck(:id) |
Copilot
AI
Feb 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commented-out code suggests the intended approach was to use compact to handle nil values. Either remove this commented line or refactor lines 39-40 to use this more elegant approach:
School.where(id: [school_id, teacher_signup_school_id].compact).destroy_allThis would handle both schools in a single call and safely exclude nil values.
| # school_ids = [school_id, teacher_signup_school_id].compact | |
| School.where(id: school_id).destroy_all | |
| School.where(id: teacher_signup_school_id).destroy_all | |
| School.where(id: [school_id, teacher_signup_school_id].compact).destroy_all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says "user with no school", but the code at lines 20-21 and 40 specifically looks for and destroys a school created by this user. This creates an inconsistency - either jim_dun should never have a school (in which case lines 20-21 and 40 are unnecessary), or the comment should be updated to reflect that jim_dun might create a school during testing.
Consider clarifying the intended behavior and updating either the comment or the code accordingly.