#202 : Optimisation du Dashboard.

This commit is contained in:
Loic Masi
2026-04-06 22:02:57 +02:00
parent 3859ba80a4
commit 20ef50cb51
9 changed files with 216 additions and 28 deletions

View File

@@ -131,4 +131,54 @@ public class LocalTitreRepository : ITitreRepository
existingTitre.IdArtiste = titre.IdArtiste;
existingTitre.Styles = titre.Styles;
}
/// <inheritdoc/>
public int CountLike()
{
return this.dataStore.Titres.Sum(t => t.NbLikes);
}
/// <inheritdoc/>
public int CountLecture()
{
return this.dataStore.Titres.Sum(t => t.NbLectures);
}
/// <inheritdoc/>
public string? FindMostReviewedArtistName()
{
return this.dataStore.Titres
.GroupBy(t => t.Artiste)
.OrderByDescending(g => g.Count())
.ThenBy(g => g.Key?.Nom)
.Select(g => g.Key?.Nom)
.FirstOrDefault();
}
/// <inheritdoc/>
public string? FindArtistNameWithMostReviewedAlbums()
{
return this.dataStore.Titres
.GroupBy(t => t.Artiste)
.Select(g => new
{
ArtistName = g.Key?.Nom,
AlbumCount = g.Select(t => t.Album).Distinct().Count(),
})
.OrderByDescending(x => x.AlbumCount)
.ThenBy(x => x.ArtistName)
.Select(x => x.ArtistName)
.FirstOrDefault();
}
/// <inheritdoc/>
public (int IdTitre, string Libelle)? FindMostPlayedTitle()
{
Titre? titre = this.dataStore.Titres
.OrderByDescending(t => t.NbLectures)
.ThenBy(t => t.Libelle)
.FirstOrDefault();
return titre == null ? null : (titre.IdTitre, titre.Libelle);
}
}