use level instead of depth
This commit is contained in:
Родитель
485b11b1b7
Коммит
259f6f932a
4
Rakefile
4
Rakefile
|
@ -26,14 +26,14 @@ namespace :db do
|
|||
CommentThread.delete_all
|
||||
Vote.delete_all
|
||||
User.delete_all
|
||||
depth_limit = YAML.load_file("config/application.yml")["depth_limit"]
|
||||
level_limit = YAML.load_file("config/application.yml")["level_limit"]
|
||||
(1..3).each do |question_id|
|
||||
comment_thread = CommentThread.create! :commentable_type => "questions", :commentable_id => question_id
|
||||
5.times do
|
||||
comment_thread.root_comments.create :body => "top comment", :title => "top #{rand(10)}", :user_id => 1, :course_id => 1, :comment_thread_id => comment_thread.id
|
||||
end
|
||||
10.times do
|
||||
comment = Comment.all.reject{|c| c.is_root? or c.depth - 1 >= depth_limit or c.comment_thread_id != comment_thread.id}.sample
|
||||
comment = Comment.all.reject{|c| c.is_root? or c.depth >= level_limit or c.comment_thread_id != comment_thread.id}.sample
|
||||
comment.children.create :body => "comment body", :title => "comment title #{rand(50)}", :user_id => 1, :course_id => 1, :comment_thread_id => comment_thread.id
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче