Skip to content

Commit

Permalink
Server stats
Browse files Browse the repository at this point in the history
  • Loading branch information
palmertab committed Dec 17, 2024
1 parent 4b2eccc commit 699e89c
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions api/controllers/glp/servers.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const getTabroomUsage = {

const allStudents = await req.db.sequelize.query(`
select
count (distinct student.person)
count(distinct student.person)
from student, entry_student es, entry, event, tourn
where tourn.start < DATE_ADD(CURRENT_TIMESTAMP, INTERVAL 1 DAY)
and tourn.end > NOW()
Expand All @@ -113,28 +113,40 @@ export const getTabroomUsage = {
and entry.active = 1
and entry.id = es.entry
and es.student = student.id
group by student.id
and exists (
select timeslot.id
from timeslot
where timeslot.tourn = tourn.id
and timeslot.start > CURRENT_TIMESTAMP
and timeslot.end < DATE_ADD(CURRENT_TIMESTAMP, INTERVAL 1 DAY)
)
`, {
type: req.db.sequelize.QueryTypes.SELECT,
});

const allJudges = await req.db.sequelize.query(`
select
count (distinct judge.person)
count(distinct judge.person)
from judge, category, tourn
where tourn.start < DATE_ADD(CURRENT_TIMESTAMP, INTERVAL 1 DAY)
and tourn.end > CURRENT_TIMESTAMP
and tourn.id = category.tourn
and tourn.hidden != 1
and category.id = judge.category
group by judge.id
and exists (
select timeslot.id
from timeslot
where timeslot.tourn = tourn.id
and timeslot.start > CURRENT_TIMESTAMP
and timeslot.end < DATE_ADD(CURRENT_TIMESTAMP, INTERVAL 1 DAY)
)
`, {
type: req.db.sequelize.QueryTypes.SELECT,
});

const tournamentCount = await req.db.sequelize.query(`
select
count (distinct tourn.id)
count(distinct tourn.id)
from tourn
where tourn.start < DATE_ADD(CURRENT_TIMESTAMP, INTERVAL 1 DAY)
and tourn.end > CURRENT_TIMESTAMP
Expand Down

0 comments on commit 699e89c

Please sign in to comment.