melhorar o pdf
This commit is contained in:
@@ -672,7 +672,6 @@ class PlacarController extends ChangeNotifier {
|
|||||||
_autoSaveTimer?.cancel();
|
_autoSaveTimer?.cancel();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> saveGameStats(BuildContext context) async {
|
Future<void> saveGameStats(BuildContext context) async {
|
||||||
final supabase = Supabase.instance.client;
|
final supabase = Supabase.instance.client;
|
||||||
isSaving = true;
|
isSaving = true;
|
||||||
@@ -731,6 +730,7 @@ class PlacarController extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 1. Atualizar o Jogo
|
||||||
await supabase.from('games').update({
|
await supabase.from('games').update({
|
||||||
'my_score': myScore,
|
'my_score': myScore,
|
||||||
'opponent_score': opponentScore,
|
'opponent_score': opponentScore,
|
||||||
@@ -746,6 +746,7 @@ class PlacarController extends ChangeNotifier {
|
|||||||
'play_by_play': playByPlay,
|
'play_by_play': playByPlay,
|
||||||
}).eq('id', gameId);
|
}).eq('id', gameId);
|
||||||
|
|
||||||
|
// 2. Preparar as Estatísticas dos Jogadores
|
||||||
List<Map<String, dynamic>> batchStats = [];
|
List<Map<String, dynamic>> batchStats = [];
|
||||||
playerStats.forEach((playerId, stats) {
|
playerStats.forEach((playerId, stats) {
|
||||||
if (!playerId.startsWith("fake_")) {
|
if (!playerId.startsWith("fake_")) {
|
||||||
@@ -772,22 +773,47 @@ class PlacarController extends ChangeNotifier {
|
|||||||
'p2a': stats['p2a'],
|
'p2a': stats['p2a'],
|
||||||
'p3m': stats['p3m'],
|
'p3m': stats['p3m'],
|
||||||
'p3a': stats['p3a'],
|
'p3a': stats['p3a'],
|
||||||
'so': stats['so'], // As Faltas Sofridas
|
'so': stats['so'],
|
||||||
'il': stats['il'],
|
'il': stats['il'],
|
||||||
'li': stats['li'],
|
'li': stats['li'],
|
||||||
'pa': stats['pa'],
|
'pa': stats['pa'],
|
||||||
'tres_seg': stats['tres_seg'], // Os 3 Segundos com o nome correto
|
'tres_seg': stats['tres_seg'],
|
||||||
'dr': stats['dr'],
|
'dr': stats['dr'],
|
||||||
'minutos_jogados': stats['sec'],
|
'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);
|
await supabase.from('player_stats').delete().eq('game_id', gameId);
|
||||||
if (batchStats.isNotEmpty) {
|
if (batchStats.isNotEmpty) {
|
||||||
await supabase.from('player_stats').insert(batchStats);
|
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();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
await prefs.remove('backup_$gameId');
|
await prefs.remove('backup_$gameId');
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user