Skip to content

Commit

Permalink
lib/api: Fix incorrect api stats collection
Browse files Browse the repository at this point in the history
  • Loading branch information
sogehige committed Apr 6, 2018
1 parent 902ff9c commit a8b062c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libs/api.js
Expand Up @@ -99,11 +99,11 @@ class API {
var request
try {
request = await snekfetch.get(url)
global.db.engine.insert('APIStats', { timestamp: _.now(), call: 'getChannelChattersUnofficialAPI', api: 'unofficial', endpoint: url, code: request.status })
global.db.engine.insert('api.stats', { timestamp: _.now(), call: 'getChannelChattersUnofficialAPI', api: 'unofficial', endpoint: url, code: request.status })
} catch (e) {
timeout = e.errno === 'ECONNREFUSED' || e.errno === 'ETIMEDOUT' ? 1000 : timeout
global.log.error(`${url} - ${e.message}`)
global.db.engine.insert('APIStats', { timestamp: _.now(), call: 'getChannelChattersUnofficialAPI', api: 'unofficial', endpoint: url, code: `${e.status} ${_.get(e, 'body.message', e.message)}` })
global.db.engine.insert('api.stats', { timestamp: _.now(), call: 'getChannelChattersUnofficialAPI', api: 'unofficial', endpoint: url, code: `${e.status} ${_.get(e, 'body.message', e.message)}` })
return
} finally {
setTimeout(() => this.getChannelChattersUnofficialAPI(), timeout)
Expand Down

0 comments on commit a8b062c

Please sign in to comment.