sakai-info 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +9 -0
- data/README.md +2 -2
- data/ROADMAP.md +7 -8
- data/lib/sakai-info/cli.rb +5 -1
- data/lib/sakai-info/cli/help.rb +15 -1
- data/lib/sakai-info/database.rb +1 -1
- data/lib/sakai-info/group.rb +61 -31
- data/lib/sakai-info/page.rb +12 -3
- data/lib/sakai-info/site.rb +12 -3
- data/lib/sakai-info/tool.rb +12 -3
- data/lib/sakai-info/version.rb +1 -1
- metadata +4 -4
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# sakai-info Change History #
|
2
2
|
|
3
|
+
## 0.3.3 ##
|
4
|
+
|
5
|
+
*Released 2012-03-09*
|
6
|
+
|
7
|
+
* Fixed performance bug connecting to the database on every query
|
8
|
+
* Performance improvements (with possible downsides) in property lookups
|
9
|
+
* Group supports dbrow, improved serialization
|
10
|
+
* CLI now supports group objects
|
11
|
+
|
3
12
|
## 0.3.2 ##
|
4
13
|
|
5
14
|
*Released 2012-03-08*
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# sakai-info #
|
2
2
|
|
3
|
-
last updated: 2012-03-
|
3
|
+
last updated: 2012-03-09
|
4
4
|
author: David Adams (daveadams@gmail.com)
|
5
5
|
github url: https://github.com/daveadams/sakai-info
|
6
6
|
|
@@ -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.
|
27
|
+
`sakai-info-0.3.3.gem`.
|
28
28
|
|
29
29
|
Cleanup built gems using:
|
30
30
|
|
data/ROADMAP.md
CHANGED
@@ -1,29 +1,28 @@
|
|
1
1
|
# sakai-info Roadmap #
|
2
2
|
|
3
|
-
*Last updated 2012-03-
|
3
|
+
*Last updated 2012-03-09*
|
4
4
|
|
5
|
-
### 0.3.
|
5
|
+
### 0.3.4 ###
|
6
6
|
|
7
|
-
* CLI access to groups
|
8
7
|
* User support for --mod and --dbrow
|
9
8
|
|
10
|
-
### 0.3.
|
9
|
+
### 0.3.5 ###
|
11
10
|
|
12
11
|
* CLI access to forums
|
13
12
|
|
14
|
-
### 0.3.
|
13
|
+
### 0.3.6 ###
|
15
14
|
|
16
15
|
* CLI access to gradebook
|
17
16
|
|
18
|
-
### 0.3.
|
17
|
+
### 0.3.7 ###
|
19
18
|
|
20
19
|
* CLI access to announcements
|
21
20
|
|
22
|
-
### 0.3.
|
21
|
+
### 0.3.8 ###
|
23
22
|
|
24
23
|
* CLI access to content
|
25
24
|
|
26
|
-
### 0.3.
|
25
|
+
### 0.3.9 ###
|
27
26
|
|
28
27
|
* CLI access to authz (realms, roles, functions)
|
29
28
|
|
data/lib/sakai-info/cli.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# - sakai-info command line tool support
|
3
3
|
#
|
4
4
|
# Created 2012-02-19 daveadams@gmail.com
|
5
|
-
# Last updated 2012-03-
|
5
|
+
# Last updated 2012-03-09 daveadams@gmail.com
|
6
6
|
#
|
7
7
|
# https://github.com/daveadams/sakai-info
|
8
8
|
#
|
@@ -11,6 +11,9 @@
|
|
11
11
|
|
12
12
|
require 'sakai-info/cli/help'
|
13
13
|
|
14
|
+
# it's faster to run single-threaded
|
15
|
+
Sequel.single_threaded = true
|
16
|
+
|
14
17
|
module SakaiInfo
|
15
18
|
class CLI
|
16
19
|
ObjectModes = {
|
@@ -18,6 +21,7 @@ module SakaiInfo
|
|
18
21
|
"page" => Page,
|
19
22
|
"tool" => Tool,
|
20
23
|
"user" => User,
|
24
|
+
"group" => Group,
|
21
25
|
"quiz" => Quiz,
|
22
26
|
"quiz-section" => QuizSection,
|
23
27
|
"quiz-item" => QuizItem,
|
data/lib/sakai-info/cli/help.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# - sakai-info command line help
|
3
3
|
#
|
4
4
|
# Created 2012-02-19 daveadams@gmail.com
|
5
|
-
# Last updated 2012-03-
|
5
|
+
# Last updated 2012-03-09 daveadams@gmail.com
|
6
6
|
#
|
7
7
|
# https://github.com/daveadams/sakai-info
|
8
8
|
#
|
@@ -20,6 +20,7 @@ sakai-info #{VERSION}
|
|
20
20
|
|
21
21
|
Object commands:
|
22
22
|
user User information
|
23
|
+
group Group information
|
23
24
|
|
24
25
|
site Site information
|
25
26
|
page Site page information
|
@@ -116,6 +117,19 @@ sakai-info user
|
|
116
117
|
--all Print all possible details
|
117
118
|
EOF
|
118
119
|
|
120
|
+
"group" => <<EOF,
|
121
|
+
sakai-info group
|
122
|
+
|
123
|
+
Usage: sakai-info group <id> [<options>]
|
124
|
+
|
125
|
+
Prints information about the group ID or EID specified. Additional options
|
126
|
+
may be passed to include additional information:
|
127
|
+
|
128
|
+
--users Print user membership information
|
129
|
+
--realm Print corresponding realm information
|
130
|
+
--all Print all possible details
|
131
|
+
EOF
|
132
|
+
|
119
133
|
"site" => <<EOF,
|
120
134
|
sakai-info site
|
121
135
|
|
data/lib/sakai-info/database.rb
CHANGED
data/lib/sakai-info/group.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# SakaiInfo::Group 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,17 +11,18 @@
|
|
11
11
|
|
12
12
|
module SakaiInfo
|
13
13
|
class Group < SakaiObject
|
14
|
-
attr_reader :
|
14
|
+
attr_reader :site_id, :title, :dbrow
|
15
15
|
|
16
|
-
def initialize(
|
17
|
-
@
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
16
|
+
def initialize(dbrow)
|
17
|
+
@dbrow = dbrow
|
18
|
+
|
19
|
+
@id = dbrow[:group_id]
|
20
|
+
@site_id = dbrow[:site_id]
|
21
|
+
@title = dbrow[:title]
|
22
|
+
end
|
23
|
+
|
24
|
+
def site
|
25
|
+
@site ||= Site.find(@site_id)
|
25
26
|
end
|
26
27
|
|
27
28
|
@@cache = {}
|
@@ -31,35 +32,38 @@ module SakaiInfo
|
|
31
32
|
if row.nil?
|
32
33
|
raise ObjectNotFoundException.new(Group, id)
|
33
34
|
end
|
34
|
-
@@cache[id] = Group.new(
|
35
|
+
@@cache[id] = Group.new(row)
|
35
36
|
end
|
36
37
|
@@cache[id]
|
37
38
|
end
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
@@cache_by_site_id[site_id] = []
|
43
|
-
site = Site.find(site_id)
|
40
|
+
def self.query_by_site_id(site_id)
|
41
|
+
DB.connect[:sakai_site_group].where(:site_id => site_id)
|
42
|
+
end
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|
50
|
-
@@cache_by_site_id[site_id]
|
44
|
+
def self.find_by_site_id(site_id)
|
45
|
+
Group.query_by_site_id(site_id).all.
|
46
|
+
collect { |row| @@cache[row[:group_id]] = Group.new(row) }
|
51
47
|
end
|
52
48
|
|
53
49
|
def self.count_by_site_id(site_id)
|
54
|
-
|
50
|
+
Group.query_by_site_id(site_id).count
|
55
51
|
end
|
56
52
|
|
57
53
|
def properties
|
58
|
-
@properties ||= GroupProperty.find_by_group_id(
|
54
|
+
@properties ||= GroupProperty.find_by_group_id(self.id)
|
59
55
|
end
|
60
56
|
|
61
57
|
def realm
|
62
|
-
@authz_realm ||= AuthzRealm.find_by_site_id_and_group_id(
|
58
|
+
@authz_realm ||= AuthzRealm.find_by_site_id_and_group_id(self.site_id, self.id)
|
59
|
+
end
|
60
|
+
|
61
|
+
def providers
|
62
|
+
@providers ||= self.realm.providers
|
63
|
+
end
|
64
|
+
|
65
|
+
def users
|
66
|
+
@users ||= AuthzRealmMembership.find_by_realm_id(self.realm.id).collect{|arm|arm.user}
|
63
67
|
end
|
64
68
|
|
65
69
|
# serialization
|
@@ -67,8 +71,9 @@ module SakaiInfo
|
|
67
71
|
result = {
|
68
72
|
"id" => self.id,
|
69
73
|
"title" => self.title,
|
70
|
-
"
|
71
|
-
"
|
74
|
+
"site" => self.site.serialize(:summary),
|
75
|
+
"user_count" => self.realm.user_count,
|
76
|
+
"providers" => self.providers,
|
72
77
|
"properties" => self.properties
|
73
78
|
}
|
74
79
|
if result["properties"] == {}
|
@@ -81,9 +86,25 @@ module SakaiInfo
|
|
81
86
|
{
|
82
87
|
"id" => self.id,
|
83
88
|
"title" => self.title,
|
84
|
-
"
|
89
|
+
"user_count" => self.realm.user_count
|
90
|
+
}
|
91
|
+
end
|
92
|
+
|
93
|
+
def users_serialization
|
94
|
+
{
|
95
|
+
"users" => self.users.collect { |u| u.serialize(:summary) }
|
85
96
|
}
|
86
97
|
end
|
98
|
+
|
99
|
+
def realm_serialization
|
100
|
+
{
|
101
|
+
"realm" => self.realm.name
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.all_serializations
|
106
|
+
[:default, :users, :realm]
|
107
|
+
end
|
87
108
|
end
|
88
109
|
|
89
110
|
class GroupProperty
|
@@ -99,8 +120,17 @@ module SakaiInfo
|
|
99
120
|
|
100
121
|
def self.find_by_group_id(group_id)
|
101
122
|
properties = {}
|
102
|
-
|
103
|
-
|
123
|
+
# HACK: reading blobs via OCI8 is really slow, make the db server do it!
|
124
|
+
# This is multiple orders of magnitude faster.
|
125
|
+
# But, this will break if the property value is > 4000chars and may not work
|
126
|
+
# on mysql, so here's the original version:
|
127
|
+
# DB.connect[:sakai_site_group_property].where(:group_id => group_id).all.each do |row|
|
128
|
+
# properties[row[:name]] = row[:value].read
|
129
|
+
# end
|
130
|
+
DB.connect[:sakai_site_group_property].
|
131
|
+
select(:name, :to_char.sql_function(:value).as(:value)).
|
132
|
+
where(:group_id => group_id).all.each do |row|
|
133
|
+
properties[row[:name]] = row[:value]
|
104
134
|
end
|
105
135
|
return properties
|
106
136
|
end
|
data/lib/sakai-info/page.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# SakaiInfo::Page library
|
3
3
|
#
|
4
4
|
# Created 2012-03-08 daveadams@gmail.com
|
5
|
-
# Last updated 2012-03-
|
5
|
+
# Last updated 2012-03-09 daveadams@gmail.com
|
6
6
|
#
|
7
7
|
# https://github.com/daveadams/sakai-info
|
8
8
|
#
|
@@ -101,8 +101,17 @@ module SakaiInfo
|
|
101
101
|
|
102
102
|
def self.find_by_page_id(page_id)
|
103
103
|
properties = {}
|
104
|
-
|
105
|
-
|
104
|
+
# HACK: reading blobs via OCI8 is really slow, make the db server do it!
|
105
|
+
# This is multiple orders of magnitude faster.
|
106
|
+
# But, this will break if the property value is > 4000chars and may not work
|
107
|
+
# on mysql, so here's the original version:
|
108
|
+
# DB.connect[:sakai_site_page_property].where(:page_id => page_id).all.each do |row|
|
109
|
+
# properties[row[:name]] = row[:value].read
|
110
|
+
# end
|
111
|
+
DB.connect[:sakai_site_page_property].
|
112
|
+
select(:name, :to_char.sql_function(:value).as(:value)).
|
113
|
+
where(:page_id => page_id).all.each do |row|
|
114
|
+
properties[row[:name]] = row[:value]
|
106
115
|
end
|
107
116
|
return properties
|
108
117
|
end
|
data/lib/sakai-info/site.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# SakaiInfo::Site library
|
3
3
|
#
|
4
4
|
# Created 2012-02-17 daveadams@gmail.com
|
5
|
-
# Last updated 2012-03-
|
5
|
+
# Last updated 2012-03-09 daveadams@gmail.com
|
6
6
|
#
|
7
7
|
# https://github.com/daveadams/sakai-info
|
8
8
|
#
|
@@ -402,8 +402,17 @@ module SakaiInfo
|
|
402
402
|
|
403
403
|
def self.find_by_site_id(site_id)
|
404
404
|
properties = {}
|
405
|
-
|
406
|
-
|
405
|
+
# HACK: reading blobs via OCI8 is really slow, make the db server do it!
|
406
|
+
# This is multiple orders of magnitude faster.
|
407
|
+
# But, this will break if the property value is > 4000chars and may not work
|
408
|
+
# on mysql, so here's the original version:
|
409
|
+
# DB.connect[:sakai_site_property].where(:site_id => site_id).all.each do |row|
|
410
|
+
# properties[row[:name]] = row[:value].read
|
411
|
+
# end
|
412
|
+
DB.connect[:sakai_site_property].
|
413
|
+
select(:name, :to_char.sql_function(:value).as(:value)).
|
414
|
+
where(:site_id => site_id).all.each do |row|
|
415
|
+
properties[row[:name]] = row[:value]
|
407
416
|
end
|
408
417
|
return properties
|
409
418
|
end
|
data/lib/sakai-info/tool.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# SakaiInfo::Tool library
|
3
3
|
#
|
4
4
|
# Created 2012-03-08 daveadams@gmail.com
|
5
|
-
# Last updated 2012-03-
|
5
|
+
# Last updated 2012-03-09 daveadams@gmail.com
|
6
6
|
#
|
7
7
|
# https://github.com/daveadams/sakai-info
|
8
8
|
#
|
@@ -106,8 +106,17 @@ module SakaiInfo
|
|
106
106
|
|
107
107
|
def self.find_by_tool_id(tool_id)
|
108
108
|
properties = {}
|
109
|
-
|
110
|
-
|
109
|
+
# HACK: reading blobs via OCI8 is really slow, make the db server do it!
|
110
|
+
# This is multiple orders of magnitude faster.
|
111
|
+
# But, this will break if the property value is > 4000chars and may not work
|
112
|
+
# on mysql, so here's the original version:
|
113
|
+
# DB.connect[:sakai_site_tool_property].where(:tool_id => tool_id).all.each do |row|
|
114
|
+
# properties[row[:name]] = row[:value].read
|
115
|
+
# end
|
116
|
+
DB.connect[:sakai_site_tool_property].
|
117
|
+
select(:name, :to_char.sql_function(:value).as(:value)).
|
118
|
+
where(:tool_id => tool_id).all.each do |row|
|
119
|
+
properties[row[:name]] = row[:value]
|
111
120
|
end
|
112
121
|
return properties
|
113
122
|
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: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Adams
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-03-
|
18
|
+
date: 2012-03-09 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|