wip: checkpoint multi-game core work
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use crate::extractors::GameId;
|
||||
use axum::{
|
||||
extract::{Query, State},
|
||||
Json,
|
||||
@@ -12,8 +13,8 @@ use crate::{
|
||||
services::{profile as profile_svc, statistics as stats_svc},
|
||||
};
|
||||
|
||||
pub async fn get_statistics(State(state): State<AppState>) -> AppResult<Json<Value>> {
|
||||
let profile = profile_svc::get_active_profile(&state.pool).await?;
|
||||
pub async fn get_statistics(State(state): State<AppState>, game: GameId) -> AppResult<Json<Value>> {
|
||||
let profile = profile_svc::get_active_profile(&state.pool, game.as_str()).await?;
|
||||
let stats = stats_svc::get_or_create(&state.pool, &profile.id).await?;
|
||||
let pos_goals = stats_svc::get_position_goals(&state.pool, &profile.id).await?;
|
||||
|
||||
@@ -36,9 +37,10 @@ pub struct HistoryQuery {
|
||||
|
||||
pub async fn get_statistics_history(
|
||||
State(state): State<AppState>,
|
||||
game: GameId,
|
||||
Query(query): Query<HistoryQuery>,
|
||||
) -> AppResult<Json<Value>> {
|
||||
let profile = profile_svc::get_active_profile(&state.pool).await?;
|
||||
let profile = profile_svc::get_active_profile(&state.pool, game.as_str()).await?;
|
||||
let limit = query.limit.unwrap_or(20).clamp(1, 100);
|
||||
|
||||
let matches = sqlx::query_as::<_, Match>(
|
||||
|
||||
Reference in New Issue
Block a user