   return q
 
 module.exports = class Event
-  constructor: ({@accessTokenStream, @netox}) -> null
+  constructor: ({@accessTokenStream, @netox}) ->
+    @queryQueue = []
+    @batchCache = {}
 
   getAppNames: =>
     @netox.stream config.HYPERPLANE_API_URL + '/events',

      _.flatten res.results[0].series[0].values

  query: ({select, from, where, groupBy}) =>
    @netox.stream config.HYPERPLANE_API_URL + '/events',
      method: 'post'
      body:
        q: queryify {select, from, where, groupBy}
      headers:
        Authorization: "Token #{@accessTokenStream.getValue()}"
    .map (res) ->
      unless res.results
        throw new Error 'Something went wrong...'

      res.results[0]

  bluebird = 'bluebird'
  require bluebird

BATCH_SIZE = 25 # should take 5s based on 200ms (worst case) per query

queryify = ({select, from, where, groupBy}) ->
  q = "SELECT #{select} FROM #{from}"
  if where?
