sakai-info 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # sakai-info Change History #
2
2
 
3
+ ## 0.3.4 ##
4
+
5
+ *Released 2012-03-09*
6
+
7
+ * Added --dbrow and --mod support to User
8
+ * User property lookup performance improvements
9
+
3
10
  ## 0.3.3 ##
4
11
 
5
12
  *Released 2012-03-09*
data/README.md CHANGED
@@ -24,7 +24,7 @@ Use `rake` to test and build the gem:
24
24
  $ rake gem:build
25
25
 
26
26
  The resulting gem will be saved to the working directory as
27
- `sakai-info-0.3.3.gem`.
27
+ `sakai-info-0.3.4.gem`.
28
28
 
29
29
  Cleanup built gems using:
30
30
 
data/ROADMAP.md CHANGED
@@ -2,10 +2,6 @@
2
2
 
3
3
  *Last updated 2012-03-09*
4
4
 
5
- ### 0.3.4 ###
6
-
7
- * User support for --mod and --dbrow
8
-
9
5
  ### 0.3.5 ###
10
6
 
11
7
  * CLI access to forums
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::User library
3
3
  #
4
4
  # Created 2012-02-17 daveadams@gmail.com
5
- # Last updated 2012-02-26 daveadams@gmail.com
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
- attr_reader :created_by, :created_at, :modified_by, :modified_at
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.fetch("select first_name, last_name, type, " +
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(id, eid, name, type, created_at, modified_at)
65
- @id = id
66
- @eid = eid
67
- @name = name
68
- @type = type
69
- @created_at = created_at
70
- @modified_at = modified_at
71
- @properties = nil
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
- DB.connect[:sakai_user_property].where(:user_id => user_id).all.each do |row|
220
- properties[row[:name]] = row[:value].read
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
@@ -1,3 +1,3 @@
1
1
  module SakaiInfo
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
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: 21
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 3
10
- version: 0.3.3
9
+ - 4
10
+ version: 0.3.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Adams