Started work on statistic classes
This commit is contained in:
parent
9e82b16254
commit
cca5584c74
2 changed files with 20 additions and 2 deletions
5
src/classes/statistic_classes.py
Normal file
5
src/classes/statistic_classes.py
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
class BaseIntStatistic(BaseModel):
|
||||||
|
name: str
|
||||||
|
result: int
|
||||||
17
src/main.py
17
src/main.py
|
|
@ -4,7 +4,7 @@ from fastapi import FastAPI
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
|
|
||||||
from src.classes import boardgame_classes, play_classes
|
from src.classes import boardgame_classes, play_classes, statistic_classes
|
||||||
from src.modules import data_connection
|
from src.modules import data_connection
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
|
|
@ -61,4 +61,17 @@ def get_plays():
|
||||||
def get_players_from_play(play_id):
|
def get_players_from_play(play_id):
|
||||||
requested_players: list[play_classes.PlayPlayer] = data_connection.get_players_from_play(play_id)
|
requested_players: list[play_classes.PlayPlayer] = data_connection.get_players_from_play(play_id)
|
||||||
|
|
||||||
return requested_players
|
return requested_players
|
||||||
|
|
||||||
|
|
||||||
|
@app.get('/statistics/amount_of_games', response_model=statistic_classes.BaseIntStatistic)
|
||||||
|
def get_amount_of_games():
|
||||||
|
|
||||||
|
statistic_dict = {
|
||||||
|
"name":"Amount of games in owned collection",
|
||||||
|
"result":len(data_connection.get_user_owned_collection())
|
||||||
|
}
|
||||||
|
|
||||||
|
statistic_to_return = statistic_classes.BaseIntStatistic(**statistic_dict)
|
||||||
|
|
||||||
|
return statistic_to_return
|
||||||
Loading…
Reference in a new issue