исправление роутинга, отображение общей статистики

This commit is contained in:
Alexey Kasyanchuk
2017-01-02 15:15:47 +03:00
parent e988f11891
commit 0549f099f0
2 changed files with 30 additions and 1 deletions

View File

@ -69,6 +69,11 @@ app.get('/', function(req, res)
app.use(express.static('build'));
app.get('*', function(req, res)
{
res.sendfile(__dirname + '/build/index.html');
});
io.on('connection', function(socket)
{
function baseRowData(row)
@ -96,6 +101,18 @@ io.on('connection', function(socket)
});
});
socket.on('statistic', function(callback)
{
let stats = {};
socketMysql.query('SELECT COUNT(*) as tornum FROM `torrents`', function (error, rows, fields) {
stats.torrents = rows[0].tornum;
socketMysql.query('SELECT COUNT(*) as filesnum FROM `files`', function (error, rows, fields) {
stats.files = rows[0].filesnum;
callback(stats)
});
});
});
socket.on('torrent', function(hash, options, callback)
{
if(hash.length != 40)