Skip to content

Commit

Permalink
#687 fix grouping with empty teams/groups
Browse files Browse the repository at this point in the history
  • Loading branch information
luechtdiode committed Jul 27, 2023
1 parent fe9e06c commit 1a3a230
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/main/scala/ch/seidel/kutu/data/GroupBy.scala
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,15 @@ sealed trait GroupBy {

private def mapAndSortLeaf(grouped: Map[DataObject, Seq[WertungView]]) = {
def reduce(switch: DataObject, list: Seq[WertungView]): Seq[GroupSection] = {
if (list.nonEmpty) {
val gl = GroupLeaf(switch, list)
val rl = list.filter(_.showInScoreList)
if (rl.nonEmpty) {
val gl = GroupLeaf(switch, rl)
kind match {
case Teamrangliste => {
TeamSums(gl).toSeq
TeamSums(gl)
}
case Einzelrangliste => Seq(gl)
case Kombirangliste => gl +: TeamSums(gl).toSeq
case Kombirangliste => gl +: TeamSums(gl)
}
} else {
Seq()
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/ch/seidel/kutu/data/GroupSection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,10 @@ object TeamSums {
case (_, teams) =>
val diszs = teams.flatMap(_.diszList).distinct
.groupBy(_._1).toList.sortBy(_._2.head._2).map(_._2.head._1)
val tms = teams.map { team =>
val tms = teams.filter(team => team.wertungen.nonEmpty).map { team =>
GroupLeaf(team, team.wertungen, diszs)
}
if (teams.isEmpty) None else Some(TeamSums(teamRows.groupKey.asInstanceOf[DataObject], tms))
if (tms.isEmpty) None else Some(TeamSums(teamRows.groupKey.asInstanceOf[DataObject], tms))
}
.toList
} else List[TeamSums]()
Expand Down

0 comments on commit 1a3a230

Please sign in to comment.