Skip to content

Commit

Permalink
Fixed typo
Browse files Browse the repository at this point in the history
  • Loading branch information
isaiahzs committed Dec 13, 2017
1 parent eab2319 commit 288c643
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/se/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def initialize(key, **params)
@params = params
@quota = nil
@quota_used = 0
@backoff = Datetime.now
@backoff = DateTime.now
@logger_raw = Logger.new 'api_raw.log'
@logger_json = Logger.new 'api_json.log'
end
Expand All @@ -34,7 +34,7 @@ def posts(ids = "", **params)

def json(uri, **params)
throw "No site specified" if params[:site].nil?
backoff_for = ((@backoff - Datetime.now) * 24 * 60 * 60)
backoff_for = ((@backoff - DateTime.now) * 24 * 60 * 60)
backoff_for = 0 if backoff_for <= 0
if backoff_for > 0
puts "Backing off for #{backoff_for}"
Expand All @@ -46,7 +46,7 @@ def json(uri, **params)
resp_raw = Net::HTTP.get_response(URI("https://api.stackexchange.com/#{API_VERSION}/#{uri}?#{params}")).body
@logger_raw.info "https://api.stackexchange.com/#{API_VERSION}/#{uri}?#{params} => #{resp_raw}"
resp = JSON.parse(resp_raw)
@backoff = Datetime.now + (resp["backoff"].to_i/(24*60*60))
@backoff = DateTime.now + (resp["backoff"].to_i/(24*60*60))
@logger_json.info "https://api.stackexchange.com/#{API_VERSION}/#{uri}?#{params} => #{resp}"
@quota = resp["quota_remaining"]
@quota_used += 1
Expand Down

0 comments on commit 288c643

Please sign in to comment.