From b916e42f400dac8aa51670b15e439f87f0eb8939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 1 Nov 2021 19:36:18 -0400 Subject: [PATCH] feat: show number of events per type in acp --- src/controllers/admin/events.js | 6 ++++-- src/views/admin/advanced/events.tpl | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/controllers/admin/events.js b/src/controllers/admin/events.js index 1ca791ac16..f077972aca 100644 --- a/src/controllers/admin/events.js +++ b/src/controllers/admin/events.js @@ -20,15 +20,17 @@ eventsController.get = async function (req, res) { const currentFilter = req.query.type || ''; - const [eventCount, eventData] = await Promise.all([ + const [eventCount, eventData, counts] = await Promise.all([ db.sortedSetCount(`events:time${currentFilter ? `:${currentFilter}` : ''}`, from || '-inf', to), events.getEvents(currentFilter, start, stop, from || '-inf', to), + db.sortedSetsCard([''].concat(events.types).map(type => `events:time${type ? `:${type}` : ''}`)), ]); - const types = [''].concat(events.types).map(type => ({ + const types = [''].concat(events.types).map((type, index) => ({ value: type, name: type || 'all', selected: type === currentFilter, + count: counts[index], })); const pageCount = Math.max(1, Math.ceil(eventCount / itemsPerPage)); diff --git a/src/views/admin/advanced/events.tpl b/src/views/admin/advanced/events.tpl index 0456b4bcdd..ccaca544b6 100644 --- a/src/views/admin/advanced/events.tpl +++ b/src/views/admin/advanced/events.tpl @@ -40,7 +40,7 @@