-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
more seed data (#2356) #2361
more seed data (#2356) #2361
Conversation
brought this ticket back up to date with current master, awaiting its merge so I may complete: |
|
||
3.times do | ||
40.times do |
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.
What about using a multiplicator as a parameter (in the case of db:seed
it'd probably be an env variable)?
Let's say the default seeds keeps things as they are and one can say "generate 2 times the default amount of data" or 10 times that.
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.
I increased the number enough for the purpose of pagination, and I think we should ensure we have enough data by default so when people go to Q&A the app has what they need without having to look or fiddle with settings.
In honest, this is such a small increase in seed data where I have web-apps which load 10K records within a minute or less.
The seed data is slow in the repo because of architectural choices such as using acts_as_taggable
. I can certainly suggest in future tickets to improve these performance issues so we can have much more seed data.
|
||
100.times do |i| | ||
name = Faker::Name.unique.name | ||
puts "username #{Faker::Internet.username(name)}" |
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.
I wouldn't display 100 (or a 1000 in case of the user's multiplication factor) user names on the console, what's to gain?
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.
If you are testing out pagination, you would.
@@ -213,6 +217,67 @@ | |||
) | |||
############################################################################## | |||
|
|||
Rails.logger.info "9/10 Devvy Ruxpin" |
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.
What if, instead of having "Devvy Ruxpin" as a seed and resort to the hack of having the sign in as a user, all the following code would moved to a regular rake task that can only be run in development mode and that, by passing the username or user id, would do all the "followings" and create all the articles?
This way you don't need any hack. If you want a regular seeded DB you just run the normal seed, if you want more data you increase it with the multiplication factor and if you need to follow everything you just run a rake task meant for dev purposes.
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.
An alternative to the quickin
would be to use a gem such as Pretender which would only work within the admin panel.
I actually don't know if an admin panel exists or how to access it in this codebase which is why I had not suggested this previously.
I don't understand the objections to increasing the amount of data as currently the seed data is insufficent for general Q&A.
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.
It's not an objection, I'm saying that if you make it parameterized the user can decide how much seed data they want and it's future proof :) You can still raise the default multiplier to have a better seed data default.
I'm not familiar with Pretender.
There's an admin, it's under /admin
. There are also internal pages which I think it's a "side admin", see the routes under /internal
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.
Why not just give them the right amount of seed data to test the app without configuration? In order to Q&A various pagination you need more seed data.
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.
Sounds like neither of you object to making the amount of data configurable, just what the default quantity of data should be. @omenking wants to increase the default quantity. @rhymes, are you ok with increasing that amount, or do you want the current quantity to be the default? (I agree with @omenking that the amount of seed data should be sufficient to exercise paging.)
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.
@keithrbennett I still think it should be a configurable param, we can also tweak the default later
@@ -280,6 +280,9 @@ | |||
get "/rails/mailers/*path" => "rails/mailers#preview" | |||
end | |||
|
|||
get '/quickin' => 'users#quickin' |
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.
These two routes should also be wrapped in an if Rails.env.development?
statement.
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 is a good point. I had never considered whether Rails.env could be used in routes but its ruby so certainly should add.
Now that I'm aware there is an admin panel, I think I should have that default user I have in this seed data have admin access as soon as I determine how it can be applied. There is no Also since |
If you switch to using |
@abraham It's not recommended by the gem creators: FactoryGirl for Seed Data?. It's an old article but I think it still applies. |
@omenking |
its a busy week but I'll find time to get these improvements rolled in. |
What if we made the seed file work with activerecord-import to speed everything up? |
Will investigate activerecord-import and report back |
@benhalpern I looked at The gem is quite hefty and I am adverse into increasing the Gemfile further. I'm discouraged to write a simple implementation of what the gem does because the peer review will just delay this PR further. In honest, I think I'm going to abandon this ticket and PR because I only have a few hours a week to work on DEV.to and I didn't want to spend more than 30min here, it was simply to add more seed data for QA of other features. |
@Zhao-Andy is there a way to ignore coverage on files such as |
@maestromac would know better than I would, but I think it's okay if the diff coverage doesn't pass for this case. |
Hi @omenking, we're going to close this for the following two reasons:
Sorry if we let this PR slip for so long. I'm going to open an issue about the seed data so that if we wanto we can discuss around that before coming to an agreeable implementation |
What type of PR is this? (check all applicable)
Description
I add more seed data, I also add a new user which has a populated dashboard which you can impersonate only in development via /quickin
Running seed takes much more time now. We can dial back the number of objects created and let the developer decide if they need to create more of X for their specific development use cases to mitigate this issue.
Related Tickets & Documents
This is the original ticket where I document the journey:
#2356
I needed this to complete this ticket:
#258
Mobile & Desktop Screenshots/Recordings (if there are UI changes)
Added to documentation?
[optional] What gif best describes this PR or how it makes you feel?