mirror of
https://github.com/lichess-org/lila.git
synced 2026-05-26 13:51:00 +00:00
fix irc patron report
This commit is contained in:
@@ -209,11 +209,14 @@ final class IrcApi(
|
||||
buffer.head.date
|
||||
.isBefore(nowInstant.minusHours(24))
|
||||
.so:
|
||||
val firsts = scalalib.HeapSort.topN(buffer, 10).map(_.username).map(userAt).mkString(", ")
|
||||
val firsts = scalalib.HeapSort
|
||||
.topN(buffer.filter(_.username.value.nonEmpty), 10)
|
||||
.map("@" + _.username)
|
||||
.mkString(", ")
|
||||
val amountSum = buffer.map(_.cents).sum
|
||||
val patrons =
|
||||
if firsts.lengthIs > 10
|
||||
then s"$firsts and, like, ${firsts.length - 10} others,"
|
||||
if buffer.lengthIs > 10
|
||||
then s"$firsts and, like, ${buffer.length - 10} others,"
|
||||
else firsts
|
||||
displayMessage:
|
||||
s"$patrons donated ${amount(amountSum)}. Monthly progress: ${buffer.last.percent}%"
|
||||
@@ -223,10 +226,6 @@ final class IrcApi(
|
||||
private def displayMessage(text: String) =
|
||||
zulip(_.general, "lila")(markdown.linkifyUsers(text))
|
||||
|
||||
private def userAt(name: UserName) =
|
||||
if name == UserName("Anonymous") then name
|
||||
else s"@$name"
|
||||
|
||||
private def amount(cents: Int) = s"$$${BigDecimal(cents.toLong, 2)}"
|
||||
|
||||
object IrcApi:
|
||||
|
||||
Reference in New Issue
Block a user