Class: SirTracksAlot::Queue::ReportQueue
Constant Summary
collapse
- QUEUE_NAME =
'trackable_queue'
Class Method Summary
collapse
Methods inherited from Persistable
#==, #eql?, find_or_create, #hash, #to_hash
Class Method Details
.pop ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/sir_tracks_alot/queue/report_queue.rb', line 18
def self.pop
queue = self.find(:name => QUEUE_NAME)
if queue.nil? || queue.first.nil?
SirTracksAlot.log.info("Reports queue has not been created yet.")
return false
end
queue = queue.first
config = ReportConfig[queue.queue.pop]
process(config)
end
|
.process(config) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/sir_tracks_alot/queue/report_queue.rb', line 32
def self.process(config)
return false if config.nil?
SirTracksAlot.log.info("building report: #{config.inspect}")
begin
report = QueueHelper.constantize(QueueHelper.camelize("SirTracksAlot::Reports::#{config.report.capitalize}"))
html = report.render_html(config.options)
cache = ReportCache.find_or_create(:owner => config.owner, :report => config.report, :name => config.name)
cache.update(:html => html)
rescue Exception => e
SirTracksAlot.log.fatal("Error building report #{config.report} for #{config.owner}: #{e}")
end
true
end
|
.push(owner, report, name, options) ⇒ Object
11
12
13
14
15
16
|
# File 'lib/sir_tracks_alot/queue/report_queue.rb', line 11
def self.push(owner, report, name, options)
config = ReportConfig.find_or_create(:owner => owner.to_s, :report => report.to_s, :name => name.to_s)
config.options = options
queue = self.find_or_create(:name => QUEUE_NAME)
queue.queue << config.id
end
|