#9 Major routes refactor and expansion, #15 Added API for statistics, Added search cache backend and functionality tests, Backend sync improvements
Build / build (push) Successful in 56s

This commit is contained in:
Sansan committed 2026-09-26 16:48:40 +02:00
1 parent e86c0f8e04
commit a8a2602f50
34 files changed
+1819 -1294

No files matched your search

+148 -135
View File
@@ -23,6 +23,110 @@ var doc = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/api/v1/statistics/songs/least-played": {
"get": {
"description": "Returns the top N least played songs with their soundtrack info",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"statistics"
],
"summary": "Get least played songs",
"parameters": [
{
"type": "integer",
"description": "Number of results (default: 10)",
"name": "limit",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/backend.SongInfoForStats"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/v1/statistics/songs/most-played": {
"get": {
"description": "Returns the top N most played songs with their soundtrack info",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"statistics"
],
"summary": "Get most played songs",
"parameters": [
{
"type": "integer",
"description": "Number of results (default: 10)",
"name": "limit",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/backend.SongInfoForStats"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/v1/statistics/soundtracks/last-played": {
"get": {
"description": "Returns the most recently played soundtracks",
@@ -266,110 +370,6 @@ var doc = `{
}
}
},
"/api/v1/statistics/songs/least-played": {
"get": {
"description": "Returns the top N least played songs with their game info",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"statistics"
],
"summary": "Get least played songs",
"parameters": [
{
"type": "integer",
"description": "Number of results (default: 10)",
"name": "limit",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/backend.SongInfoForStats"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/v1/statistics/songs/most-played": {
"get": {
"description": "Returns the top N most played songs with their game info",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"statistics"
],
"summary": "Get most played songs",
"parameters": [
{
"type": "integer",
"description": "Number of results (default: 10)",
"name": "limit",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/backend.SongInfoForStats"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/v1/statistics/summary": {
"get": {
"description": "Returns overall statistics about the music library",
@@ -404,7 +404,7 @@ var doc = `{
},
"/api/v1/token": {
"post": {
"description": "Returns a new session token for API access",
"description": "Returns a new session token for API access. Requires valid API password.",
"consumes": [
"application/json"
],
@@ -417,7 +417,7 @@ var doc = `{
"summary": "Create session token",
"parameters": [
{
"description": "Client type",
"description": "Password and client type",
"name": "request",
"in": "body",
"required": true,
@@ -442,6 +442,15 @@ var doc = `{
}
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
@@ -1369,9 +1378,38 @@ var doc = `{
}
},
"definitions": {
"backend.SongInfoForStats": {
"type": "object",
"properties": {
"file_name": {
"type": "string"
},
"path": {
"type": "string"
},
"song_name": {
"type": "string"
},
"soundtrack_id": {
"type": "integer"
},
"soundtrack_name": {
"type": "string"
},
"times_played": {
"type": "integer"
}
}
},
"backend.SoundtrackWithSongs": {
"type": "object",
"properties": {
"songs": {
"type": "array",
"items": {
"$ref": "#/definitions/backend.SongInfoForStats"
}
},
"soundtrack_id": {
"type": "integer"
},
@@ -1383,35 +1421,6 @@ var doc = `{
},
"soundtrack_played": {
"type": "integer"
},
"songs": {
"type": "array",
"items": {
"$ref": "#/definitions/backend.SongInfoForStats"
}
}
}
},
"backend.SongInfoForStats": {
"type": "object",
"properties": {
"file_name": {
"type": "string"
},
"soundtrack_id": {
"type": "integer"
},
"soundtrack_name": {
"type": "string"
},
"path": {
"type": "string"
},
"song_name": {
"type": "string"
},
"times_played": {
"type": "integer"
}
}
},
@@ -1466,6 +1475,10 @@ var doc = `{
"client_type": {
"description": "Optional: \"web\", \"mobile\", \"api\"",
"type": "string"
},
"password": {
"description": "Required: API password",
"type": "string"
}
}
},
+148 -135
View File
@@ -4,6 +4,110 @@
"contact": {}
},
"paths": {
"/api/v1/statistics/songs/least-played": {
"get": {
"description": "Returns the top N least played songs with their soundtrack info",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"statistics"
],
"summary": "Get least played songs",
"parameters": [
{
"type": "integer",
"description": "Number of results (default: 10)",
"name": "limit",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/backend.SongInfoForStats"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/v1/statistics/songs/most-played": {
"get": {
"description": "Returns the top N most played songs with their soundtrack info",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"statistics"
],
"summary": "Get most played songs",
"parameters": [
{
"type": "integer",
"description": "Number of results (default: 10)",
"name": "limit",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/backend.SongInfoForStats"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/v1/statistics/soundtracks/last-played": {
"get": {
"description": "Returns the most recently played soundtracks",
@@ -247,110 +351,6 @@
}
}
},
"/api/v1/statistics/songs/least-played": {
"get": {
"description": "Returns the top N least played songs with their soundtrack info",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"statistics"
],
"summary": "Get least played songs",
"parameters": [
{
"type": "integer",
"description": "Number of results (default: 10)",
"name": "limit",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/backend.SongInfoForStats"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/v1/statistics/songs/most-played": {
"get": {
"description": "Returns the top N most played songs with their soundtrack info",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"statistics"
],
"summary": "Get most played songs",
"parameters": [
{
"type": "integer",
"description": "Number of results (default: 10)",
"name": "limit",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/backend.SongInfoForStats"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/v1/statistics/summary": {
"get": {
"description": "Returns overall statistics about the music library",
@@ -385,7 +385,7 @@
},
"/api/v1/token": {
"post": {
"description": "Returns a new session token for API access",
"description": "Returns a new session token for API access. Requires valid API password.",
"consumes": [
"application/json"
],
@@ -398,7 +398,7 @@
"summary": "Create session token",
"parameters": [
{
"description": "Client type",
"description": "Password and client type",
"name": "request",
"in": "body",
"required": true,
@@ -423,6 +423,15 @@
}
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
@@ -1350,9 +1359,38 @@
}
},
"definitions": {
"backend.SongInfoForStats": {
"type": "object",
"properties": {
"file_name": {
"type": "string"
},
"path": {
"type": "string"
},
"song_name": {
"type": "string"
},
"soundtrack_id": {
"type": "integer"
},
"soundtrack_name": {
"type": "string"
},
"times_played": {
"type": "integer"
}
}
},
"backend.SoundtrackWithSongs": {
"type": "object",
"properties": {
"songs": {
"type": "array",
"items": {
"$ref": "#/definitions/backend.SongInfoForStats"
}
},
"soundtrack_id": {
"type": "integer"
},
@@ -1364,35 +1402,6 @@
},
"soundtrack_played": {
"type": "integer"
},
"songs": {
"type": "array",
"items": {
"$ref": "#/definitions/backend.SongInfoForStats"
}
}
}
},
"backend.SongInfoForStats": {
"type": "object",
"properties": {
"file_name": {
"type": "string"
},
"soundtrack_id": {
"type": "integer"
},
"soundtrack_name": {
"type": "string"
},
"path": {
"type": "string"
},
"song_name": {
"type": "string"
},
"times_played": {
"type": "integer"
}
}
},
@@ -1447,6 +1456,10 @@
"client_type": {
"description": "Optional: \"web\", \"mobile\", \"api\"",
"type": "string"
},
"password": {
"description": "Required: API password",
"type": "string"
}
}
},
+208 -196
View File
@@ -1,49 +1,49 @@
definitions:
backend.GameWithSongs:
properties:
game_id:
type: integer
game_last_played:
type: string
game_name:
type: string
game_played:
type: integer
songs:
items:
$ref: '#/definitions/backend.SongInfoForStats'
type: array
type: object
backend.SongInfoForStats:
properties:
file_name:
type: string
game_id:
type: integer
game_name:
type: string
path:
type: string
song_name:
type: string
soundtrack_id:
type: integer
soundtrack_name:
type: string
times_played:
type: integer
type: object
backend.SoundtrackWithSongs:
properties:
songs:
items:
$ref: '#/definitions/backend.SongInfoForStats'
type: array
soundtrack_id:
type: integer
soundtrack_last_played:
type: string
soundtrack_name:
type: string
soundtrack_played:
type: integer
type: object
backend.StatisticsSummary:
properties:
avg_game_plays:
avg_soundtrack_plays:
type: number
max_game_plays:
max_soundtrack_plays:
type: integer
min_game_plays:
min_soundtrack_plays:
type: integer
never_played_games:
never_played_soundtracks:
type: integer
played_games:
played_soundtracks:
type: integer
total_game_plays:
total_soundtrack_plays:
type: integer
total_games:
total_soundtracks:
type: integer
type: object
backend.VersionData:
@@ -64,6 +64,9 @@ definitions:
client_type:
description: 'Optional: "web", "mobile", "api"'
type: string
password:
description: 'Required: API password'
type: string
type: object
server.TokenResponse:
properties:
@@ -77,171 +80,11 @@ definitions:
info:
contact: {}
paths:
/api/v1/statistics/games/last-played:
get:
consumes:
- application/json
description: Returns the most recently played games
parameters:
- description: 'Number of results (default: 10)'
in: query
name: limit
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/backend.GameWithSongs'
type: array
"400":
description: Bad Request
schema:
additionalProperties:
type: string
type: object
"500":
description: Internal Server Error
schema:
additionalProperties:
type: string
type: object
summary: Get last played games
tags:
- statistics
/api/v1/statistics/games/least-played:
get:
consumes:
- application/json
description: Returns the top N least played games with their songs
parameters:
- description: 'Number of results (default: 10)'
in: query
name: limit
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/backend.GameWithSongs'
type: array
"400":
description: Bad Request
schema:
additionalProperties:
type: string
type: object
"500":
description: Internal Server Error
schema:
additionalProperties:
type: string
type: object
summary: Get least played games
tags:
- statistics
/api/v1/statistics/games/most-played:
get:
consumes:
- application/json
description: Returns the top N most played games with their songs
parameters:
- description: 'Number of results (default: 10)'
in: query
name: limit
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/backend.GameWithSongs'
type: array
"400":
description: Bad Request
schema:
additionalProperties:
type: string
type: object
"500":
description: Internal Server Error
schema:
additionalProperties:
type: string
type: object
summary: Get most played games
tags:
- statistics
/api/v1/statistics/games/never-played:
get:
consumes:
- application/json
description: Returns all games that have never been played (times_played = 0)
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/backend.GameWithSongs'
type: array
"500":
description: Internal Server Error
schema:
additionalProperties:
type: string
type: object
summary: Get never played games
tags:
- statistics
/api/v1/statistics/games/oldest-played:
get:
consumes:
- application/json
description: Returns the least recently played games (that have been played
at least once)
parameters:
- description: 'Number of results (default: 10)'
in: query
name: limit
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/backend.GameWithSongs'
type: array
"400":
description: Bad Request
schema:
additionalProperties:
type: string
type: object
"500":
description: Internal Server Error
schema:
additionalProperties:
type: string
type: object
summary: Get oldest played games
tags:
- statistics
/api/v1/statistics/songs/least-played:
get:
consumes:
- application/json
description: Returns the top N least played songs with their game info
description: Returns the top N least played songs with their soundtrack info
parameters:
- description: 'Number of results (default: 10)'
in: query
@@ -275,7 +118,7 @@ paths:
get:
consumes:
- application/json
description: Returns the top N most played songs with their game info
description: Returns the top N most played songs with their soundtrack info
parameters:
- description: 'Number of results (default: 10)'
in: query
@@ -305,6 +148,167 @@ paths:
summary: Get most played songs
tags:
- statistics
/api/v1/statistics/soundtracks/last-played:
get:
consumes:
- application/json
description: Returns the most recently played soundtracks
parameters:
- description: 'Number of results (default: 10)'
in: query
name: limit
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/backend.SoundtrackWithSongs'
type: array
"400":
description: Bad Request
schema:
additionalProperties:
type: string
type: object
"500":
description: Internal Server Error
schema:
additionalProperties:
type: string
type: object
summary: Get last played soundtracks
tags:
- statistics
/api/v1/statistics/soundtracks/least-played:
get:
consumes:
- application/json
description: Returns the top N least played soundtracks with their songs
parameters:
- description: 'Number of results (default: 10)'
in: query
name: limit
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/backend.SoundtrackWithSongs'
type: array
"400":
description: Bad Request
schema:
additionalProperties:
type: string
type: object
"500":
description: Internal Server Error
schema:
additionalProperties:
type: string
type: object
summary: Get least played soundtracks
tags:
- statistics
/api/v1/statistics/soundtracks/most-played:
get:
consumes:
- application/json
description: Returns the top N most played soundtracks with their songs
parameters:
- description: 'Number of results (default: 10)'
in: query
name: limit
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/backend.SoundtrackWithSongs'
type: array
"400":
description: Bad Request
schema:
additionalProperties:
type: string
type: object
"500":
description: Internal Server Error
schema:
additionalProperties:
type: string
type: object
summary: Get most played soundtracks
tags:
- statistics
/api/v1/statistics/soundtracks/never-played:
get:
consumes:
- application/json
description: Returns all soundtracks that have never been played (times_played
= 0)
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/backend.SoundtrackWithSongs'
type: array
"500":
description: Internal Server Error
schema:
additionalProperties:
type: string
type: object
summary: Get never played soundtracks
tags:
- statistics
/api/v1/statistics/soundtracks/oldest-played:
get:
consumes:
- application/json
description: Returns the least recently played soundtracks (that have been played
at least once)
parameters:
- description: 'Number of results (default: 10)'
in: query
name: limit
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/backend.SoundtrackWithSongs'
type: array
"400":
description: Bad Request
schema:
additionalProperties:
type: string
type: object
"500":
description: Internal Server Error
schema:
additionalProperties:
type: string
type: object
summary: Get oldest played soundtracks
tags:
- statistics
/api/v1/statistics/summary:
get:
consumes:
@@ -364,9 +368,10 @@ paths:
post:
consumes:
- application/json
description: Returns a new session token for API access
description: Returns a new session token for API access. Requires valid API
password.
parameters:
- description: Client type
- description: Password and client type
in: body
name: request
required: true
@@ -385,6 +390,12 @@ paths:
additionalProperties:
type: string
type: object
"401":
description: Unauthorized
schema:
additionalProperties:
type: string
type: object
"500":
description: Internal Server Error
schema:
@@ -606,7 +617,7 @@ paths:
get:
consumes:
- application/json
description: Returns a list of all games in order
description: Returns a list of all soundtracks in order
produces:
- application/json
responses:
@@ -628,7 +639,7 @@ paths:
get:
consumes:
- application/json
description: Returns a list of all games in random order
description: Returns a list of all soundtracks in random order
produces:
- application/json
responses:
@@ -852,7 +863,7 @@ paths:
get:
consumes:
- application/json
description: Starts syncing games with only new changes
description: Starts syncing soundtracks with only new changes
produces:
- application/json
responses:
@@ -871,7 +882,7 @@ paths:
get:
consumes:
- application/json
description: Starts a full sync of all games
description: Starts a full sync of all soundtracks
produces:
- application/json
responses:
@@ -883,7 +894,7 @@ paths:
description: Syncing is in progress
schema:
type: string
summary: Sync all games fully
summary: Sync all soundtracks fully
tags:
- sync
/sync/progress:
@@ -906,7 +917,8 @@ paths:
get:
consumes:
- application/json
description: Resets the games database by deleting all games and songs
description: Resets the soundtracks database by deleting all soundtracks and
songs
produces:
- application/json
responses: