varsql=`SELECT count(*) from battle_history where type = 'entertain' and start_time>= '${from_date} 00:00:00' and start_time < '${to_date} 00:00:00';`
console.log(sql)
client.query(sql,function(err,result){
done()
if(err){
returnconsole.error('error running query',err)
}
callback(err,result)
});
},
entertainDisconnect:function(callback){
varsql=`SELECT count(*) from battle_history where type = 'entertain' and start_time>= '${from_date} 00:00:00' and start_time < '${to_date} 00:00:00' and (userscorea<0 or userscoreb<0);`
console.log(sql)
client.query(sql,function(err,result){
done()
if(err){
returnconsole.error('error running query',err)
}
callback(err,result)
});
},
entertainUsers:function(callback){
varsql=`SELECT count(DISTINCT usernamea) from battle_history where type = 'entertain' and start_time>= '${from_date} 00:00:00' and start_time < '${to_date} 00:00:00';`
console.log(sql)
client.query(sql,function(err,result){
done()
if(err){
returnconsole.error('error running query',err)
}
callback(err,result)
});
},
athleticTotal:function(callback){
varsql=`SELECT count(*) from battle_history where type = 'athletic' and start_time>= '${from_date} 00:00:00' and start_time < '${to_date} 00:00:00';`
console.log(sql)
client.query(sql,function(err,result){
done()
if(err){
returnconsole.error('error running query',err)
}
callback(err,result)
});
},
athleticDisconnect:function(callback){
varsql=`SELECT count(*) from battle_history where type = 'athletic' and start_time>= '${from_date} 00:00:00' and (userscorea<0 or userscoreb<0) and start_time < '${to_date} 00:00:00';`
console.log(sql)
client.query(sql,function(err,result){
done()
if(err){
returnconsole.error('error running query',err)
}
callback(err,result)
});
},
athleticUsers:function(callback){
varsql=`SELECT count(DISTINCT usernamea) from battle_history where type = 'athletic' and start_time>= '${from_date} 00:00:00' and start_time < '${to_date} 00:00:00';`
console.log(sql)
client.query(sql,function(err,result){
done()
if(err){
returnconsole.error('error running query',err)
}
callback(err,result)
});
},
totalActive:function(callback){
varsql=`SELECT count(DISTINCT usernamea) from battle_history where start_time>= '${from_date} 00:00:00' and start_time < '${to_date} 00:00:00';`