Skip to content

Commit

Permalink
Issue 5844: Seeder other duties (#5903)
Browse files Browse the repository at this point in the history
* Add create_other_duties for volunteers only

* Remove casa_org param to apply other duties to all volunteers regardless of casa org

* other_duties_counter initialized to 0

* Call on new private method create_other_duties

* create_other_duties maps through Volunteer to create OtherDuty 2x. Increments to the other_duties_counter each time and prints statement of how many other duties were created

* Modifies enumerable to find_each + returns other_duties_counter after OtherDuty.create

* Add OtherDuty to main seeds file and remove counter and puts statement from seeder
  • Loading branch information
gaurijo authored Jul 13, 2024
1 parent a7680bb commit 04036e9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def active_record_classes
LearningHourType,
LearningHourTopic,
MileageRate,
OtherDuty,
Supervisor,
SupervisorVolunteer,
User,
Expand Down
19 changes: 19 additions & 0 deletions db/seeds/db_populator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,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 +105,24 @@ 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
)
}
end
end

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

0 comments on commit 04036e9

Please sign in to comment.