# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
#   movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
#   Character.create(name: "Luke", movie: movies.first)
p1 = Publisher.create(name: "Simon and Schuster")
p2 = Publisher.create(name: "Nature America")
p3 = Publisher.create(name: "Random House")
p4 = Publisher.create(name: "O'Reilly Media")

a1 = Author.create(first_name: "Judy", last_name: "Blume")
a2 = Author.create(first_name: "Carolyn", last_name: "Keene")
a3 = Author.create(first_name: "National", last_name: "Geographic")
a4 = Author.create(first_name: "Who", last_name: "Knows")


b1 = Book.create(title: "Are you there god, it's me Margaret", publisher_id: p1.id, author_id: a1.id)
b2 = Book.create(title: "Where are the Hardy Boys now?", publisher_id: p3.id, author_id: a2.id)
b3 = Book.create(title: "Elephants in the Wild", publisher_id: p2.id, author_id: a3.id)
b4 = Book.create(title: "huh?", publisher_id: p4.id, author_id: a4.id)
b5 = Book.create(title: "Friends, the behind the scenes story", publisher_id: p1.id, author_id: a4.id)
b6 = Book.create(title: "Jurrasic Park", publisher_id: p3.id, author_id: a3.id)

bf1 = BookFormatType.create(name: "Hardcover", physical: true)
bf2 = BookFormatType.create(name: "Softcover", physical: true)
bf3 = BookFormatType.create(name: "pdf", physical: false)
bf4 = BookFormatType.create(name: "kindle", physical: false)
b1.book_formats.create(book_format_type_id: bf1.id)
b1.book_formats.create(book_format_type_id: bf2.id)
b2.book_formats.create(book_format_type_id: bf3.id)
b2.book_formats.create(book_format_type_id: bf1.id)
b3.book_formats.create(book_format_type_id: bf4.id)
b3.book_formats.create(book_format_type_id: bf2.id)
b4.book_formats.create(book_format_type_id: bf1.id)
b4.book_formats.create(book_format_type_id: bf4.id)
b4.book_formats.create(book_format_type_id: bf3.id)
b5.book_formats.create(book_format_type_id: bf1.id)
b5.book_formats.create(book_format_type_id: bf2.id)
b5.book_formats.create(book_format_type_id: bf3.id)
b6.book_formats.create(book_format_type_id: bf1.id)
b6.book_formats.create(book_format_type_id: bf2.id)
b6.book_formats.create(book_format_type_id: bf3.id)
b6.book_formats.create(book_format_type_id: bf4.id)



b1.book_reviews.create(rating: rand(1..5))
b2.book_reviews.create(rating: rand(1..5))
b1.book_reviews.create(rating: rand(1..5))
b2.book_reviews.create(rating: rand(1..5))
b1.book_reviews.create(rating: rand(1..5))
b3.book_reviews.create(rating: rand(1..5))
b3.book_reviews.create(rating: rand(1..5))
b3.book_reviews.create(rating: rand(1..5))
b4.book_reviews.create(rating: rand(1..5))
b4.book_reviews.create(rating: rand(1..5))
b4.book_reviews.create(rating: rand(1..5))
b5.book_reviews.create(rating: rand(1..5))
b5.book_reviews.create(rating: rand(1..5))
b5.book_reviews.create(rating: rand(1..5))
b5.book_reviews.create(rating: rand(1..5))
b6.book_reviews.create(rating: rand(1..5))
b6.book_reviews.create(rating: rand(1..5))
b6.book_reviews.create(rating: rand(1..5))
b6.book_reviews.create(rating: rand(1..5))
b6.book_reviews.create(rating: rand(1..5))
b6.book_reviews.create(rating: rand(1..5))
puts "The Seeds have been planted"