Class: SakaiInfo::GenericMessage

Inherits:
SakaiObject show all
Defined in:
lib/sakai-info/generic_message.rb

Direct Known Subclasses

ForumPost, PrivateMessage

Instance Attribute Summary

Attributes inherited from SakaiObject

#id

Class Method Summary collapse

Methods inherited from SakaiObject

all_serializations, #dbrow_only_serialization, #dbrow_serialization, #default_serialization, descendants, #object_type_serialization, #serialize, #shell_serialization, #summary_serialization, #to_csv, #to_json, #to_yaml

Class Method Details

.count_by_date_and_message_type(count_date, message_type) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/sakai-info/generic_message.rb', line 26

def self.count_by_date_and_message_type(count_date, message_type)
  date_str = nil
  if count_date.is_a? Time
    date_str = count_date.strftime("%Y-%m-%d")
  elsif count_date.is_a? String
    if count_date =~ /^\d\d\d\d-\d\d-\d\d$/
      date_str = count_date
    else
      raise InvalidDateException
    end
  else
    raise InvalidDateException
  end

  if not valid_message_type? message_type
    raise UnknownMessageTypeException
  end

  DB.connect.fetch("select count(*) as count from mfr_message_t " +
                   "where message_dtype = ? and " +
                   "to_char(created,'YYYY-MM-DD') = ? ",
                   message_type, date_str).first[:count].to_i
end

.typesObject



15
16
17
18
19
20
# File 'lib/sakai-info/generic_message.rb', line 15

def self.types
  {
    "ME" => "Forum Post",
    "PM" => "Private Message"
  }
end

.valid_message_type?(mt) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/sakai-info/generic_message.rb', line 22

def self.valid_message_type?(mt)
  GenericMessage.types.keys.include?(mt)
end