saving issue fixed
This commit is contained in:
@@ -1286,13 +1286,13 @@ def reset_league():
|
||||
# Archive current league if it exists
|
||||
league_state = load_league_state()
|
||||
if league_state:
|
||||
archive_league(league_state)
|
||||
|
||||
_, _ = archive_league(league_state) # Unpack tuple but ignore values
|
||||
|
||||
# Remove league, tournament, and results files
|
||||
for file_path in [LEAGUE_FILE, TOURNAMENT_FILE, RESULTS_FILE]:
|
||||
if os.path.exists(file_path):
|
||||
os.remove(file_path)
|
||||
|
||||
|
||||
return jsonify({'status': 'success'})
|
||||
except Exception as e:
|
||||
return jsonify({'status': 'error', 'message': str(e)}), 400
|
||||
@@ -1526,20 +1526,22 @@ def finish_tournament():
|
||||
|
||||
# Archive the tournament (only if it's NOT part of a league)
|
||||
archive_success = False
|
||||
archive_filename = None
|
||||
if not league_state: # Only archive standalone tournaments
|
||||
archive_success = archive_tournament(tournament_state, results)
|
||||
archive_success, archive_filename = archive_tournament(tournament_state, results)
|
||||
tournament_type = results.get('tournament_type', '20_targets')
|
||||
print(f"Standalone {tournament_type} tournament archived: {archive_success}")
|
||||
else:
|
||||
tournament_type = results.get('tournament_type', '20_targets')
|
||||
print(f"League {tournament_type} tournament - not archiving individual tournament")
|
||||
|
||||
|
||||
# Archive the league if it just finished
|
||||
league_archive_success = False
|
||||
league_archive_filename = None
|
||||
if league_finished and league_state:
|
||||
league_archive_success = archive_league(league_state)
|
||||
league_archive_success, league_archive_filename = archive_league(league_state)
|
||||
print(f"League archived: {league_archive_success}")
|
||||
|
||||
|
||||
# Save final results
|
||||
if save_results(results):
|
||||
# End the tournament by removing tournament state
|
||||
@@ -1550,15 +1552,21 @@ def finish_tournament():
|
||||
if league_finished and os.path.exists(LEAGUE_FILE):
|
||||
os.remove(LEAGUE_FILE)
|
||||
|
||||
# Delete results file after archiving
|
||||
if os.path.exists(RESULTS_FILE):
|
||||
os.remove(RESULTS_FILE)
|
||||
# Delete results file only if tournament was archived
|
||||
# For non-final league tournaments, keep results file so /results route can show both league standings and tournament results
|
||||
if archive_success or league_archive_success:
|
||||
# Tournament or league was archived, safe to delete results
|
||||
if os.path.exists(RESULTS_FILE):
|
||||
os.remove(RESULTS_FILE)
|
||||
# If not archived (non-final league tournament), keep results file for display
|
||||
|
||||
response_data = {
|
||||
'status': 'success',
|
||||
'results': results,
|
||||
'archived': archive_success,
|
||||
'archive_filename': archive_filename,
|
||||
'league_archived': league_archive_success if league_finished else None,
|
||||
'league_archive_filename': league_archive_filename if league_finished else None,
|
||||
'tournament_type': results.get('tournament_type', '20_targets'),
|
||||
'tournament_format': get_tournament_format_description(results.get('tournament_type', '20_targets'))
|
||||
}
|
||||
@@ -1683,12 +1691,12 @@ def emergency_reset():
|
||||
tournament_state = load_tournament_state()
|
||||
league_state = load_league_state()
|
||||
results = load_results()
|
||||
|
||||
|
||||
if tournament_state and results:
|
||||
archive_tournament(tournament_state, results)
|
||||
|
||||
_, _ = archive_tournament(tournament_state, results) # Unpack tuple but ignore values
|
||||
|
||||
if league_state:
|
||||
archive_league(league_state)
|
||||
_, _ = archive_league(league_state) # Unpack tuple but ignore values
|
||||
|
||||
# Remove all state files
|
||||
for file_path in [LEAGUE_FILE, TOURNAMENT_FILE, RESULTS_FILE]:
|
||||
|
||||
Reference in New Issue
Block a user