Load trajectory details (messages, submission, memory) on demand
()
| 1292 | @app.route("/load-trajectory-details") |
| 1293 | @print_timing |
| 1294 | def load_trajectory_details(): |
| 1295 | """Load trajectory details (messages, submission, memory) on demand""" |
| 1296 | # Don't allow trajectory loading in static mode (already embedded) - skip freezing |
| 1297 | if STATIC_MODE: |
| 1298 | return redirect(url_for("index")) |
| 1299 | |
| 1300 | selected_folder = request.args.get("folder") |
| 1301 | player_name = request.args.get("player") |
| 1302 | round_num = request.args.get("round") |
| 1303 | |
| 1304 | if not all([selected_folder, player_name, round_num]): |
| 1305 | return jsonify({"success": False, "error": "Missing required parameters"}), 400 |
| 1306 | |
| 1307 | try: |
| 1308 | round_num = int(round_num) |
| 1309 | except ValueError: |
| 1310 | return jsonify({"success": False, "error": "Invalid round number"}), 400 |
| 1311 | |
| 1312 | try: |
| 1313 | # Validate the selected folder exists and is a game folder |
| 1314 | folder_path = LOG_BASE_DIR / selected_folder |
| 1315 | if not folder_path.exists() or not is_game_folder(folder_path): |
| 1316 | return jsonify({"success": False, "error": "Invalid game folder"}), 404 |
| 1317 | |
| 1318 | # Parse trajectory with messages loaded |
| 1319 | parser = LogParser(folder_path) |
| 1320 | trajectory = parser.parse_trajectory(player_name, round_num, load_messages=True) |
| 1321 | |
| 1322 | if not trajectory: |
| 1323 | return jsonify({"success": False, "error": "Trajectory not found"}), 404 |
| 1324 | |
| 1325 | return jsonify( |
| 1326 | { |
| 1327 | "success": True, |
| 1328 | "messages": trajectory.messages, |
| 1329 | "submission": trajectory.submission, |
| 1330 | "memory": trajectory.memory, |
| 1331 | "trajectory_file_path": trajectory.trajectory_file_path, |
| 1332 | } |
| 1333 | ) |
| 1334 | |
| 1335 | except Exception as e: |
| 1336 | logger.error(f"Error loading trajectory details: {e}", exc_info=True) |
| 1337 | return jsonify({"success": False, "error": str(e)}), 500 |
| 1338 | |
| 1339 | |
| 1340 | @app.route("/load-trajectory-diffs") |
nothing calls this directly
no test coverage detected