This commit is contained in:
+16
-5
@@ -22,14 +22,22 @@ router.get('/hunt/:shortName/leaderboard', (req, res) => {
|
||||
return res.status(404).render('error', { title: 'Not Found', message: 'Hunt not found.' });
|
||||
}
|
||||
|
||||
const leaderboard = Hunts.getLeaderboard(hunt.id);
|
||||
res.render('hunt/leaderboard', { title: `${hunt.name} - Leaderboard`, hunt, leaderboard });
|
||||
const perPage = 25;
|
||||
const page = Math.max(1, parseInt(req.query.page) || 1);
|
||||
const totalCount = Hunts.getLeaderboardCount(hunt.id);
|
||||
const totalPages = Math.max(1, Math.ceil(totalCount / perPage));
|
||||
const leaderboard = Hunts.getLeaderboard(hunt.id, perPage, (page - 1) * perPage);
|
||||
res.render('hunt/leaderboard', { title: `${hunt.name} - Leaderboard`, hunt, leaderboard, page, totalPages, offset: (page - 1) * perPage });
|
||||
});
|
||||
|
||||
// ─── Global leaderboard ──────────────────────────────────
|
||||
router.get('/leaderboard', (req, res) => {
|
||||
const leaderboard = Scans.getGlobalLeaderboard();
|
||||
res.render('leaderboard/global', { title: 'Global Leaderboard', leaderboard });
|
||||
const perPage = 25;
|
||||
const page = Math.max(1, parseInt(req.query.page) || 1);
|
||||
const totalCount = Scans.getGlobalLeaderboardCount();
|
||||
const totalPages = Math.max(1, Math.ceil(totalCount / perPage));
|
||||
const leaderboard = Scans.getGlobalLeaderboard(perPage, (page - 1) * perPage);
|
||||
res.render('leaderboard/global', { title: 'Global Leaderboard', leaderboard, page, totalPages, offset: (page - 1) * perPage });
|
||||
});
|
||||
|
||||
// ─── Package profile (by card number — no secret code exposed) ────
|
||||
@@ -74,13 +82,16 @@ router.get('/player/:username', (req, res) => {
|
||||
const rank = Users.getRank(user.id);
|
||||
const totalPlayers = Users.getTotalPlayerCount();
|
||||
|
||||
const isOwnProfile = req.session && req.session.userId === user.id;
|
||||
|
||||
res.render('player/profile', {
|
||||
title: `${user.username}'s Profile`,
|
||||
profile,
|
||||
recentScans,
|
||||
huntBreakdown,
|
||||
rank,
|
||||
totalPlayers
|
||||
totalPlayers,
|
||||
isOwnProfile
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user