Skip to content

Commit

Permalink
remove recap perf.seconds which is not used
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Dec 15, 2024
1 parent aec7951 commit ea87935
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
7 changes: 2 additions & 5 deletions modules/recap/src/main/Recap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,14 @@ case class RecapGames(
sources: Map[Source, Int],
opponents: List[Counted[UserId]],
perfs: List[Recap.Perf]
):
def significantPerfs: List[Recap.Perf] = perfs.filter: p =>
(p.games > (nbs.total / 20)) || (p.seconds > (timePlaying.toSeconds / 20))
)

case class RecapPuzzles(nbs: NbWin = NbWin(), votes: PuzzleVotes = PuzzleVotes())

object Recap:

case class Counted[A](value: A, count: Int)
case class Perf(key: PerfKey, seconds: Int, games: Int):
def duration = seconds.seconds
case class Perf(key: PerfKey, games: Int)

type Openings = ByColor[Counted[SimpleOpening]]
lazy val nopening = Counted(SimpleOpening.openingList.head, 0)
Expand Down
9 changes: 4 additions & 5 deletions modules/recap/src/main/RecapBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ private final class RecapBuilder(
sources = scan.sources,
opponents = scan.opponents.toList.sortBy(-_._2).take(5).map(Recap.Counted.apply),
perfs = scan.perfs.toList
.sortBy(-_._2._1)
.sortBy(-_._2)
.map:
case (key, (seconds, games)) => Recap.Perf(key, seconds, games)
case (key, games) => Recap.Perf(key, games)
)

private def runGameScan(userId: UserId): Fu[GameScan] =
Expand All @@ -96,7 +96,7 @@ private final class RecapBuilder(
firstMoves: Map[SanStr, Int] = Map.empty,
sources: Map[Source, Int] = Map.empty,
opponents: Map[UserId, Int] = Map.empty,
perfs: Map[PerfKey, (Int, Int)] = Map.empty
perfs: Map[PerfKey, Int] = Map.empty
):
def addGame(userId: UserId)(g: Game): GameScan =
g.player(userId)
Expand Down Expand Up @@ -125,6 +125,5 @@ private final class RecapBuilder(
opponents = opponent.fold(opponents): op =>
opponents.updatedWith(op)(_.fold(1)(_ + 1).some),
perfs = perfs.updatedWith(g.perfKey): pk =>
pk.fold((durationSeconds, 1).some): (seconds, games) =>
(seconds + durationSeconds, games + 1).some
some(pk.orZero + 1)
)
1 change: 0 additions & 1 deletion ui/recap/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export interface Sources {

export interface RecapPerf {
key: Exclude<Perf, 'fromPosition'>;
seconds: number;
games: number;
}

Expand Down

0 comments on commit ea87935

Please sign in to comment.