Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 5844: Seeder other duties #5903

Merged
merged 7 commits into from
Jul 13, 2024
22 changes: 22 additions & 0 deletions db/seeds/db_populator.rb
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add other_duties to

def active_record_classes
to show a count of the number created.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def initialize(random_instance, case_fourteen_years_old: false)
@casa_org_counter = 0
@case_number_sequence = 1000
@case_fourteen_years_old = case_fourteen_years_old
@other_duties_counter = 0 ## adds other duties counter
end

def create_all_casa_admin(email)
Expand Down Expand Up @@ -53,6 +54,7 @@ def create_org(options_hash)
create_learning_hour_types(casa_org)
create_learning_hour_topics(casa_org)
create_learning_hours(casa_org)
create_other_duties
casa_org
end

Expand Down Expand Up @@ -104,6 +106,26 @@ def create_users(casa_org, options)
Volunteer.all.each { |v| v.supervisor = supervisors.sample(random: rng) }
end

# Create other duties (Volunteer only)
# Increment other_duties_counter by 1 each time other duty is created
# Print out statement that indicates number of other duties created

def create_other_duties
Volunteer.find_each do |v|
2.times {
OtherDuty.create!(
creator_id: v.id,
creator_type: "Volunteer",
occurred_at: Faker::Date.between(from: 2.days.ago, to: Date.today),
duration_minutes: rand(5..180),
notes: Faker::Lorem.sentence
)
@other_duties_counter = + 1
}
end
puts "Created #{@other_duties_counter} Other Duties."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we add the count to the main seeds.rb file we don't need the puts or the counter.

end

def generate_case_number
# CINA-YY-XXXX
years = ((DateTime.now.year - 20)..DateTime.now.year).to_a
Expand Down
Loading