[Seeding] Tweak comment randomization (#719)

This commit is contained in:
Cinder 2024-08-12 15:07:02 -07:00 committed by GitHub
parent fe37772f2c
commit 27b2359dde
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -168,9 +168,9 @@ def populate_comments(number, users: [])
users = User.where("users.created_at < ?", 14.days.ago).limit(DISTRIBUTION).order("random()") if users.empty?
posts = Post.limit(DISTRIBUTION).order("random()")
number.times do |index|
post = posts[index % DISTRIBUTION]
CurrentUser.user = users[index % DISTRIBUTION]
number.times do
post = posts.sample
CurrentUser.user = users.sample
comment_obj = Comment.create do |comment|
comment.creator = CurrentUser.user