Reworked database setup and added pagination

The database tables are now automatically created
The history lookup now uses a view for names (for simplicity and readability)
The all history lookup now uses a view combining all punishment history for efficiency
This commit is contained in:
2025-04-11 18:22:07 +02:00
parent 3c6141f7ad
commit 4b891dd672
13 changed files with 448 additions and 181 deletions
+4 -2
View File
@@ -16,7 +16,9 @@ paths:
$ref: './schemas/team/team.yml#/getTeam'
/history/{userType}/search/{type}:
$ref: './schemas/bans/bans.yml#/getUserNames'
/history/{userType}/name/{type}/{user}:
/history/{userType}/name/{type}/{user}/{page}:
$ref: './schemas/bans/bans.yml#/getHistoryForUsers'
/history/{userType}/uuid/{type}/{uuid}:
/history/{userType}/name/{type}/{page}:
$ref: './schemas/bans/bans.yml#/getHistoryForAll'
/history/{userType}/uuid/{type}/{uuid}/{page}:
$ref: './schemas/bans/bans.yml#/getHistoryForUuid'
@@ -29,14 +29,41 @@ getHistoryForUsers:
tags:
- history
summary: Get history for users
description: >
description: >
Get all users with punishment history of the specified type,
where the user name starts with the search query
where the user name starts with the search query, 100 records at a time
operationId: getHistoryForUsers
parameters:
- $ref: '#/components/parameters/UserType'
- $ref: '#/components/parameters/HistoryType'
- $ref: '#/components/parameters/User'
- $ref: '#/components/parameters/Page'
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/PunishmentHistory'
default:
description: Unexpected error
content:
application/json:
schema:
$ref: "../generic/errors.yml#/components/schemas/ApiError"
getHistoryForAll:
get:
tags:
- history
summary: Get history for users
description: >
Get all users with punishment history of the specified type,
where the user name starts with the search query, 100 records at a time
operationId: getHistoryForAll
parameters:
- $ref: '#/components/parameters/UserType'
- $ref: '#/components/parameters/HistoryType'
- $ref: '#/components/parameters/Page'
responses:
'200':
description: Successful operation
@@ -55,14 +82,15 @@ getHistoryForUuid:
tags:
- history
summary: Get user
description: >
description: >
Get all users with punishment history of the specified type,
where the user uuid matches
where the user uuid matches, 100 records at a time
operationId: getHistoryForUuid
parameters:
- $ref: '#/components/parameters/UserType'
- $ref: '#/components/parameters/HistoryType'
- $ref: '#/components/parameters/Uuid'
- $ref: '#/components/parameters/Page'
responses:
'200':
description: Successful operation
@@ -108,11 +136,25 @@ components:
type: string
enum: [ player, staff ]
description: Indicates if this is a staff history or a player history look up
Page:
name: page
in: path
required: true
schema:
type: integer
description: The page that should be retrieved
schemas:
PunishmentHistory:
type: array
items:
type: object
required:
- username
- uuid
- reason
- type
- punishmentTime
- punishmentUserUuid
properties:
username:
type: string