@@ -86,7 +86,7 @@ case class GroupLeaf[GK <: DataObject](override val groupKey: GK, list: Iterable
86
86
// val divider = if(!isDivided) 1 else groups.head._2.size
87
87
88
88
val gleichstandsregel = Gleichstandsregel (list.head.wettkampf)
89
- def buildColumns : List [WKCol ] = {
89
+ def buildColumns ( isAvgOnMultipleCompetitions : Boolean = true ) : List [WKCol ] = {
90
90
val athletCols : List [WKCol ] = List (
91
91
WKLeafCol [ResultRow ](text = " Rang" , prefWidth = 20 , styleClass = Seq (" data" ), valueMapper = gr => {
92
92
if (isTeamGroup) {
@@ -126,11 +126,11 @@ case class GroupLeaf[GK <: DataObject](override val groupKey: GK, list: Iterable
126
126
}
127
127
)
128
128
129
- val (disziplinCol : List [WKCol ], sumCol : List [WKCol ]) = buildCommonColumns
129
+ val (disziplinCol : List [WKCol ], sumCol : List [WKCol ]) = buildCommonColumns(isAvgOnMultipleCompetitions)
130
130
athletCols ++ disziplinCol ++ sumCol
131
131
}
132
132
133
- def buildCommonColumns : (List [WKCol ], List [WKCol ]) = {
133
+ def buildCommonColumns ( isAvgOnMultipleCompetitions : Boolean ) : (List [WKCol ], List [WKCol ]) = {
134
134
val indexer = Iterator .from(0 )
135
135
val disziplinCol : List [WKCol ] =
136
136
if (! isTeamGroup && groups.keySet.size > 1 ) {
@@ -170,7 +170,7 @@ case class GroupLeaf[GK <: DataObject](override val groupKey: GK, list: Iterable
170
170
cs.rang.formattedEnd
171
171
})
172
172
val cl : WKCol = WKGroupCol (
173
- text = if (anzahWettkaempfe > 1 ) {
173
+ text = if (isAvgOnMultipleCompetitions && anzahWettkaempfe > 1 ) {
174
174
s " ø aus " + grKey.easyprint
175
175
}
176
176
else {
@@ -227,7 +227,7 @@ case class GroupLeaf[GK <: DataObject](override val groupKey: GK, list: Iterable
227
227
lazy val clRang = WKLeafCol [ResultRow ](text = " Rang" , prefWidth = 60 , styleClass = Seq (" hintdata" ), valueMapper = gr => {
228
228
if (gr.resultate.size > index) f " ${gr.resultate(index).rang.endnote}%3.0f " else " "
229
229
})
230
- val cl = WKGroupCol (text = if (anzahWettkaempfe > 1 ) {
230
+ val cl = WKGroupCol (text = if (isAvgOnMultipleCompetitions && anzahWettkaempfe > 1 ) {
231
231
s " ø aus " + disziplin.name
232
232
}
233
233
else {
@@ -246,7 +246,7 @@ case class GroupLeaf[GK <: DataObject](override val groupKey: GK, list: Iterable
246
246
}
247
247
val sumColAll : List [WKCol ] = List (
248
248
WKLeafCol [ResultRow ](
249
- text = if (anzahWettkaempfe > 1 ) {
249
+ text = if (isAvgOnMultipleCompetitions && anzahWettkaempfe > 1 ) {
250
250
s " Total ø aus $dNoteLabel"
251
251
}
252
252
else {
@@ -257,7 +257,7 @@ case class GroupLeaf[GK <: DataObject](override val groupKey: GK, list: Iterable
257
257
}
258
258
),
259
259
WKLeafCol [ResultRow ](
260
- text = if (anzahWettkaempfe > 1 ) {
260
+ text = if (isAvgOnMultipleCompetitions && anzahWettkaempfe > 1 ) {
261
261
if (! isDivided && withDNotes) {
262
262
s " Total ø aus $eNoteLabel"
263
263
}
@@ -290,7 +290,7 @@ case class GroupLeaf[GK <: DataObject](override val groupKey: GK, list: Iterable
290
290
}
291
291
),
292
292
WKLeafCol [ResultRow ](
293
- text = if (anzahWettkaempfe > 1 ) {
293
+ text = if (isAvgOnMultipleCompetitions && anzahWettkaempfe > 1 ) {
294
294
s " Total ø Punkte "
295
295
}
296
296
else {
@@ -310,7 +310,7 @@ case class GroupLeaf[GK <: DataObject](override val groupKey: GK, list: Iterable
310
310
GroupSection .mapAvgRang(grp.map { d => (d._1, d._2._1, d._2._2) }).map(r => (r.groupKey.asInstanceOf [A ] -> r)).toMap
311
311
}
312
312
313
- def mapToAvgRowSummary (athlWertungen : Iterable [WertungView ] = list): (Resultat , Resultat , Iterable [(Disziplin , Long , Resultat , Resultat , Option [Int ], Option [BigDecimal ])], Iterable [(ProgrammView , Resultat , Resultat , Option [Int ], Option [BigDecimal ])], Resultat ) = {
313
+ def mapToAvgRowSummary (athlWertungen : Iterable [WertungView ] = list, avgSumsWithMultiCompetitions : Boolean ): (Resultat , Resultat , Iterable [(Disziplin , Long , Resultat , Resultat , Option [Int ], Option [BigDecimal ])], Iterable [(ProgrammView , Resultat , Resultat , Option [Int ], Option [BigDecimal ])], Resultat ) = {
314
314
val wks = athlWertungen.filter(_.endnote.nonEmpty).groupBy { w => w.wettkampf }
315
315
val wksums = wks.map { wk => aggreateFun(wk._2.map(w => w.resultat)) }.toList
316
316
val rsum = aggreateFun(wksums)
@@ -324,8 +324,9 @@ case class GroupLeaf[GK <: DataObject](override val groupKey: GK, list: Iterable
324
324
}) * aggreateFun.sortFactor
325
325
}
326
326
val gsum = aggreateFun(gwksums) // if (gwksums.nonEmpty) gwksums.reduce(_ + _) else Resultat(0, 0, 0)
327
- val avg = if (wksums.nonEmpty) rsum / wksums.size else Resultat (0 , 0 , 0 )
328
- val gavg = if (wksums.nonEmpty) gsum / wksums.size else Resultat (0 , 0 , 0 )
327
+ val wkDivider = if (avgSumsWithMultiCompetitions) wksums.size else 1
328
+ val avg = if (wksums.nonEmpty) rsum / wkDivider else Resultat (0 , 0 , 0 )
329
+ val gavg = if (wksums.nonEmpty) gsum / wkDivider else Resultat (0 , 0 , 0 )
329
330
val withAuszeichnung = anzahWettkaempfe == 1 && groups.size == 1 && wks.size == 1
330
331
val auszeichnung = if (withAuszeichnung) Some (wks.head._1.auszeichnung) else None
331
332
val auszeichnungEndnote = if (withAuszeichnung && wks.head._1.auszeichnungendnote > 0 ) Some (wks.head._1.auszeichnungendnote) else None
@@ -341,7 +342,8 @@ case class GroupLeaf[GK <: DataObject](override val groupKey: GK, list: Iterable
341
342
}).groupBy(_._1).map { x =>
342
343
val xsum = x._2.map(_._2).reduce(_ + _)
343
344
val xasum = aggreateFun(x._2.map(_._2))
344
- (x._1, xasum, xsum / x._2.size, auszeichnung, auszeichnungEndnote)
345
+ val diszDivider = if (avgSumsWithMultiCompetitions) x._2.size else 1
346
+ (x._1, xasum, xsum / diszDivider, auszeichnung, auszeichnungEndnote)
345
347
}
346
348
.toList.sortBy(d => d._1._1)
347
349
.map(d => (d._1._2, d._1._3, d._2, d._3, d._4, d._5))
@@ -359,17 +361,18 @@ case class GroupLeaf[GK <: DataObject](override val groupKey: GK, list: Iterable
359
361
}).groupBy(_._1).map { x =>
360
362
val xsum = x._2.map(_._2).reduce(_ + _)
361
363
val xasum = aggreateFun(x._2.map(_._2))
362
- (x._1, xasum, xsum / x._2.size, auszeichnung, auszeichnungEndnote)
364
+ val pgmDivider = if (avgSumsWithMultiCompetitions) x._2.size else 1
365
+ (x._1, xasum, xsum / pgmDivider, auszeichnung, auszeichnungEndnote)
363
366
}
364
367
.toList.sortBy(d => d._1.ord)
365
368
(rsum, avg, perDisziplinAvgs, perProgrammAvgs, gavg)
366
369
}
367
370
368
- def getTableData (sortAlphabetically : Boolean = false ) = {
371
+ def getTableData (sortAlphabetically : Boolean = false , avgSumsWithMultiCompetitions : Boolean = true ) = {
369
372
val avgPerAthlet = list.groupBy { x =>
370
373
x.athlet
371
374
}.map { x =>
372
- (x._1, mapToAvgRowSummary(x._2), x._2.head.wettkampfdisziplin.programm)
375
+ (x._1, mapToAvgRowSummary(x._2, avgSumsWithMultiCompetitions ), x._2.head.wettkampfdisziplin.programm)
373
376
}.filter(_._2._1.endnote > 0 )
374
377
375
378
// Beeinflusst die Total-Rangierung pro Gruppierung
@@ -408,7 +411,7 @@ case class GroupLeaf[GK <: DataObject](override val groupKey: GK, list: Iterable
408
411
// team.perDisciplinResults(w._1).indexOf(ww.avg) > -1)
409
412
team.isRelevantResult(w._1, ww.groupKey.asInstanceOf [AthletView ]))
410
413
}
411
- else if (anzahWettkaempfe > 1 ) {
414
+ else if (avgSumsWithMultiCompetitions && anzahWettkaempfe > 1 ) {
412
415
LeafRow (w._1.name,
413
416
ww.avg,
414
417
rang,
@@ -434,7 +437,7 @@ case class GroupLeaf[GK <: DataObject](override val groupKey: GK, list: Iterable
434
437
programmResults.map{w =>
435
438
val ww = avgProgrammRangMap(w._1)(athlet)
436
439
// val posproz = 100d * ww.rang.endnote / avgProgrammRangMap.size
437
- if (anzahWettkaempfe > 1 ) {
440
+ if (avgSumsWithMultiCompetitions && anzahWettkaempfe > 1 ) {
438
441
LeafRow (w._1.easyprint,
439
442
ww.avg,
440
443
ww.rang,
@@ -481,8 +484,11 @@ case class GroupLeaf[GK <: DataObject](override val groupKey: GK, list: Iterable
481
484
if (sortAlphabetically) {
482
485
prepared.sortBy(_.athlet.easyprint)
483
486
}
487
+ // else if(avgSumsWithMultiCompetitions) {
488
+ // }
484
489
else {
485
490
prepared.sortBy(_.rang.endnote)
491
+ // prepared.sortBy(_.sum.endnote).reverse
486
492
}
487
493
}
488
494
}
@@ -545,7 +551,7 @@ case class TeamSums(override val groupKey: DataObject, teamRows: List[GroupLeaf[
545
551
" "
546
552
})
547
553
)
548
- val (disziplinCol : List [WKCol ], sumCol : List [WKCol ]) = glGroup.buildCommonColumns
554
+ val (disziplinCol : List [WKCol ], sumCol : List [WKCol ]) = glGroup.buildCommonColumns( true )
549
555
teamCols ++ disziplinCol ++ sumCol
550
556
}
551
557
@@ -555,7 +561,7 @@ case class TeamSums(override val groupKey: DataObject, teamRows: List[GroupLeaf[
555
561
}.map { x =>
556
562
val (team, teamRow) = x
557
563
val teamwertungen = team.countingWertungen.flatMap(_._2)
558
- (team, teamRow.mapToAvgRowSummary(teamwertungen))
564
+ (team, teamRow.mapToAvgRowSummary(teamwertungen, avgSumsWithMultiCompetitions = true ))
559
565
}
560
566
561
567
(for (teamRuleGroup <- avgPerTeams.groupBy(_._1.rulename)) yield {
0 commit comments