#202 : Optimisation du Dashboard.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user