lib/wackamole/models/mission.rb in wackamole-0.0.8 vs lib/wackamole/models/mission.rb in wackamole-0.0.9
- old
+ new
@@ -13,20 +13,22 @@
{ :to_date => count_to_date, :today => count_today, :last_tick => count_last_tick }
end
# -----------------------------------------------------------------------
# generates mole logs conditons
- def self.gen_conds( now, single_day )
+ 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
+ conds = SearchFilter.time_conds( now, 1 )
+ else
+ now = now.clone.utc
+ date_id = now.to_date_id.to_s
+ time_id = now.to_time_id
+ conds[:did] = { '$gte' => date_id }
+ conds[:tid] = { '$gte' => time_id }
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
# -----------------------------------------------------------------------
@@ -51,10 +53,10 @@
conds[:typ] = t
logs = logs_cltn.find( conds, :fields => [:_id] )
row[t] = logs.count
end
end
- counts
+ counts
end
# =========================================================================
private
\ No newline at end of file