feat: add genre filtering and longest streak display in TopSongs
This commit is contained in:
parent
7f01af5d93
commit
ae0efe0756
@ -122,6 +122,14 @@ case class TopSongs(songs: List[Song] = List()) {
|
|||||||
.toMap
|
.toMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function return the song spent the most weeks on the chart
|
||||||
|
// It uses reduce to find the song with the maximum streak value
|
||||||
|
def longestStreak(): Song = {
|
||||||
|
songs.reduce((s1, s2) => {
|
||||||
|
if (s1.rank._1.streak.getOrElse(0) > s2.rank._1.streak.getOrElse(0)) s1 else s2
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// This function returns the top N songs by weeks on chart
|
// This function returns the top N songs by weeks on chart
|
||||||
// It sorts the songs by the streak value in descending order and takes the top N songs
|
// It sorts the songs by the streak value in descending order and takes the top N songs
|
||||||
def topNSongsByWeeks(n: Int): List[Song] = {
|
def topNSongsByWeeks(n: Int): List[Song] = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user