Return viewer count at a couple places in the API

pull/28/head
knotteye 2021-01-15 11:07:45 -06:00
parent 3d131980ae
commit f966bda4dd
2 changed files with 4 additions and 4 deletions

View File

@ -86,7 +86,7 @@ async function getConfig(username: string, all?: boolean): Promise<object>{
if(all) { if(all) {
let users = await db.query('SELECT stream_key,record_flag FROM users WHERE username='+db.raw.escape(username)); let users = await db.query('SELECT stream_key,record_flag FROM users WHERE username='+db.raw.escape(username));
if(users[0]) Object.assign(t, users[0]); if(users[0]) Object.assign(t, users[0]);
let usermeta = await db.query('SELECT title,about,live FROM user_meta WHERE username='+db.raw.escape(username)); let usermeta = await db.query('SELECT title,about,live,viewers FROM user_meta WHERE username='+db.raw.escape(username));
if(usermeta[0]) Object.assign(t, usermeta[0]); if(usermeta[0]) Object.assign(t, usermeta[0]);
let ci = await db.query('SELECT irc,xmpp,twitch,discord FROM chat_integration WHERE username='+db.raw.escape(username)); let ci = await db.query('SELECT irc,xmpp,twitch,discord FROM chat_integration WHERE username='+db.raw.escape(username));
if(ci[0]) Object.assign(t, ci[0]); if(ci[0]) Object.assign(t, ci[0]);
@ -94,7 +94,7 @@ async function getConfig(username: string, all?: boolean): Promise<object>{
if(tw[0]) t['twitch_mirror'] = Object.assign({}, tw[0]); if(tw[0]) t['twitch_mirror'] = Object.assign({}, tw[0]);
} }
else { else {
let um = await db.query('SELECT title,about,live FROM user_meta WHERE username='+db.raw.escape(username)); let um = await db.query('SELECT title,about,live,viewers FROM user_meta WHERE username='+db.raw.escape(username));
if(um[0]) Object.assign(t, um[0]); if(um[0]) Object.assign(t, um[0]);
} }
return t; return t;

View File

@ -187,7 +187,7 @@ async function initAPI() {
}); });
}); });
app.post('/api/users/live', (req, res) => { app.post('/api/users/live', (req, res) => {
let qs = 'SELECT username,title FROM user_meta WHERE live=1'; let qs = 'SELECT username,title,viewers FROM user_meta WHERE live=1';
if(req.body.sort) { if(req.body.sort) {
switch (req.body.sort) { switch (req.body.sort) {
@ -217,7 +217,7 @@ async function initAPI() {
}); });
}); });
app.post('/api/users/all', (req, res) => { app.post('/api/users/all', (req, res) => {
let qs = 'SELECT username,title,live FROM user_meta'; let qs = 'SELECT username,title,live,viewers FROM user_meta';
if(req.body.sort) { if(req.body.sort) {
switch (req.body.sort) { switch (req.body.sort) {