melhorar o pdf
This commit is contained in:
@@ -672,8 +672,7 @@ class PlacarController extends ChangeNotifier {
|
||||
_autoSaveTimer?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> saveGameStats(BuildContext context) async {
|
||||
Future<void> saveGameStats(BuildContext context) async {
|
||||
final supabase = Supabase.instance.client;
|
||||
isSaving = true;
|
||||
notifyListeners();
|
||||
@@ -731,6 +730,7 @@ class PlacarController extends ChangeNotifier {
|
||||
}
|
||||
});
|
||||
|
||||
// 1. Atualizar o Jogo
|
||||
await supabase.from('games').update({
|
||||
'my_score': myScore,
|
||||
'opponent_score': opponentScore,
|
||||
@@ -746,6 +746,7 @@ class PlacarController extends ChangeNotifier {
|
||||
'play_by_play': playByPlay,
|
||||
}).eq('id', gameId);
|
||||
|
||||
// 2. Preparar as Estatísticas dos Jogadores
|
||||
List<Map<String, dynamic>> batchStats = [];
|
||||
playerStats.forEach((playerId, stats) {
|
||||
if (!playerId.startsWith("fake_")) {
|
||||
@@ -772,22 +773,47 @@ class PlacarController extends ChangeNotifier {
|
||||
'p2a': stats['p2a'],
|
||||
'p3m': stats['p3m'],
|
||||
'p3a': stats['p3a'],
|
||||
'so': stats['so'], // As Faltas Sofridas
|
||||
'so': stats['so'],
|
||||
'il': stats['il'],
|
||||
'li': stats['li'],
|
||||
'pa': stats['pa'],
|
||||
'tres_seg': stats['tres_seg'], // Os 3 Segundos com o nome correto
|
||||
'tres_seg': stats['tres_seg'],
|
||||
'dr': stats['dr'],
|
||||
'minutos_jogados': stats['sec'],
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 3. Preparar os Locais dos Lançamentos (MAPA DE CALOR) - O QUE FALTAVA
|
||||
List<Map<String, dynamic>> batchShots = [];
|
||||
for (var shot in matchShots) {
|
||||
if (!shot.playerId.startsWith("fake_")) {
|
||||
batchShots.add({
|
||||
'game_id': gameId,
|
||||
'member_id': shot.playerId,
|
||||
'player_name': shot.playerName,
|
||||
'relative_x': shot.relativeX,
|
||||
'relative_y': shot.relativeY,
|
||||
'is_make': shot.isMake,
|
||||
'zone': shot.zone,
|
||||
'points': shot.points,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Guardar na BD: Apaga as antigas e insere as atualizadas
|
||||
await supabase.from('player_stats').delete().eq('game_id', gameId);
|
||||
if (batchStats.isNotEmpty) {
|
||||
await supabase.from('player_stats').insert(batchStats);
|
||||
}
|
||||
|
||||
// Guardar mapa de calor na BD
|
||||
await supabase.from('shot_locations').delete().eq('game_id', gameId);
|
||||
if (batchShots.isNotEmpty) {
|
||||
await supabase.from('shot_locations').insert(batchShots);
|
||||
}
|
||||
|
||||
// Limpar backup local
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.remove('backup_$gameId');
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user