Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubZojdzik committed Apr 22, 2024
2 parents c4be8c5 + c9bee02 commit 9f56548
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/controllers/users.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ const ranking = async (request, response) => {
const { id } = request.body;
const admin = await isAdminUtil(id);
const competitionConf = yaml.load(fs.readFileSync(process.env.SOK_CONFIG, 'utf8'));
const competitionEnd = new Date(Date.parse(competitionConf.endTime));
let dbRes;
if (competitionConf.freeze === 'true' && !admin) {
const freezeTime = new Date(Date.parse(competitionConf.freezeTime));
Expand All @@ -193,13 +194,13 @@ const ranking = async (request, response) => {
JOIN
challenges c ON s.chall_id = c.id
WHERE
admin = 0 AND verified = true AND sent <= $1
admin = 0 AND verified = true AND sent <= $1 AND sent <= $2
GROUP BY
u.id, u.name
ORDER BY
points DESC, MAX(s.sent) ASC, u.name;
`,
[freezeTime.toISOString()],
[competitionEnd.toISOString(), freezeTime.toISOString()],
);
} else {
dbRes = await pool.query(
Expand All @@ -214,12 +215,13 @@ const ranking = async (request, response) => {
JOIN
challenges c ON s.chall_id = c.id
WHERE
admin = 0 AND verified = true
admin = 0 AND verified = true AND sent <= $1
GROUP BY
u.id, u.name
ORDER BY
points DESC, MAX(s.sent) ASC, u.name;
`,
[competitionEnd.toISOString()],
);
}
const dbRows = dbRes.rows;
Expand Down

0 comments on commit 9f56548

Please sign in to comment.