sakai-info 0.4.5 → 0.4.6

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # sakai-info Change History #
2
2
 
3
+ ### 0.4.6 ###
4
+
5
+ *Released 2012-05-19*
6
+
7
+ * Reinstated stub PrivateMessage class
8
+ * Removed defunct message.rb
9
+ * Re-added `count_by_date` method to PrivateMessage and ForumPost classes
10
+
3
11
  ### 0.4.5 ###
4
12
 
5
13
  *Released 2012-05-14*
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # sakai-info #
2
2
 
3
- last updated: 2012-05-14
3
+ last updated: 2012-05-19
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.4.5.gem`.
27
+ `sakai-info-0.4.6.gem`.
28
28
 
29
29
  Cleanup built gems using:
30
30
 
@@ -255,6 +255,10 @@ module SakaiInfo
255
255
  ForumPost.query_by_thread_id(thread_id).all.collect { |r| ForumPost.new(r) }
256
256
  end
257
257
 
258
+ def self.count_by_date(d)
259
+ count_by_date_and_message_type(d, "ME")
260
+ end
261
+
258
262
  def default_serialization
259
263
  {
260
264
  "id" => self.id,
@@ -62,6 +62,12 @@ module SakaiInfo
62
62
  GenericThread.types.keys.include?(mt)
63
63
  end
64
64
  end
65
+
66
+ class PrivateMessage < GenericMessage
67
+ def self.count_by_date(d)
68
+ count_by_date_and_message_type(d, "PM")
69
+ end
70
+ end
65
71
  end
66
72
 
67
73
 
@@ -1,3 +1,3 @@
1
1
  module SakaiInfo
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sakai-info
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-14 00:00:00.000000000 Z
12
+ date: 2012-05-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sequel
@@ -70,7 +70,6 @@ files:
70
70
  - lib/sakai-info/cli.rb
71
71
  - lib/sakai-info/question_pool.rb
72
72
  - lib/sakai-info/generic_message.rb
73
- - lib/sakai-info/message.rb
74
73
  - lib/sakai-info/content.rb
75
74
  - lib/sakai-info/page.rb
76
75
  - lib/sakai-info/sakai_xml_entity.rb
@@ -1,116 +0,0 @@
1
- # sakai-info/message.rb
2
- # SakaiInfo::Message library
3
- #
4
- # Created 2012-02-17 daveadams@gmail.com
5
- # Last updated 2012-05-10 daveadams@gmail.com
6
- #
7
- # https://github.com/daveadams/sakai-info
8
- #
9
- # This software is public domain.
10
- #
11
-
12
- module SakaiInfo
13
- class MessageTypeUUID
14
- # TODO: verify whether these are the same in all installs
15
- PRIVATE_MESSAGE = "d6404db7-7f6e-487a-00fe-baffce45d84c"
16
- FORUM_POST = "7143223e-355a-4865-00dd-cee9310499e4"
17
- end
18
-
19
- class UnknownMessageTypeException < SakaiException; end
20
- class GenericMessage < SakaiObject
21
- def self.count_by_date_and_message_type(count_date, message_type)
22
- date_str = nil
23
- if count_date.is_a? Time
24
- date_str = count_date.strftime("%Y-%m-%d")
25
- elsif count_date.is_a? String
26
- if count_date =~ /^\d\d\d\d-\d\d-\d\d$/
27
- date_str = count_date
28
- else
29
- raise InvalidDateException
30
- end
31
- else
32
- raise InvalidDateException
33
- end
34
-
35
- if not valid_message_type? message_type
36
- raise UnknownMessageTypeException
37
- end
38
-
39
- DB.connect.fetch("select count(*) as count from mfr_message_t " +
40
- "where message_dtype = ? and " +
41
- "to_char(created,'YYYY-MM-DD') = ? ",
42
- message_type, date_str).first[:count].to_i
43
- end
44
-
45
- private
46
- def self.valid_message_type?(s)
47
- s =="ME" or s =="PM"
48
- end
49
- end
50
-
51
- class PrivateMessage < GenericMessage
52
- def self.count_by_date(d)
53
- count_by_date_and_message_type(d, "PM")
54
- end
55
- end
56
-
57
- class ForumPost < GenericMessage
58
- def self.count_by_date(d)
59
- count_by_date_and_message_type(d, "ME")
60
- end
61
- end
62
-
63
- class Forum < SakaiObject
64
- attr_reader :id, :title
65
-
66
- def self.clear_cache
67
- @@cache = {}
68
- @@cache_by_site_id = {}
69
- end
70
- clear_cache
71
-
72
- def initialize(id, title)
73
- @id = id.to_i
74
- @title = title
75
- end
76
-
77
- def self.count_by_site_id(site_id)
78
- DB.connect.fetch("select count(*) as count from mfr_open_forum_t " +
79
- "where surrogatekey = (select id from mfr_area_t " +
80
- "where type_uuid = ? and context_id = ?)",
81
- MessageTypeUUID::FORUM_POST, site_id).first[:count].to_i
82
- end
83
-
84
- def self.find_by_site_id(site_id)
85
- if @@cache_by_site_id[site_id].nil?
86
- @@cache_by_site_id[site_id] = []
87
- DB.connect.fetch("select id, title from mfr_open_forum_t " +
88
- "where surrogatekey = (select id from mfr_area_t " +
89
- "where type_uuid = ? " +
90
- "and context_id = ?) order by sort_index",
91
- MessageTypeUUID::FORUM_POST, site_id) do |row|
92
- id = row[:id].to_i.to_s
93
- title = row[:title]
94
- @@cache[id] = Forum.new(id, title)
95
- @@cache_by_site_id[site_id] << @@cache[id]
96
- end
97
- end
98
- @@cache_by_site_id[site_id]
99
- end
100
-
101
- def default_serialization
102
- {
103
- "id" => self.id,
104
- "title" => self.title
105
- }
106
- end
107
-
108
- def summary_serialization
109
- {
110
- "id" => self.id,
111
- "title" => self.title
112
- }
113
- end
114
- end
115
- end
116
-