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

refactor: move current seeds.rb script to new DevStarter module (lib/seed/seeder.rb) #767

Merged
merged 9 commits into from
Mar 4, 2025

Conversation

kolharsam
Copy link
Contributor

@kolharsam kolharsam commented Feb 28, 2025

Ref ticket: #762

This pull request refactors the database seeding process by moving the logic into a new module and class, and organizing constants into a separate file.

  • db/seeds.rb: It now just directly calls Seed::DevStarter.call.
  • lib/seed/dev_starter.rb: Created a new Seed::DevStarter class that encapsulates the seeding logic for admin, owner, and developer users (as it was present in the earlier seeds.rb file)
  • lib/seed/constants.rb: Moved constants for admin, owner, and developer user details into a separate file

This starts a new series of PRs that are meant to eventually help resolve #762

@kolharsam kolharsam requested review from kitallis and nid90 February 28, 2025 05:38
@kolharsam kolharsam self-assigned this Feb 28, 2025
Copy link
Member

@kitallis kitallis left a comment

Choose a reason for hiding this comment

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

Approving, left a small comment.

Comment on lines +11 to +13
self.class.send(:create_admin_user)
self.class.send(:create_owner_user)
self.class.send(:create_developer_user)
Copy link
Member

@kitallis kitallis Feb 28, 2025

Choose a reason for hiding this comment

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

issue this needn't be called like this, we can just call it like self.class.create_admin_user and remove the private. But better yet, since this class doesn't have state yet, the point of the class is sort of very low value. Classes encapsulate state. But it may in the future, so I would recommend just do something like:

def self.call
  new.call
end

def call
  create_admin_user
  ..
end

And make all those class methods, instance methods (and you can keep them private).

@kolharsam kolharsam added this pull request to the merge queue Mar 4, 2025
Merged via the queue into main with commit fad105c Mar 4, 2025
3 of 4 checks passed
@kolharsam kolharsam deleted the sam-demo-env-1 branch March 4, 2025 08:15
kolharsam added a commit that referenced this pull request Mar 4, 2025
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.

demo.tramline.app - Notes
2 participants