From 340415195abe0b98e0524e51856f10c9a23604fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Gl=C3=B3rias?= Date: Sat, 4 Jan 2025 00:23:01 +0000 Subject: [PATCH 1/2] simplify replace system not need 2 systems --- .../relay/src/main/RelayPlayerEnrich.scala | 31 +++++++------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/modules/relay/src/main/RelayPlayerEnrich.scala b/modules/relay/src/main/RelayPlayerEnrich.scala index f79fc3d72ae10..bc3c318cca668 100644 --- a/modules/relay/src/main/RelayPlayerEnrich.scala +++ b/modules/relay/src/main/RelayPlayerEnrich.scala @@ -50,27 +50,18 @@ private case class RelayPlayersTextarea(text: String): lines.nonEmpty.so: text.linesIterator.take(1000).toList.flatMap(parse).toMap - // Original name / Optional rating / Optional title / Optional replacement name + // Original name / Optional FideID / Optional title / Optional rating / Optional replacement name private def parse(line: String): Option[(PlayerName, RelayPlayerLine)] = - line.split('=').map(_.trim) match - case Array(nameStr, fideId) => - val name = PlayerName(nameStr) - val parts = fideId.split('/').map(_.trim) - parts - .lift(0) - .flatMap(_.toIntOption) - .map: id => - name -> RelayPlayerLine(name.some, none, parts.lift(1).flatMap(PlayerTitle.get), FideId(id).some) - case _ => - val arr = line.split('/').map(_.trim) - arr - .lift(0) - .map: fromName => - PlayerName(fromName) -> RelayPlayerLine( - name = PlayerName.from(arr.lift(3).filter(_.nonEmpty)), - rating = IntRating.from(arr.lift(1).flatMap(_.toIntOption)), - title = arr.lift(2).flatMap(PlayerTitle.get) - ) + val arr = line.split('/').map(_.trim) + arr + .lift(0) + .map: fromName => + PlayerName(fromName) -> RelayPlayerLine( + name = PlayerName.from(arr.lift(4).filter(_.nonEmpty)), + rating = IntRating.from(arr.lift(3).flatMap(_.toIntOption)), + title = arr.lift(2).flatMap(PlayerTitle.get), + fideId = arr.lift(1).flatMap(_.toIntOption).map(FideId(_)) + ) private case class RelayPlayerLines(players: Map[PlayerName, RelayPlayerLine]): From cdb8c7a11d6eb4328c15c19c7966c7dfce366732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Gl=C3=B3rias?= Date: Sat, 4 Jan 2025 00:28:02 +0000 Subject: [PATCH 2/2] edit help info --- modules/relay/src/main/ui/RelayFormUi.scala | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/relay/src/main/ui/RelayFormUi.scala b/modules/relay/src/main/ui/RelayFormUi.scala index 0199c4036e4a0..16401cf342708 100644 --- a/modules/relay/src/main/ui/RelayFormUi.scala +++ b/modules/relay/src/main/ui/RelayFormUi.scala @@ -547,20 +547,20 @@ final class RelayFormUi(helpers: Helpers, ui: RelayUi, tourUi: RelayTourUi): trb.replacePlayerTags(), help = frag( // do not translate "One line per player, formatted as such:", - pre("player name = FIDE ID"), + pre("player name / FIDE ID"), "Example:", - pre("""Magnus Carlsen = 1503014"""), + pre("""Magnus Carlsen / 1503014"""), "Player names ignore case and punctuation, and match all possible combinations of 2 words:", br, """"Jorge Rick Vito" will match "Jorge Rick", "jorge vito", "Rick, Vito", etc.""", br, "If the player is NM or WNM, you can:", - pre("""Player Name = FIDE ID / Title"""), + pre("""Player Name / FIDE ID / title"""), "Alternatively, you may set tags manually, like so:", - pre("player name / rating / title / new name"), + pre("player name / FIDE ID / title / rating / new name"), "All values are optional. Example:", - pre("""Magnus Carlsen / 2863 / GM -YouGotLittUp / 1890 / / Louis Litt""") + pre("""Magnus Carlsen / / GM / 2863 +YouGotLittUp / / / 1890 / Louis Litt""") ).some, half = true )(form3.textarea(_)(rows := 3, spellcheck := "false", cls := "monospace")),