aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/mauve/notification.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/mauve/notification.rb b/lib/mauve/notification.rb
index 57d82d2..745660a 100644
--- a/lib/mauve/notification.rb
+++ b/lib/mauve/notification.rb
@@ -124,14 +124,20 @@ module Mauve
def no_one_in(people_list)
return true unless Configuration.current.people[people_list].respond_to?(:people)
+ @test_time = @time if @test_time.nil?
+
#
- # Cache the results to prevent hitting the calendar too many times.
+ # This is cached by itself, since calendar calls are rounded to the
+ # nearest minute. However this cache expires with the during runner,
+ # which isn't so insane..
#
- @no_one_in_cache ||= Hash.new
+ test_time = @test_time - @test_time.sec
- return @no_one_in_cache[people_list] if @no_one_in_cache.has_key?(people_list)
+ @no_one_in_cache ||= Hash.new{|h,k| h[k] = Hash.new}
- @no_one_in_cache[people_list] = Configuration.current.people[people_list].people(@time).empty?
+ return @no_one_in_cache[people_list][test_time] if @no_one_in_cache[people_list].has_key?(test_time)
+
+ @no_one_in_cache[people_list][test_time] = Configuration.current.people[people_list].people(test_time).empty?
end
# Returns true if the current hour is in the list of hours given.
@@ -248,7 +254,7 @@ module Mauve
@during = nil
@every = nil
@level = nil
- end
+ end
# @return [String]
def to_s