meibo 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2fed6d292ab3d38301370ef4d6238d4ddc470d8ae380e1e8bdf8f6d88822aaf0
4
- data.tar.gz: d364e20a7336ad702b4d3434efefe800bed8a971f0cc02177c817398fa79982d
3
+ metadata.gz: 5ad0dc346f3bc9d8166c4ddc9a55ddfedc79bcf78aea61f83289e339a40dfea4
4
+ data.tar.gz: d2bf911450a3c05d334e3b6c5ea7ea9a2dd8e9cb141ce125f0d6a95a99e4daca
5
5
  SHA512:
6
- metadata.gz: bb712c2090b7cc03708a4c8b302e187357db4f2bf260e62486f79072ba646371368c6968baaa022c472774b6a09c0aba3a7f1716b1b074e6fcb2ab6ab6e19935
7
- data.tar.gz: dd2f31087c8b28e02b9e257dcb405cb1eec588d5a576c120cdcadcb0402743cb7a02f6e62262ca1c932f93c8f119839d95eb505ce44534a04a478883e0d966af
6
+ metadata.gz: fb78b3143e372d6629f174fe3e0d34eea05ecbaf11bb1b8c0478c09a6a78c9792349f850da3f7530f5e20e5503b5151907dd6e7ee85a46dc286f5bc1f24cbc71
7
+ data.tar.gz: d28830dba3e605a95bca895ddc2655d6921707884c0fefa5257e79766e400f13bcc7e9c47a940c8687f4a874a2e8d4178ef61aef721cd7bcd16e784d4aeac2ab
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- meibo (0.13.0)
4
+ meibo (0.14.0)
5
5
  rubyzip
6
6
  zeitwerk
7
7
 
@@ -62,7 +62,11 @@ module Meibo
62
62
  end
63
63
 
64
64
  def parent
65
- Meibo.current_roster.academic_sessions.find(parent_sourced_id)
65
+ parent_sourced_id && Meibo.current_roster.academic_sessions.find(parent_sourced_id)
66
+ end
67
+
68
+ def children
69
+ Meibo.current_roster.academic_sessions.where(parent_sourced_id: sourced_id)
66
70
  end
67
71
  end
68
72
  end
@@ -83,5 +83,9 @@ module Meibo
83
83
  def terms
84
84
  term_sourced_ids.map {|term_sourced_id| Meibo.current_roster.academic_sessions.find(term_sourced_id) }
85
85
  end
86
+
87
+ def enrollments
88
+ Meibo.current_roster.enrollments.where(class_sourced_id: sourced_id)
89
+ end
86
90
  end
87
91
  end
data/lib/meibo/course.rb CHANGED
@@ -49,5 +49,9 @@ module Meibo
49
49
  def school_year
50
50
  Meibo.current_roster.academic_sessions.find(school_year_sourced_id)
51
51
  end
52
+
53
+ def classes
54
+ Meibo.current_roster.classes.where(course_sourced_id: sourced_id)
55
+ end
52
56
  end
53
57
  end
@@ -42,19 +42,17 @@ module Meibo
42
42
  raise DataNotFoundError, "sourcedId: #{sourced_id} が見つかりません"
43
43
  end
44
44
 
45
- def by_organization(org_sourced_id)
46
- data_by_org_sourced_id[org_sourced_id]
47
- end
48
-
49
- def by_user(user_sourced_id)
50
- data_by_user_sourced_id[user_sourced_id]
45
+ def where(**conditions)
46
+ group_cache[conditions.keys.sort][conditions.values]
51
47
  end
52
48
 
53
49
  private
54
50
 
55
- def data_by_org_sourced_id
56
- @cache[:data_by_org_sourced_id] ||= @data.group_by(&:data_by_org_sourced_id).to_h do |org_sourced_id, data|
57
- [org_sourced_id, new(data)]
51
+ def group_cache
52
+ @cache[:group_cache] ||= Hash.new do |hash, keys|
53
+ hash[keys] = @data.group_by {|datum| keys.map {|attribute| datum.public_send(attribute) } }.to_h do |values, data|
54
+ [values, new(data)]
55
+ end
58
56
  end
59
57
  end
60
58
 
@@ -62,12 +60,6 @@ module Meibo
62
60
  @cache[:data_by_sourced_id] ||= @data.to_h {|datum| [datum.sourced_id, datum] }
63
61
  end
64
62
 
65
- def data_by_user_sourced_id
66
- @cache[:data_by_user_sourced_id] ||= @data.group_by(&:user_sourced_id).to_h do |user_sourced_id, data|
67
- [user_sourced_id, new(data)]
68
- end
69
- end
70
-
71
63
  def new(data)
72
64
  self.class.new(data, roster: roster)
73
65
  end
@@ -68,5 +68,21 @@ module Meibo
68
68
  def parent
69
69
  parent_sourced_id && Meibo.current_roster.organizations.find(parent_sourced_id)
70
70
  end
71
+
72
+ def enrollments
73
+ Meibo.current_roster.enrollments.where(school_sourced_id: sourced_id)
74
+ end
75
+
76
+ def classes
77
+ Meibo.current_roster.classes.where(school_sourced_id: sourced_id)
78
+ end
79
+
80
+ def courses
81
+ Meibo.current_roster.courses.where(org_sourced_id: sourced_id)
82
+ end
83
+
84
+ def roles
85
+ Meibo.current_roster.roles.where(org_sourced_id: sourced_id)
86
+ end
71
87
  end
72
88
  end
data/lib/meibo/user.rb CHANGED
@@ -79,7 +79,7 @@ module Meibo
79
79
  end
80
80
 
81
81
  def enrollments
82
- Meibo.current_roster.enrollments.by_user(sourced_id)
82
+ Meibo.current_roster.enrollments.where(user_sourced_id: sourced_id)
83
83
  end
84
84
 
85
85
  def primary_organization
@@ -87,17 +87,17 @@ module Meibo
87
87
  end
88
88
 
89
89
  def primary_role_in(org)
90
- Meibo.current_roster.roles.by_user(sourced_id).detect do |role|
90
+ Meibo.current_roster.roles.where(user_sourced_id: sourced_id).detect do |role|
91
91
  role.primary? && role.org_sourced_id == org.sourced_id
92
92
  end
93
93
  end
94
94
 
95
95
  def roles
96
- Meibo.current_roster.roles.by_user(sourced_id)
96
+ Meibo.current_roster.roles.where(user_sourced_id: sourced_id)
97
97
  end
98
98
 
99
99
  def user_profiles
100
- Meibo.current_roster.user_profiles.by_user(sourced_id)
100
+ Meibo.current_roster.user_profiles.where(user_sourced_id: sourced_id)
101
101
  end
102
102
  end
103
103
  end
@@ -42,5 +42,9 @@ module Meibo
42
42
  def user
43
43
  Meibo.current_roster.users.find(user_sourced_id)
44
44
  end
45
+
46
+ def role
47
+ Meibo.current_roster.roles.where(user_profile_sourced_id: sourced_id).first
48
+ end
45
49
  end
46
50
  end
data/lib/meibo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meibo
4
- VERSION = "0.13.0"
4
+ VERSION = "0.14.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meibo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seiei Miyagi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-15 00:00:00.000000000 Z
11
+ date: 2022-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -125,7 +125,7 @@ metadata:
125
125
  allowed_push_host: https://rubygems.org/
126
126
  homepage_uri: https://github.com/hanachin/meibo
127
127
  source_code_uri: https://github.com/hanachin/meibo
128
- changelog_uri: https://github.com/hanachin/meibo/blob/meibo/v0.13.0/CHANGELOG.md
128
+ changelog_uri: https://github.com/hanachin/meibo/blob/meibo/v0.14.0/CHANGELOG.md
129
129
  post_install_message:
130
130
  rdoc_options: []
131
131
  require_paths: