if !User.exists?(email: "whyruby@gmail.com")
  User.create!(name: "Qichunren", username: "qichunren", email: "whyruby@gmail.com", password: "a12345678aa", confirmed_at: Time.now, level: "root")
end

max_user_id = User.order("id DESC").first.id + 1
50.times do |i|
  User.create!(name: "User_#{i + max_user_id}", username: "user_#{i + max_user_id}", email: "user_#{i + max_user_id}@example.com", password: "12345678aa", confirmed_at: Time.now)
end

post_category_1 = PostCategory.create!(name: "Programming", url_slug: "programming", group_name: "Default", position: 1)
post_category_2 = PostCategory.create!(name: "English Learning", url_slug: "english-learning", group_name: "Default", position: 2)
PostCategory.create!(name: "CompanyNews", url_slug: "company-news", group_name: "Default", position: 3)

Post.create!(title: "Hello world", content: "This is the first post here!", is_draft: false, published_at: Time.current, post_category_id: post_category_1.id, user_id: User.first.id)
Post.create!(title: "Build a awesome product", content: "Try to build a awesome product", is_draft: false, published_at: Time.current, post_category_id: post_category_2.id, user_id: User.last.id)

200.times do |i|
  Post.create!(title: "Post #{i}", content: "Content in post #{i}", is_draft: false, published_at: Time.current, post_category_id: PostCategory.ids[i % 3], user_id: User.last.id)
end
