historique de toutes les parties

This commit is contained in:
2026-03-24 21:09:41 +01:00
parent 8444aa7aa7
commit a179611f29
4 changed files with 99 additions and 0 deletions

View File

@@ -169,6 +169,32 @@ public class GestionnaireBDD {
return data.toArray(new Object[0][]);
}
public Object[][] getHistoriqueParties() {
String sql = "SELECT u.identifiant, p.date_partie, p.score, p.campagne_id, p.difficulte_id, p.duree " +
"FROM parties p " +
"JOIN utilisateurs u ON p.utilisateur_id = u.id " +
"ORDER BY p.date_partie DESC";
List<Object[]> data = new ArrayList<>();
try (Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql)) {
while (rs.next()) {
Object[] row = {
rs.getString("identifiant"),
new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm").format(rs.getTimestamp("date_partie")),
rs.getInt("score"),
rs.getInt("campagne_id"),
rs.getInt("difficulte_id"),
rs.getInt("duree")
};
data.add(row);
}
} catch (SQLException e) {
System.out.println("Erreur lors de la récupération de l'historique : " + e.getMessage());
}
return data.toArray(new Object[0][]);
}
public void fermerConnexion() {
try {
if (conn != null) {