From 94d0537287e95927209173782a7c10b632bfc951 Mon Sep 17 00:00:00 2001 From: Herman Karlsson Date: Sun, 11 Feb 2024 02:49:35 +0100 Subject: [PATCH] add idx --- routes/index.js | 15 +++++++++++---- views/stats.pug | 14 ++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/routes/index.js b/routes/index.js index 257ca7a..7558af0 100644 --- a/routes/index.js +++ b/routes/index.js @@ -212,8 +212,11 @@ router.get('/stats', function(req, res) { return usermandates[b].days - usermandates[a].days; } return usermandates[b].count - usermandates[a].count; - }).map(function(key) { - return usermandates[key]; + }).map(function(key, index) { + return { + ...usermandates[key], + idx: index+1 + }; }); // Total days for each user on a mandate @@ -222,9 +225,13 @@ router.get('/stats', function(req, res) { return usermandates[b].count - usermandates[a].count; } return usermandates[b].days - usermandates[a].days; - }).map(function(key) { - return usermandates[key]; + }).map(function(key, index) { + return { + ...usermandates[key], + idx: index+1 + }; }); + // Pagination logic const page = parseInt(req.query.page) || 1; diff --git a/views/stats.pug b/views/stats.pug index ba22456..e2665aa 100644 --- a/views/stats.pug +++ b/views/stats.pug @@ -30,13 +30,16 @@ block content table(id='mandateCountTable', style=`${sorting == "count" ? "" : "display: none;"}`) thead - tr + tr + th th Användare th Antal mandat th Antal dagar tbody each user in paginatedItems tr + td + =user.idx td a(href='/user/' + user.user.kthid) =user.user.first_name + " " + user.user.last_name @@ -48,12 +51,15 @@ block content table(id='daysOnMandateTable', style=`${sorting == "days" ? "" : "display: none;"}`) thead tr - th Användare - th Antal mandat - th Antal dagar + th + th Användare + th Antal mandat + th Antal dagar tbody each user in paginatedItems tr + td + =user.idx td a(href='/user/' + user.user.kthid) =user.user.first_name + " " + user.user.last_name