Skip to content

Commit

Permalink
update placement type and species to be random in seeds (#1047)
Browse files Browse the repository at this point in the history
* update placement type and species to be random in seeds

* set breed based on species
  • Loading branch information
kasugaijin authored Oct 13, 2024
1 parent 5694781 commit 6f55760
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
13 changes: 9 additions & 4 deletions db/seeds/01_alta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,23 @@
)

path = Rails.root.join("app", "assets", "images", "hero.jpg")
from_weight = [5, 10, 20, 30, 40, 50, 60].sample

50.times do
from_weight = [5, 10, 20, 30, 40, 50, 60].sample
species = Pet.species.keys.sample
breed = "Faker::Creature::#{species.classify}".constantize.breed

pet = Pet.create!(
name: Faker::Creature::Dog.name,
birth_date: Faker::Date.birthday(min_age: 0, max_age: 3),
sex: Faker::Creature::Dog.gender,
weight_from: from_weight,
weight_to: from_weight + 15,
weight_unit: Pet::WEIGHT_UNITS.sample,
breed: Faker::Creature::Dog.breed,
breed: breed,
description: "He just loves a run and a bum scratch at the end of the day",
species: Pet.species["Dog"],
placement_type: 0,
species: species,
placement_type: Pet.placement_types.values.sample,
published: true
)
pet.images.attach(io: File.open(path), filename: "hero.jpg")
Expand Down Expand Up @@ -250,6 +254,7 @@

@fosterable_pets = Array.new(3) do
from_weight = [5, 10, 20, 30, 40, 50, 60].sample

Pet.create!(
name: Faker::Creature::Dog.name,
birth_date: Faker::Date.birthday(min_age: 0, max_age: 3),
Expand Down
12 changes: 8 additions & 4 deletions db/seeds/02_baja.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,23 @@
end

path = Rails.root.join("app", "assets", "images", "hero.jpg")
from_weight = [5, 10, 20, 30, 40, 50, 60].sample

25.times do
from_weight = [5, 10, 20, 30, 40, 50, 60].sample
species = Pet.species.keys.sample
breed = "Faker::Creature::#{species.classify}".constantize.breed

pet = Pet.create!(
name: Faker::Creature::Dog.name,
birth_date: Faker::Date.birthday(min_age: 0, max_age: 3),
sex: Faker::Creature::Dog.gender,
weight_from: from_weight,
weight_to: from_weight + 15,
weight_unit: Pet::WEIGHT_UNITS.sample,
breed: Faker::Creature::Dog.breed,
breed: breed,
description: "He just loves a run and a bum scratch at the end of the day",
species: Pet.species["Dog"],
placement_type: 1,
species: species,
placement_type: Pet.placement_types.values.sample,
published: true
)
pet.images.attach(io: File.open(path), filename: "hero.jpg")
Expand Down

0 comments on commit 6f55760

Please sign in to comment.