Class LogLogSubscription
In: app/models/log_log_subscription.rb
Parent: ActiveRecord::Base

Methods

External Aliases

save -> __save__

Public Class methods

Class-methods

[Source]

    # File app/models/log_log_subscription.rb, line 21
21:   def self.send_out_alerts(period)
22:     sent_to = []
23:     begin
24:       LogLogSubscription.find_each(:conditions => ['period = ?', period]) do |lls|
25:         url = URI.parse(GlobalConfig.log_log_site + 
26:             "/channels/" + lls.channel + "/periods/" + period + ".txt")
27:         begin
28:           page = Net::HTTP.get_response(url)
29:           periodical = page.body
30:           if periodical =~ /[^\s]/
31:             if lls.channel == "logis"
32:               Notifier.deliver_logis_log(lls.user, period, periodical)
33:             else
34:               Notifier.deliver_personalized_log(lls.user, period, periodical)
35:             end
36:             sent_to << lls.user.name
37:           end
38:         rescue
39:         end
40:       end
41:     rescue
42:       ActiveRecord::Base.logger.error "LogLog enabled, but not found.\n"
43:     end
44:     if sent_to.empty?
45:       sent_to = ['Nobody'] 
46:     end
47:     if period == "weekly"
48:       l_count = Logi.count(:conditions => 'created_at > "' + 1.week.ago.to_s(:db) + '"')
49:       Notifier.deliver_admin_log(period, sent_to.size,
50:           "Sent #{period} to: " + sent_to.join(', ') + "\n" +
51:           "There were #{l_count} new logis")
52:     else
53:       s_count = (sent_to == ['Nobody'] ? 0 : sent_to.size)
54:       Notifier.deliver_admin_log(period, s_count,
55:           "Sent personalized #{period} to: " + sent_to.join(', '))
56:     end
57:   end

Public Instance methods

[Source]

    # File app/models/log_log_subscription.rb, line 60
60:   def save
61:     begin
62:       self.__save__
63:     rescue
64:       ActiveRecord::Base.logger.error "Error: LogLog enabled, but not found.\n"
65:     end
66:   end

[Validate]