 ########test data#####
 
 @inserts = (connection, pcId, date, cpu) ->
-  console.log "querying for last insert"
   connection.query('insert into data (pc, dat, cpu ) values (?, ?, ?)',[pcId, date, cpu], (err, rows, fields) =>
     throw err if (err) 
-    console.log(rows.insertId);
+    console.log "inserted " +  rows.insertId
   )
 #setInterval ( => @getLastDataWrapper('pc1')), 5000
 setInterval ( => @inserts(connection, 'pc1', new Date(), Math.random())), 10000

#getAllData(connection, 'pc1')
#getAllData(connection, 'pc2')

@getAllDataWrapper = (pcId) ->
  getAllData connection, pcId, (result) ->
    for item in result
      io.sockets.emit 'chart', {chartData: item}
      console.log item
  
@getLastDataWrapper = (pcId) ->
  getLastData connection, pcId, (result) ->
    io.sockets.emit 'chart', {chartData: result}
    console.log result

#getAllData connection, 'pc1', (result) ->
#  for item in result



#connection.end()
#@getLastDataWrapper('pc1')
setInterval ( => @getLastDataWrapper(connection, 'pc1')), 5000
#  setInterval ( => @getAllDataWrapper('pc1')), 5000 

io.sockets.on 'connection', (socket) =>
