Code cleanup: standardized imports, refined formatting for consistency, and resolved minor redundancies in services, models, monitoring, and tools modules.

This commit is contained in:
Yûki VACHOT 2025-11-29 00:49:36 +01:00
parent e486d78e31
commit ec0fe38861
39 changed files with 222 additions and 239 deletions

View file

@ -1,4 +1,3 @@
@mcp.tool()
async def analyze_recent_games(count: int = 10) -> dict:
"""
@ -11,8 +10,7 @@ async def analyze_recent_games(count: int = 10) -> dict:
async with await get_async_session() as client:
# Get activity feed
feed_response = await client.get(
f"{GEOGUESSR_BASE_URL}/v4/feed/private",
params={"count": count * 2, "page": 0}
f"{GEOGUESSR_BASE_URL}/v4/feed/private", params={"count": count * 2, "page": 0}
)
feed_response.raise_for_status()
feed = feed_response.json()
@ -27,7 +25,9 @@ async def analyze_recent_games(count: int = 10) -> dict:
game_token = entry.get("payload", {}).get("gameToken")
if game_token:
try:
game_response = await client.get(f"{GEOGUESSR_BASE_URL}/v3/games/{game_token}")
game_response = await client.get(
f"{GEOGUESSR_BASE_URL}/v3/games/{game_token}"
)
if game_response.status_code == 200:
game = game_response.json()
@ -36,17 +36,19 @@ async def analyze_recent_games(count: int = 10) -> dict:
"map": game.get("map", {}).get("name", "Unknown"),
"mode": game.get("type", "Unknown"),
"total_score": 0,
"rounds": []
"rounds": [],
}
for round_data in game.get("player", {}).get("guesses", []):
round_score = round_data.get("roundScoreInPoints", 0)
game_info["total_score"] += round_score
game_info["rounds"].append({
"score": round_score,
"distance": round_data.get("distanceInMeters", 0),
"time": round_data.get("time", 0)
})
game_info["rounds"].append(
{
"score": round_score,
"distance": round_data.get("distanceInMeters", 0),
"time": round_data.get("time", 0),
}
)
total_rounds += 1
if round_score == 5000:
@ -63,8 +65,10 @@ async def analyze_recent_games(count: int = 10) -> dict:
"average_score": total_score / len(games_analyzed) if games_analyzed else 0,
"total_rounds": total_rounds,
"perfect_rounds": perfect_rounds,
"perfect_round_percentage": (perfect_rounds / total_rounds * 100) if total_rounds > 0 else 0,
"games": games_analyzed
"perfect_round_percentage": (
(perfect_rounds / total_rounds * 100) if total_rounds > 0 else 0
),
"games": games_analyzed,
}
@ -111,14 +115,16 @@ async def get_performance_summary() -> dict:
# Get achievements
try:
achievements_response = await client.get(f"{GEOGUESSR_BASE_URL}/v3/profiles/achievements")
achievements_response = await client.get(
f"{GEOGUESSR_BASE_URL}/v3/profiles/achievements"
)
achievements_response.raise_for_status()
achievements = achievements_response.json()
results["achievements_summary"] = {
"total": len(achievements) if isinstance(achievements, list) else 0,
"achievements": achievements
"achievements": achievements,
}
except Exception as e:
results["achievements_error"] = str(e)
return results
return results

View file

@ -1,5 +1,7 @@
"""MCP tools for auth operations."""
import logging
from mcp.server.fastmcp import FastMCP
from ..auth.session import SessionManager
@ -44,7 +46,6 @@ def register_auth_tools(mcp: FastMCP, session_manager: SessionManager):
logger.error(f"Login error: {e}")
return {"success": False, "error": f"An unexpected error occurred: {str(e)}"}
@mcp.tool()
async def logout() -> dict:
"""
@ -63,7 +64,6 @@ def register_auth_tools(mcp: FastMCP, session_manager: SessionManager):
return {"success": False, "message": "No active session"}
@mcp.tool()
async def set_session_token(token: str) -> dict:
"""
@ -86,7 +86,6 @@ def register_auth_tools(mcp: FastMCP, session_manager: SessionManager):
return {"success": False, "error": "Invalid or expired session token"}
@mcp.tool()
async def set_ncfa_cookie(cookie: str) -> dict:
"""
@ -135,7 +134,6 @@ def register_auth_tools(mcp: FastMCP, session_manager: SessionManager):
"session_token": session_token,
}
@mcp.tool()
async def get_auth_status() -> dict:
"""