You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: program.rb
    path of file: ./repos/osem/app/models
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

# cannot delete program if there are events submitted

class Program < ApplicationRecord
  has_paper_trail on: [:update], ignore: [:updated_at], meta: { conference_id: :conference_id }

  belongs_to :conference

  has_many :cfps, dependent: :destroy
  has_many :event_types, dependent: :destroy
  has_many :tracks, dependent: :destroy
  has_man
    
  def selected_event_schedules(includes: [:event])
    event_schedules = []
    event_schedules = selected_schedule.event_schedules.includes(*includes).order(start_time: :asc) if selected_schedule
    tracks.self_organized.confirmed.includes(selected_schedule: { event_schedules: includes }).order(start_date: :asc).each do |track|
      next unless track.selected_schedule

      event_schedules += track.selected_schedule.event_schedules
    end
    event_schedules.sort_by(&:start_time)
  end