From 72ec4703affb075fcaded0868caefad689374402 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Thu, 27 Jun 2024 12:27:08 +0200 Subject: [PATCH] better broadcast error reporting --- modules/relay/src/main/RelayListing.scala | 7 +++---- modules/relay/src/main/RelayTour.scala | 8 +++++++- modules/relay/src/main/ui/RelayTourUi.scala | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/relay/src/main/RelayListing.scala b/modules/relay/src/main/RelayListing.scala index 49191e9c3f33..dfceff7f8ec7 100644 --- a/modules/relay/src/main/RelayListing.scala +++ b/modules/relay/src/main/RelayListing.scala @@ -26,10 +26,9 @@ final class RelayListing( local = "_id", foreign = "tourId", pipe = List( - $doc("$match" -> $doc("finished" -> false)), - $doc("$addFields" -> $doc("sync.log" -> $arr())), - $doc("$sort" -> RelayRoundRepo.sort.chrono), - $doc("$limit" -> 1) + $doc("$match" -> $doc("finished" -> false)), + $doc("$sort" -> RelayRoundRepo.sort.chrono), + $doc("$limit" -> 1) ) ) for diff --git a/modules/relay/src/main/RelayTour.scala b/modules/relay/src/main/RelayTour.scala index f0c106eed16e..ac9fc74ee51d 100644 --- a/modules/relay/src/main/RelayTour.scala +++ b/modules/relay/src/main/RelayTour.scala @@ -85,7 +85,13 @@ object RelayTour: display: RelayRound, // which round to show on the tour link link: RelayRound, // which round to actually link to group: Option[RelayGroup.Name] - ) extends RelayRound.AndTourAndGroup + ) extends RelayRound.AndTourAndGroup: + def errors: List[String] = + val round = display + ~round.sync.log.lastErrors.some + .filter(_.nonEmpty) + .orElse: + (round.hasStarted && !round.sync.ongoing).option(List("Not syncing!")) case class WithLastRound(tour: RelayTour, round: RelayRound, group: Option[RelayGroup.Name]) extends RelayRound.AndTourAndGroup: diff --git a/modules/relay/src/main/ui/RelayTourUi.scala b/modules/relay/src/main/ui/RelayTourUi.scala index 7a3f1f61e4ed..e702512d7556 100644 --- a/modules/relay/src/main/ui/RelayTourUi.scala +++ b/modules/relay/src/main/ui/RelayTourUi.scala @@ -51,7 +51,7 @@ final class RelayTourUi(helpers: Helpers, ui: RelayUi): ) private def adminIndex(active: List[RelayTour.ActiveWithSomeRounds])(using Context) = - val errored = active.flatMap(a => a.link.sync.log.lastErrors.some.filter(_.nonEmpty).map(a -> _)) + val errored = active.flatMap(a => a.errors.some.filter(_.nonEmpty).map(a -> _)) errored.nonEmpty.option: div(cls := "relay-index__admin")( h2("Ongoing broadcasts with errors"),