feat(score): allow to recalculate all score pp

This commit is contained in:
MingxuanGame
2025-08-14 06:50:17 +00:00
parent c8b6c1fa0e
commit ebbc0b8252
5 changed files with 163 additions and 11 deletions

View File

@@ -2,6 +2,7 @@ from __future__ import annotations
from contextlib import asynccontextmanager
from datetime import datetime
import os
from app.config import settings
from app.dependencies.database import engine, redis_client
@@ -20,6 +21,7 @@ from app.router.redirect import redirect_router
from app.service.calculate_all_user_rank import calculate_user_rank
from app.service.daily_challenge import daily_challenge_job
from app.service.osu_rx_statistics import create_rx_statistics
from app.service.pp_recalculate import recalculate_all_players_pp
from fastapi import FastAPI, HTTPException, Request
from fastapi.exceptions import RequestValidationError
@@ -31,9 +33,11 @@ import sentry_sdk
@asynccontextmanager
async def lifespan(app: FastAPI):
# on startup
await get_fetcher() # 初始化 fetcher
if os.environ.get("RECALCULATE_PP", "false").lower() == "true":
await recalculate_all_players_pp()
await create_rx_statistics()
await calculate_user_rank(True)
await get_fetcher() # 初始化 fetcher
init_scheduler()
await daily_challenge_job()
# on shutdown