Module: CalculateStat::InstanceMethods

Defined in:
lib/enju_leaf/calculate_stat.rb

Instance Method Summary collapse

Instance Method Details

#check_dateObject

利用統計の日付をチェックします。



23
24
25
26
27
28
29
30
# File 'lib/enju_leaf/calculate_stat.rb', line 23

def check_date
  if self.start_date and self.end_date
    if self.start_date >= self.end_date
      errors.add(:start_date)
      errors.add(:end_date)
    end
  end
end

#send_messageObject

利用統計の集計完了メッセージを送信します。



33
34
35
36
37
38
39
40
# File 'lib/enju_leaf/calculate_stat.rb', line 33

def send_message
  sender = User.find(1) #system
  message_template = MessageTemplate.localized_template('counting_completed', user.profile.locale)
  request = MessageRequest.new
  request.assign_attributes({sender: sender, receiver: user, message_template: message_template})
  request.save_message_body
  request.transition_to!(:sent)
end