diff --git a/app/datatables/admin/effective_mentorship_group_users_datatable.rb b/app/datatables/admin/effective_mentorship_group_users_datatable.rb index eedb5e1..9cfbda2 100644 --- a/app/datatables/admin/effective_mentorship_group_users_datatable.rb +++ b/app/datatables/admin/effective_mentorship_group_users_datatable.rb @@ -11,6 +11,9 @@ class EffectiveMentorshipGroupUsersDatatable < Effective::Datatable col :mentorship_group col :mentorship_role col :user + col :email do |registration| + registration.user.email + end actions_col end diff --git a/app/datatables/admin/effective_mentorship_registrations_datatable.rb b/app/datatables/admin/effective_mentorship_registrations_datatable.rb index 5788a85..61e2e23 100644 --- a/app/datatables/admin/effective_mentorship_registrations_datatable.rb +++ b/app/datatables/admin/effective_mentorship_registrations_datatable.rb @@ -4,6 +4,7 @@ class EffectiveMentorshipRegistrationsDatatable < Effective::Datatable scope :all scope :opt_in scope :opt_out + scope :opt_in_with_groups scope :opt_in_without_groups end @@ -17,6 +18,9 @@ class EffectiveMentorshipRegistrationsDatatable < Effective::Datatable col :mentorship_cycle, search: :select col :user + col :email do |registration| + registration.user.email + end col :opt_in, visible: attributes[:opt_in_without_groups].blank? diff --git a/app/models/concerns/effective_mentorships_registration.rb b/app/models/concerns/effective_mentorships_registration.rb index 1ab79e5..fbcbc32 100644 --- a/app/models/concerns/effective_mentorships_registration.rb +++ b/app/models/concerns/effective_mentorships_registration.rb @@ -96,27 +96,23 @@ def locations scope :mentees, -> { where(mentorship_role: :mentee) } scope :opt_in, -> { where(opt_in: true) } scope :opt_out, -> { where(opt_in: false) } + scope :opt_in_with_groups, -> { opt_in.with_groups } scope :opt_in_without_groups, -> { opt_in.without_groups } scope :in_person, -> { where(venue: 'In-person') } scope :virtual, -> { where(venue: 'Virtual') } scope :either, -> { where(venue: 'Either') } - scope :with_groups, -> { - group_users = Effective::MentorshipGroupUser.all + scope :with_groups, -> { + group_users = Effective::MentorshipGroupUser.where.not(mentorship_registration_id: nil) where(id: group_users.select(:mentorship_registration_id)) } scope :without_groups, -> { - group_users = Effective::MentorshipGroupUser.all + group_users = Effective::MentorshipGroupUser.where.not(mentorship_registration_id: nil) where.not(id: group_users.select(:mentorship_registration_id)) } - scope :with_groups, -> { - group_users = Effective::MentorshipGroupUser.all - where(id: group_users.select(:mentorship_registration_id)) - } - scope :with_groups_from, -> (mentorship_bulk_group) { groups = EffectiveMentorships.MentorshipGroup.where(mentorship_bulk_group: mentorship_bulk_group) group_users = Effective::MentorshipGroupUser.where(mentorship_group_id: groups.select(:mentorship_group_id))