Skip to content

Commit d3efd0a

Browse files
Add 'attended by coach workshop invitations' to seeds
1 parent 9a884b9 commit d3efd0a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

db/seeds.rb

+14-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@
2020
workshops.concat Fabricate.times(2, :workshop, title: 'Workshop', chapter: chapters.sample)
2121

2222
Rails.logger.info "Creating a lot of old workshops..."
23-
past_workshops = 50.times.map do |n|
23+
past_workshops_since_n_months = 5 * 12
24+
past_workshops_one_per_n_months = 6
25+
past_workshops_count = past_workshops_since_n_months/past_workshops_one_per_n_months
26+
27+
past_workshops = past_workshops_count.times.map do |n|
2428
Fabricate(:workshop, title: 'Workshop',
2529
chapter: chapters.sample,
26-
date_and_time: Time.zone.now - 9.years + n.months)
30+
date_and_time: Time.zone.now - past_workshops_since_n_months.months + (past_workshops_one_per_n_months * n).months)
2731
end
2832

2933
Rails.logger.info "Creating events..."
@@ -70,7 +74,14 @@
7074
Rails.logger.info "Creating event invitations..."
7175
10.times do |n|
7276
Fabricate(:invitation, member: students.sample, event: events.sample)
73-
Fabricate(:coach_invitation, member: students.sample, event: events.sample)
77+
Fabricate(:coach_invitation, member: coaches.sample, event: events.sample)
78+
end
79+
80+
Rails.logger.info "Creating attended by coach workshop invitations..."
81+
coaches.sample(15).each do |coach|
82+
past_workshops.sample(3).each do |workshop|
83+
Fabricate(:attended_coach, workshop: workshop, member: coach)
84+
end
7485
end
7586

7687
Rails.logger.info "Creating workshop invitations..."

0 commit comments

Comments
 (0)