Closed staylorwr closed 1 year ago
ManyToMany.make(:mentors, Mentor) |> ManyToMany.with_index_fields([ Text.make(:last_name), Text.make(:first_name), Select.make(:pronouns, "Preferred Pronouns") |> Select.options(~w(he/him she/her they/them)), Text.make(:login_code), date_field(:background_check_on), date_field(:consent_form_received_on), Number.make(:sessions_completed) ]) |> ManyToMany.with_index_query(fn query, _assoc, program_id -> from( m in query, left_join: s in Voyager.Edu.Session, on: s.mentee_id == m.id and s.program_id == ^program_id and not is_nil(s.completed_on), select_merge: %{sessions_completed: count(s.id)}, group_by: m.id ) end),