Add API endpoint to retrieve total punishment counts

Introduced a new API endpoint `/history/total` for fetching the total counts of bans, mutes, kicks, and warnings. Added database mapping and DTO classes to support this functionality, along with necessary schema and controller updates.
This commit is contained in:
2025-04-11 23:27:20 +02:00
parent 807569a0a1
commit 44d28494e5
6 changed files with 107 additions and 7 deletions
+2
View File
@@ -22,3 +22,5 @@ paths:
$ref: './schemas/bans/bans.yml#/getHistoryForAll'
/history/{userType}/uuid/{type}/{uuid}/{page}:
$ref: './schemas/bans/bans.yml#/getHistoryForUuid'
/history/total:
$ref: './schemas/bans/bans.yml#/getTotalPunishments'
@@ -23,7 +23,7 @@ getUserNames:
content:
application/json:
schema:
$ref: "../generic/errors.yml#/components/schemas/ApiError"
$ref: '../generic/errors.yml#/components/schemas/ApiError'
getHistoryForUsers:
get:
tags:
@@ -50,7 +50,7 @@ getHistoryForUsers:
content:
application/json:
schema:
$ref: "../generic/errors.yml#/components/schemas/ApiError"
$ref: '../generic/errors.yml#/components/schemas/ApiError'
getHistoryForAll:
get:
tags:
@@ -76,7 +76,7 @@ getHistoryForAll:
content:
application/json:
schema:
$ref: "../generic/errors.yml#/components/schemas/ApiError"
$ref: '../generic/errors.yml#/components/schemas/ApiError'
getHistoryForUuid:
get:
tags:
@@ -103,7 +103,27 @@ getHistoryForUuid:
content:
application/json:
schema:
$ref: "../generic/errors.yml#/components/schemas/ApiError"
$ref: '../generic/errors.yml#/components/schemas/ApiError'
getTotalPunishments:
get:
tags:
- history
summary: Get total history count per type
description: Retrieves the total count of punishments for each type available (ban, mute, kick, warn, or all).
operationId: getTotalPunishments
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/HistoryCount'
default:
description: Unexpected error
content:
application/json:
schema:
$ref: '../generic/errors.yml#/components/schemas/ApiError'
components:
parameters:
HistoryType:
@@ -205,3 +225,22 @@ components:
required:
- name
- uuid
HistoryCount:
type: object
properties:
bans:
type: integer
description: The total amounts of bans
example: 10528
mutes:
type: integer
description: The total amounts of mutes
example: 2350
warnings:
type: integer
description: The total amounts of warnings
example: 3881
kicks:
type: integer
description: The total amounts of kicks
example: 1769