mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: show number of events per type in acp
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<label for="type">[[admin/advanced/events:filter-type]]</label>
|
||||
<select id="type" name="type" class="form-control">
|
||||
<!-- BEGIN types -->
|
||||
<option value="{types.value}" <!-- IF types.selected -->selected<!-- ENDIF types.selected -->>{types.name}</option>
|
||||
<option value="{types.value}" <!-- IF types.selected -->selected<!-- ENDIF types.selected -->>{types.name} - ({types.count}) </option>
|
||||
<!-- END types -->
|
||||
</select>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user