remove mostly unused scalaz stuff

pull/6506/head
Thibault Duplessis 2020-04-29 08:30:36 -06:00
parent cf3257b80d
commit c8f26bdb4d
9 changed files with 16 additions and 28 deletions

View File

@ -263,7 +263,7 @@ final class Team(
forms.processRequest.bindFromRequest.fold(
_ => fuccess(routes.Team.show(team.id).toString), {
case (decision, url) =>
api.processRequest(team, request, (decision === "accept")) inject url
api.processRequest(team, request, (decision == "accept")) inject url
}
)
}

View File

@ -46,7 +46,9 @@ final private class ChallengeRepo(coll: Coll, maxPerUser: Max)(
coll.update.one($id(c.id), $set("challenger" -> c.challenger)).void
private[challenge] def allWithUserId(userId: String): Fu[List[Challenge]] =
createdByChallengerId(userId) |+| createdByDestId(userId)
createdByChallengerId(userId) zip createdByDestId(userId) dmap {
case (x, y) => x ::: y
}
@silent def like(c: Challenge) =
~(for {

View File

@ -19,19 +19,12 @@ trait Lilaisms
with scalalib.Validation
with scalalib.Zeros
with scalalib.Zero.Syntax
with scalaz.std.ListFunctions
with scalaz.std.ListInstances
with scalaz.std.OptionFunctions
with scalaz.std.OptionInstances
with scalaz.std.StringInstances
with scalaz.std.TupleInstances
with scalaz.syntax.std.ToListOps
with scalaz.syntax.std.ToOptionIdOps
with scalaz.syntax.ToApplyOps
with scalaz.syntax.ToEqualOps
// with scalaz.syntax.ToIdOps
with scalaz.syntax.ToMonoidOps
with scalaz.syntax.ToShowOps
with scalaz.syntax.ToTraverseOps
with scalaz.syntax.ToValidationOps {
@ -40,7 +33,6 @@ trait Lilaisms
@inline implicit def toPimpedFuture[A](f: Fu[A]) = new PimpedFuture(f)
@inline implicit def toPimpedFutureBoolean(f: Fu[Boolean]) = new PimpedFutureBoolean(f)
@inline implicit def toPimpedFutureOption[A](f: Fu[Option[A]]) = new PimpedFutureOption(f)
// @inline implicit def toPimpedFutureValid[A](f: Fu[Valid[A]]) = new PimpedFutureValid(f)
@inline implicit def toPimpedIterableFuture[A, M[X] <: IterableOnce[X]](t: M[Fu[A]]) =
new PimpedIterableFuture(t)

View File

@ -1,8 +1,5 @@
package lila
import scalaz.Monoid
import scala.concurrent.ExecutionContext
trait PackageObject extends Lilaisms {
def !![A](msg: String): Valid[A] = msg.failureNel[A]
@ -13,15 +10,6 @@ trait PackageObject extends Lilaisms {
def nowTenths: Long = nowMillis / 100
def nowSeconds: Int = (nowMillis / 1000).toInt
implicit def fuMonoid[A: Monoid](implicit ec: ExecutionContext): Monoid[Fu[A]] =
Monoid.instance(
(x, y) =>
x zip y map {
case (a, b) => a b
},
fuccess([A])
)
type ~[+A, +B] = Tuple2[A, B]
object ~ {
def apply[A, B](x: A, y: B) = Tuple2(x, y)

View File

@ -3,6 +3,7 @@ package lila.base
import java.util.Base64
import java.lang.{ StringBuilder => jStringBuilder }
import scala.util.Try
import scalaz.{ IList, NonEmptyList }
final class PimpedTryList[A](private val list: List[Try[A]]) extends AnyVal {
def sequence: Try[List[A]] = Try(list map { _.get })
@ -12,6 +13,10 @@ final class PimpedList[A](private val list: List[A]) extends AnyVal {
def sortLike[B](other: List[B], f: A => B): List[A] = list.sortWith { (x, y) =>
other.indexOf(f(x)) < other.indexOf(f(y))
}
def toNel: Option[NonEmptyList[A]] = list match {
case Nil => None
case first :: rest => Some(NonEmptyList.nel(first, IList fromList rest))
}
}
final class PimpedChars(private val iter: Iterable[CharSequence]) extends AnyVal {

View File

@ -13,7 +13,7 @@ private object Validator {
in.fen.some,
in.id.variant
)
.fold(err => Error(err.shows).some, _ => none)
.fold(err => Error(err.toString).some, _ => none)
case (error, _) => error
}
}

View File

@ -28,7 +28,7 @@ final class PublicChat(
val ids = visibleTournaments.all.map(_.id) map Chat.Id.apply
chatApi.userChat.findAll(ids).map { chats =>
chats.map { chat =>
visibleTournaments.all.find(_.id === chat.id.value).map(tour => (tour, chat))
visibleTournaments.all.find(_.id == chat.id.value).map(tour => (tour, chat))
}.flatten
} map sortTournamentsByRelevance
}
@ -38,7 +38,7 @@ final class PublicChat(
val ids = simuls.map(_.id) map Chat.Id.apply
chatApi.userChat.findAll(ids).map { chats =>
chats.map { chat =>
simuls.find(_.id === chat.id.value).map(simul => (simul, chat))
simuls.find(_.id == chat.id.value).map(simul => (simul, chat))
}.flatten
}
}

View File

@ -43,7 +43,7 @@ final class Env(
def cli = new lila.common.Cli {
def process = {
case "msg" :: "multi" :: orig :: dests :: words =>
api.cliMultiPost(orig, dests.split(','), words mkString " ")
api.cliMultiPost(orig, dests.split(',').toIndexedSeq, words mkString " ")
}
}

View File

@ -29,13 +29,14 @@ final class AutoAnalysis(
}
private def gamesToAnalyse(candidate: Report.Candidate): Fu[List[Game]] = {
gameRepo.recentAnalysableGamesByUserId(candidate.suspect.user.id, 10) |+|
gameRepo.recentAnalysableGamesByUserId(candidate.suspect.user.id, 10) flatMap { as =>
gameRepo.lastGamesBetween(
candidate.suspect.user,
candidate.reporter.user,
DateTime.now.minusHours(2),
10
)
) dmap { as ++ _ }
}
}.map {
_.filter { g =>
g.analysable && !g.metadata.analysed