sakai-info 0.3.3 → 0.3.4
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.
- data/CHANGELOG.md +7 -0
- data/README.md +1 -1
- data/ROADMAP.md +0 -4
- data/lib/sakai-info/user.rb +30 -23
- data/lib/sakai-info/version.rb +1 -1
- metadata +3 -3
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/ROADMAP.md
CHANGED
data/lib/sakai-info/user.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# SakaiInfo::User library
|
3
3
|
#
|
4
4
|
# Created 2012-02-17 daveadams@gmail.com
|
5
|
-
# Last updated 2012-
|
5
|
+
# Last updated 2012-03-09 daveadams@gmail.com
|
6
6
|
#
|
7
7
|
# https://github.com/daveadams/sakai-info
|
8
8
|
#
|
@@ -11,8 +11,13 @@
|
|
11
11
|
|
12
12
|
module SakaiInfo
|
13
13
|
class User < SakaiObject
|
14
|
-
attr_reader :eid, :name, :type
|
15
|
-
|
14
|
+
attr_reader :eid, :name, :type, :email, :dbrow
|
15
|
+
|
16
|
+
include ModProps
|
17
|
+
created_by_key :createdby
|
18
|
+
created_at_key :createdon
|
19
|
+
modified_by_key :modifiedby
|
20
|
+
modified_at_key :modifiedon
|
16
21
|
|
17
22
|
@@cache = {}
|
18
23
|
def self.find(id)
|
@@ -23,18 +28,11 @@ module SakaiInfo
|
|
23
28
|
raise ObjectNotFoundException.new(User, id)
|
24
29
|
end
|
25
30
|
|
26
|
-
row = DB.connect.
|
27
|
-
"to_char(createdon,'YYYY-MM-DD HH24:MI:SS') as created_at, " +
|
28
|
-
"to_char(modifiedon,'YYYY-MM-DD HH24:MI:SS') as modified_at " +
|
29
|
-
"from sakai_user where user_id=?", user_id).first
|
31
|
+
row = DB.connect[:sakai_user].where(:user_id => user_id).first
|
30
32
|
if row.nil?
|
31
33
|
raise ObjectNotFoundException.new(User, id)
|
32
34
|
end
|
33
|
-
@@cache[eid] =
|
34
|
-
@@cache[user_id] =
|
35
|
-
User.new(user_id, eid,
|
36
|
-
((row[:first_name] || "") + " " + (row[:last_name] || "")).strip,
|
37
|
-
row[:type], row[:created_at], row[:modified_at])
|
35
|
+
@@cache[eid] = @@cache[user_id] = User.new(row)
|
38
36
|
end
|
39
37
|
@@cache[id]
|
40
38
|
end
|
@@ -61,14 +59,14 @@ module SakaiInfo
|
|
61
59
|
end
|
62
60
|
end
|
63
61
|
|
64
|
-
def initialize(
|
65
|
-
@
|
66
|
-
|
67
|
-
@
|
68
|
-
@
|
69
|
-
@
|
70
|
-
@
|
71
|
-
@
|
62
|
+
def initialize(dbrow)
|
63
|
+
@dbrow = dbrow
|
64
|
+
|
65
|
+
@id = dbrow[:user_id]
|
66
|
+
@eid = User.get_eid(@id)
|
67
|
+
@email = dbrow[:email]
|
68
|
+
@name = ((dbrow[:first_name] || "") + " " + (dbrow[:last_name] || "")).strip
|
69
|
+
@type = dbrow[:type]
|
72
70
|
end
|
73
71
|
|
74
72
|
def properties
|
@@ -165,8 +163,8 @@ module SakaiInfo
|
|
165
163
|
"id" => self.id,
|
166
164
|
"name" => self.name,
|
167
165
|
"eid" => self.eid,
|
166
|
+
"email" => self.email,
|
168
167
|
"type" => self.type,
|
169
|
-
"created_at" => self.created_at,
|
170
168
|
"user_properties" => UserProperty.find_by_user_id(self.id),
|
171
169
|
"site_count" => self.site_count,
|
172
170
|
"question_pool_count" => self.question_pool_count
|
@@ -216,8 +214,17 @@ module SakaiInfo
|
|
216
214
|
|
217
215
|
def self.find_by_user_id(user_id)
|
218
216
|
properties = {}
|
219
|
-
|
220
|
-
|
217
|
+
# HACK: reading blobs via OCI8 is really slow, make the db server do it!
|
218
|
+
# This is multiple orders of magnitude faster.
|
219
|
+
# But, this will break if the property value is > 4000chars and may not work
|
220
|
+
# on mysql, so here's the original version:
|
221
|
+
# DB.connect[:sakai_user_property].where(:user_id => user_id).all.each do |row|
|
222
|
+
# properties[row[:name]] = row[:value].read
|
223
|
+
# end
|
224
|
+
DB.connect[:sakai_user_property].
|
225
|
+
select(:name, :to_char.sql_function(:value).as(:value)).
|
226
|
+
where(:user_id => user_id).all.each do |row|
|
227
|
+
properties[row[:name]] = row[:value]
|
221
228
|
end
|
222
229
|
return properties
|
223
230
|
end
|
data/lib/sakai-info/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sakai-info
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 4
|
10
|
+
version: 0.3.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Adams
|