Skip to content

Commit

Permalink
squashme! don't create dup'd items when seeding requests
Browse files Browse the repository at this point in the history
  • Loading branch information
scooter-dangle committed Jun 1, 2024
1 parent a72d9c0 commit 44cb8f2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ def random_record_for_org(org, klass)
updated_at: date
)

item_requests = []
pads = p.organization.items.find_by(name: 'Pads')
new_item_request = Partners::ItemRequest.new(
item_id: pads.id,
Expand All @@ -367,9 +366,10 @@ def random_record_for_org(org, klass)
)
partner_request.item_requests << new_item_request

Array.new(Faker::Number.within(range: 4..14)) do
item = p.organization.items.sample
new_item_request = Partners::ItemRequest.new(
items = p.organization.items.sample(Faker::Number.within(range: 4..14)) - [pads]

partner_request.item_requests += items.map do |item|
Partners::ItemRequest.new(
item_id: item.id,
quantity: Faker::Number.within(range: 10..30),
children: [],
Expand All @@ -378,7 +378,6 @@ def random_record_for_org(org, klass)
created_at: date,
updated_at: date
)
partner_request.item_requests << new_item_request
end

partner_request.request_items = partner_request.item_requests.map do |ir|
Expand Down

0 comments on commit 44cb8f2

Please sign in to comment.