Skip to content

Commit

Permalink
Add overall speed/pace (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
v6ak committed Oct 1, 2023
1 parent ab8927c commit ec50c1f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 30 deletions.
51 changes: 31 additions & 20 deletions client/src/main/scala/com/v6ak/zbdb/TimeLineRenderer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,32 +120,23 @@ final class TimeLineRenderer(participantTable: ParticipantTable, plotRenderer: P
.collect { case p: WalkEvent.Walk => p.duration }
.foldLeft(TimeInterval(0))(_ + _)
val allPauses = events.collect { case p: WalkEvent.WaitingOnCheckpoint => p.duration }
val cumLenOption = events.collect { case p: WalkEvent.Arrival => p.checkpoint.cumLen }.lastOption
val totalPausesTime = allPauses.foldLeft(TimeInterval(0))(_ + _)
val totalTime = totalWalkTime + totalPausesTime
div(
div(`class` := "legend")(
h2("Legenda"),
legendTable,
),
div(`class` := "timeline-switches")(
switches.classSelect("time")(
"with-relative-time" -> "Čas od startu",
"with-clock-time" -> "Skutečný čas",
),
switches.classSelect("speed")(
"with-speed" -> "rychlost (km/h)",
"with-pace" -> "tempo (mm:ss / km)",
)
),
table(
`class` := "timeline timeline-real",
events.map(renderWalkEvent)
),
h2("Celkový čas"),
intro,
table(`class` := "timeline timeline-real")(events.map(renderWalkEvent)),
h2("Celkový čas a rychlost"),
s"Pochod ${gender.inflect("", "mu")} trval celkem ",
strong((totalWalkTime + totalPausesTime).toString),
strong(totalTime.toString),
s", z toho $totalWalkTime čistá chůze a $totalPausesTime čekání na stanovištích.",
if(allPauses.nonEmpty) s" Na jednom stanovišti čekal$langGenderSuffix průměrně ${totalPausesTime / allPauses.size}."
else "",
cumLenOption.fold("":Frag)(cumLen => p(
"Na ", strong(formatLength(cumLen)), s" cestě ${gender.inflect("šla", "šel")} průměrně ",
renderSpeedAndPace(totalTime, cumLen), " včetně pauz, resp. ", renderSpeedAndPace(totalWalkTime, cumLen),
" čisté chůze.",
)),
h2("Předbíhání"),
p("Za jeden úsek cesty počítáme předběhnutí maximálně jednou. Počítáme předběhnutí i na stanovišti."),
ul(
Expand All @@ -162,6 +153,25 @@ final class TimeLineRenderer(participantTable: ParticipantTable, plotRenderer: P
)
}

private def intro = {
fseq(
div(`class` := "legend")(
h2("Legenda"),
legendTable,
),
div(`class` := "timeline-switches")(
switches.classSelect("time")(
"with-relative-time" -> "Čas od startu",
"with-clock-time" -> "Skutečný čas",
),
switches.classSelect("speed")(
"with-speed" -> "rychlost (km/h)",
"with-pace" -> "tempo (mm:ss / km)",
)
),
)
}

private def langGenderSuffix = {
gender.inflect("a", "")
}
Expand Down Expand Up @@ -243,6 +253,7 @@ final class TimeLineRenderer(participantTable: ParticipantTable, plotRenderer: P

private def renderSpeedAndPace(duration: TimeInterval, len: BigDecimal) = fseq(
span(`class` := "speed")(strong(formatSpeed(len * 60 / duration.totalMinutes))),
" ",
span(`class` := "pace")(strong(f"${duration / len} / km"))
)

Expand Down
19 changes: 9 additions & 10 deletions server/app/assets/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,6 @@ body{
display: none;
}

&.timeline-real {
.with-relative-time & .clock-time,
.with-clock-time & .relative-time,
.with-pace & .speed,
.with-speed & .pace,
{
display: none;
}
}

.people-list-expand {
min-width: 43px;
}
Expand Down Expand Up @@ -318,6 +308,15 @@ body.without-details {
}
}

.with-relative-time & .clock-time,
.with-clock-time & .relative-time,
.with-pace & .speed,
.with-speed & .pace,
{
display: none;
}


@media screen {
.age{
display: block;
Expand Down

0 comments on commit ec50c1f

Please sign in to comment.