effective_mentorships 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51540f932b6939477810dbc83ca434c9a1f645e02ad8ce1bdfbf6ecf97254dbc
4
- data.tar.gz: 5561bd5faa4e649f72702f9f861ca0571c47f92f6a719d866e64aead6ccf500d
3
+ metadata.gz: d108b6f623e6830dc7f8472bc8a6b24a5bd0e5f960cf681e7d9a0af91fb96c76
4
+ data.tar.gz: 3ec7750b99ee913338db52f3c5993ee52f1835573d7e64516ff85098bd6b3c60
5
5
  SHA512:
6
- metadata.gz: 42f67c456e342f4abf4be9983246c6d01172db3e9a4bb36980c597a74153dc401bb3ac3e8056e94982b6344e5e90e98506c91e215e979451e0fa4f0cb00b8c1a
7
- data.tar.gz: 6575760097d8daf6fe4160313eee73eb7c180464cdeaa16a910b5107b7e69be4cce7295c7b5a6c22f44778aa53a0af69639123be69f4850daf9220ca9970a89e
6
+ metadata.gz: 8dea56a517526afddbe848866e61ae143b51a55076ed1780ee6d250fbd2200e94bc20520c2d8abedf8851821770bf5694126b3ff5a5b587577b7658aaae067c5
7
+ data.tar.gz: 0ef916d861109f3b03f1533d416b36683e75016e3f1aeb6a974191df60ca4dac59e25472f0f6a430921d249fac7d62ad28ae8241b336e2a14a021f0746849e31
@@ -29,6 +29,7 @@ module EffectiveMentorshipsUser
29
29
  scope :deep_effective_mentorships_user, -> { all }
30
30
 
31
31
  scope :mentorships_opted_in, -> (mentorship_cycle) {
32
+ mentorship_cycle = Effective::MentorshipCycle.find(mentorship_cycle) if mentorship_cycle.kind_of?(Integer)
32
33
  raise('expected an EffectiveMentorships.MentorshipCycle') unless mentorship_cycle.kind_of?(Effective::MentorshipCycle)
33
34
 
34
35
  opted_in = EffectiveMentorships.MentorshipRegistration.opt_in.where(mentorship_cycle: mentorship_cycle)
@@ -36,6 +37,7 @@ module EffectiveMentorshipsUser
36
37
  }
37
38
 
38
39
  scope :mentorships_opted_out, -> (mentorship_cycle) {
40
+ mentorship_cycle = Effective::MentorshipCycle.find(mentorship_cycle) if mentorship_cycle.kind_of?(Integer)
39
41
  raise('expected an EffectiveMentorships.MentorshipCycle') unless mentorship_cycle.kind_of?(Effective::MentorshipCycle)
40
42
 
41
43
  opted_out = EffectiveMentorships.MentorshipRegistration.opt_out.where(mentorship_cycle: mentorship_cycle)
@@ -43,6 +45,7 @@ module EffectiveMentorshipsUser
43
45
  }
44
46
 
45
47
  scope :mentorships_opted_in_mentors, -> (mentorship_cycle) {
48
+ mentorship_cycle = Effective::MentorshipCycle.find(mentorship_cycle) if mentorship_cycle.kind_of?(Integer)
46
49
  raise('expected an EffectiveMentorships.MentorshipCycle') unless mentorship_cycle.kind_of?(Effective::MentorshipCycle)
47
50
 
48
51
  opted_in_mentors = EffectiveMentorships.MentorshipRegistration.opt_in.mentors.where(mentorship_cycle: mentorship_cycle)
@@ -50,6 +53,7 @@ module EffectiveMentorshipsUser
50
53
  }
51
54
 
52
55
  scope :mentorships_opted_in_mentees, -> (mentorship_cycle) {
56
+ mentorship_cycle = Effective::MentorshipCycle.find(mentorship_cycle) if mentorship_cycle.kind_of?(Integer)
53
57
  raise('expected an EffectiveMentorships.MentorshipCycle') unless mentorship_cycle.kind_of?(Effective::MentorshipCycle)
54
58
 
55
59
  opted_in_mentees = EffectiveMentorships.MentorshipRegistration.opt_in.mentees.where(mentorship_cycle: mentorship_cycle)
@@ -57,6 +61,7 @@ module EffectiveMentorshipsUser
57
61
  }
58
62
 
59
63
  scope :mentorships_with_groups, -> (mentorship_cycle) {
64
+ mentorship_cycle = Effective::MentorshipCycle.find(mentorship_cycle) if mentorship_cycle.kind_of?(Integer)
60
65
  raise('expected an EffectiveMentorships.MentorshipCycle') unless mentorship_cycle.kind_of?(Effective::MentorshipCycle)
61
66
 
62
67
  grouped = Effective::MentorshipGroupUser.where(mentorship_cycle: mentorship_cycle)
@@ -64,11 +69,40 @@ module EffectiveMentorshipsUser
64
69
  }
65
70
 
66
71
  scope :mentorships_without_groups, -> (mentorship_cycle) {
72
+ mentorship_cycle = Effective::MentorshipCycle.find(mentorship_cycle) if mentorship_cycle.kind_of?(Integer)
67
73
  raise('expected an EffectiveMentorships.MentorshipCycle') unless mentorship_cycle.kind_of?(Effective::MentorshipCycle)
68
74
 
69
75
  grouped = Effective::MentorshipGroupUser.where(mentorship_cycle: mentorship_cycle)
70
76
  where.not(id: grouped.select(:user_id))
71
77
  }
78
+
79
+ scope :mentorships_mentors_with_groups, -> (mentorship_cycle) {
80
+ mentorship_cycle = Effective::MentorshipCycle.find(mentorship_cycle) if mentorship_cycle.kind_of?(Integer)
81
+ raise('expected an EffectiveMentorships.MentorshipCycle') unless mentorship_cycle.kind_of?(Effective::MentorshipCycle)
82
+
83
+ grouped = Effective::MentorshipGroupUser.mentors.where(mentorship_cycle: mentorship_cycle)
84
+ where(id: grouped.select(:user_id))
85
+ }
86
+
87
+ scope :mentorships_mentees_with_groups, -> (mentorship_cycle) {
88
+ mentorship_cycle = Effective::MentorshipCycle.find(mentorship_cycle) if mentorship_cycle.kind_of?(Integer)
89
+ raise('expected an EffectiveMentorships.MentorshipCycle') unless mentorship_cycle.kind_of?(Effective::MentorshipCycle)
90
+
91
+ grouped = Effective::MentorshipGroupUser.mentees.where(mentorship_cycle: mentorship_cycle)
92
+ where(id: grouped.select(:user_id))
93
+ }
94
+
95
+ scope :mentorships_participant_in_mentorship_cycle_id, -> (membership_cycle_id) {
96
+ mentorships_with_groups(membership_cycle_id)
97
+ }
98
+
99
+ scope :mentorships_mentor_in_mentorship_cycle_id, -> (membership_cycle_id) {
100
+ mentorships_mentors_with_groups(membership_cycle_id)
101
+ }
102
+
103
+ scope :mentorships_mentee_in_mentorship_cycle_id, -> (membership_cycle_id) {
104
+ mentorships_mentees_with_groups(membership_cycle_id)
105
+ }
72
106
  end
73
107
 
74
108
  # Used for the dashboard datatables. Which cycles can we register for?
@@ -25,6 +25,9 @@ module Effective
25
25
  scope :deep, -> { includes(:mentorship_cycle, :mentorship_group, :user) }
26
26
  scope :sorted, -> { order(:mentorship_cycle_id).order(:position) }
27
27
 
28
+ scope :mentors, -> { where(mentorship_role: 'mentor') }
29
+ scope :mentees, -> { where(mentorship_role: 'mentee') }
30
+
28
31
  # Assign position and cycle
29
32
  before_validation(if: -> { mentorship_group.present? }) do
30
33
  self.position ||= (mentorship_group.mentorship_group_users.map(&:position).compact.max || -1) + 1
@@ -33,7 +36,7 @@ module Effective
33
36
 
34
37
  # Assign registration, if present
35
38
  before_validation(if: -> { user.present? && mentorship_cycle.present? }) do
36
- self.mentorship_registration ||= user.mentorship_registrations.find { |mentorship_registration| mentorship_registration.mentorship_cycle_id == mentorship_cycle.id }
39
+ self.mentorship_registration = user.mentorship_registrations.find { |mentorship_registration| mentorship_registration.mentorship_cycle_id == mentorship_cycle.id }
37
40
  end
38
41
 
39
42
  # Denormalized data for searching
data/config/routes.rb CHANGED
@@ -13,7 +13,7 @@ EffectiveMentorships::Engine.routes.draw do
13
13
 
14
14
  namespace :admin do
15
15
  resources :mentorship_cycles, except: [:show]
16
- resources :mentorship_registrations, only: [:index, :edit, :update, :delete]
16
+ resources :mentorship_registrations, except: [:show]
17
17
 
18
18
  resources :mentorship_bulk_groups, only: [:index, :new, :show, :destroy] do
19
19
  resources :build, controller: :mentorship_bulk_groups, only: [:show, :update]
@@ -1,3 +1,3 @@
1
1
  module EffectiveMentorships
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_mentorships
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-13 00:00:00.000000000 Z
11
+ date: 2025-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails