forked from Klagarge/MSE-AdvProg-MicroProject
		
	feat: add genre filtering and longest streak display in TopSongs
This commit is contained in:
		| @@ -122,6 +122,14 @@ case class TopSongs(songs: List[Song] = List()) { | ||||
|       .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 | ||||
|   // It sorts the songs by the streak value in descending order and takes the top N songs | ||||
|   def topNSongsByWeeks(n: Int): List[Song] = { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user