def call(
workgroup:,
programme_type:,
requires_registration: nil,
psd_enabled: nil,
national_protocol_enabled: nil
)
MavisCLI.load_rails
team = Team.find_by!(workgroup:)
programme = Programme.find(programme_type)
attributes = {
requires_registration:,
psd_enabled:,
national_protocol_enabled:
}.compact
team
.sessions
.includes(:location, :team_location)
.for_academic_year(AcademicYear.pending)
.has_all_programmes_of([programme])
.find_each do |session|
session.assign_attributes(attributes)
if session.changed?
session.save!
puts "Updated #{session.slug}: #{session.location.name}"
end
end
end