Skip to content

Commit

Permalink
only tweet results when they are bad -- comcast got confused by seein…
Browse files Browse the repository at this point in the history
…g one tweet and thought things were fixed when they just fluctuate
  • Loading branch information
peetucket committed Aug 27, 2020
1 parent 7d90aae commit 43e9a7d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions speedtest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
puts "Running speedtest at #{test_datetime}"
output = `speedtest -f json` # use speedtest client to get results (note: returns results in bytes per second)
results = JSON.parse(output)
tweet_message = nil

if results['type'] == 'result' # successful test!

Expand All @@ -45,8 +46,6 @@

if (download_speed < config["download_minimum"]) || (upload_speed < config["upload_minimum"])
tweet_message = "Not looking so great :( Our current Comcast @Xfinity internet speeds as of #{test_datetime}: Download is #{download_speed} mbps and upload is #{upload_speed} mbps. Our plan is #{config["plan_down"]} down/#{config["plan_up"]} up."
else
tweet_message = "Looking good! Our current Comcast @Xfinity internet speeds as of #{test_datetime}: Download is #{download_speed} mbps and upload is #{upload_speed} mbps. Our plan is #{config["plan_down"]} down/#{config["plan_up"]} up."
end

elsif results['error'] # speedtest-cli returned an error
Expand All @@ -56,12 +55,11 @@

else # we shouldn't get here unless something is really broken, like we couldn't even make a request to speedtest-cli...so unlikely tweeting will work either

tweet_message = 'Something is wrong with speedtest-cli -- no results reported.'
puts '...error: unknown reasons'

end

if config["tweet_results"]
if config["tweet_results"] && tweet_message
client.update(tweet_message)
puts '...tweeting results'
end

0 comments on commit 43e9a7d

Please sign in to comment.