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

Add a specific school to seeded teams, if that school exists in the DB #2071

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ def attach_locations_to(team)
Location.order("RANDOM()").limit(50).update_all(team_id: team.id)
end

def attach_specific_school_to_team_if_present(team:, urn:)
if (school = Location.find_by(urn:))
school.update!(team_id: team.id)
end
end

def create_session(_user, team)
programme = Programme.find_by(type: "hpv")

Expand Down Expand Up @@ -147,6 +153,8 @@ def create_imports(team)
user, team = create_user_and_team(ods_code: "R1L")

attach_locations_to(team)
attach_specific_school_to_team_if_present(team:, urn: "136126") # potentially needed for automated testing

Audited.audit_class.as_user(user) { create_session(user, team) }
create_patients(team)
create_imports(team)
Expand All @@ -155,6 +163,7 @@ def create_imports(team)
user, team = create_user_and_team(ods_code: "Y51", uid: "555057896106")

attach_locations_to(team)
attach_specific_school_to_team_if_present(team:, urn: "136126") # potentially needed for automated testing
Audited.audit_class.as_user(user) { create_session(user, team) }
create_patients(team)
create_imports(team)
Loading