Class: Wackamole::Mission
- Inherits:
-
Object
- Object
- Wackamole::Mission
- Extended by:
- SingleForwardable
- Defined in:
- lib/wackamole/models/mission.rb
Class Method Summary collapse
-
.count_logs(now = nil, single_day = false) ⇒ Object
———————————————————————– Compute mole counts for each moled apps.
-
.gen_conds(now, single_day) ⇒ Object
———————————————————————– generates mole logs conditons.
-
.pulse(last_tick) ⇒ Object
———————————————————————– Pick up moled application pulse.
Class Method Details
.count_logs(now = nil, single_day = false) ⇒ Object
Compute mole counts for each moled apps
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/wackamole/models/mission.rb', line 34 def self.count_logs( now=nil, single_day=false ) counts = {} conds = gen_conds( now, single_day ) Wackamole::Control.mole_databases.each do |db_name| db = Wackamole::Control.db( db_name ) app_name, env = Wackamole::Control.extract_app_info( db_name ) logs_cltn = db['logs'] totals = { Rackamole.feature => 0, Rackamole.perf => 0, Rackamole.fault => 0 } if counts[app_name] counts[app_name][env] = totals else counts[app_name] = { env => totals } end row = counts[app_name][env] [Rackamole.feature, Rackamole.perf, Rackamole.fault].each do |t| conds[:typ] = t logs = logs_cltn.find( conds, :fields => [:_id] ) row[t] = logs.count end end counts end |
.gen_conds(now, single_day) ⇒ Object
generates mole logs conditons
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/wackamole/models/mission.rb', line 18 def self.gen_conds( now, single_day ) conds = {} if now if single_day now = Time.local( now.year, now.month, now.day, 0, 0, 0 ).utc end date_id = now.to_date_id.to_s time_id = now.to_time_id conds[:did] = date_id conds[:tid] = {'$gte' => time_id} end conds end |
.pulse(last_tick) ⇒ Object
Pick up moled application pulse
9 10 11 12 13 14 |
# File 'lib/wackamole/models/mission.rb', line 9 def self.pulse( last_tick ) count_to_date = count_logs count_today = count_logs( last_tick, true ) count_last_tick = count_logs( last_tick ) { :to_date => count_to_date, :today => count_today, :last_tick => count_last_tick } end |