@@ -235,23 +235,16 @@ object User extends LilaController {
235
235
}
236
236
}
237
237
238
- def opponents (username : String ) = Open { implicit ctx =>
239
- OptionFuOk (UserRepo named username) { user =>
240
- lila.game.BestOpponents (user.id, 50 ) flatMap { ops =>
241
- ctx.isAuth.fold(
242
- Env .pref.api.followables(ops map (_._1.id)),
243
- fuccess(List .fill(50 )(true ))
244
- ) flatMap { followables =>
245
- (ops zip followables).map {
246
- case ((u, nb), followable) => ctx.userId ?? {
247
- relationApi.fetchRelation(_, u.id)
248
- } map { lila.relation.Related (u, nb.some, followable, _) }
249
- }.sequenceFu map { relateds =>
250
- html.user.opponents(user, relateds)
251
- }
252
- }
253
- }
254
- }
238
+ def opponents = Auth { implicit ctx => me =>
239
+ for {
240
+ ops <- Env .game.bestOpponents(me.id)
241
+ followables <- Env .pref.api.followables(ops map (_._1.id))
242
+ relateds <- ops.zip(followables).map {
243
+ case ((u, nb), followable) => relationApi.fetchRelation(me.id, u.id) map {
244
+ lila.relation.Related (u, nb.some, followable, _)
245
+ }
246
+ }.sequenceFu
247
+ } yield html.user.opponents(me, relateds)
255
248
}
256
249
257
250
def perfStat (username : String , perfKey : String ) = Open { implicit ctx =>
0 commit comments