Skip to content

Commit

Permalink
saves some state in redis so it doesn't spam hipchat.
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Reeder committed Jun 22, 2011
1 parent 0ce7198 commit ae19abd
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions my_suite_worker.rb
@@ -1,5 +1,8 @@
require_relative 'suite_worker'

require 'redis'
require 'uri'

# bump asdfasd

class MySuiteWorker < SuiteWorker
Expand All @@ -15,11 +18,29 @@ def on_complete
client = HipChat::API.new(config['hipchat']['api_key'])
# puts client.rooms_list
notify_users = false
do_post = true
msg = suite_results_output(:format=>'html')
if num_failed == 0
msg = "LBJ? - We're stylin'!<br/>" + msg
# Only post every so often when nothing failed
uri = URI.parse(config['redis']['url'])
redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
ts = redis.get "last_post"
log "ts=#{ts}"
skip_count = (redis.get("skip_count") || 0).to_i
log "skip_count=#{skip_count}"
if skip_count >= 10
msg = "LBJ? - We're stylin'!<br/>" + msg
redis.set "skip_count", 0
else
do_post = false
end
end
if do_post
log "POSTED: " + client.rooms_message(config['hipchat']['room_name'], 'UnitTestWorker', msg, notify_users).body
else
log "Not posting, no errors."
end
log "POSTED: " + client.rooms_message(config['hipchat']['room_name'], 'UnitTestWorker', msg, notify_users).body

end

end

0 comments on commit ae19abd

Please sign in to comment.