@@ -41,17 +41,16 @@ private object SwissSheet:
41
41
players : List [SwissPlayer ],
42
42
pairingMap : SwissPairing .PairingMap
43
43
): List [SwissSheet ] =
44
- players.map { player =>
44
+ players.map: player =>
45
45
one(swiss, ~ pairingMap.get(player.userId), player)
46
- }
47
46
48
47
def one (
49
48
swiss : Swiss ,
50
49
pairingMap : Map [SwissRoundNumber , SwissPairing ],
51
50
player : SwissPlayer
52
51
): SwissSheet =
53
- SwissSheet {
54
- swiss.allRounds.map { round =>
52
+ SwissSheet :
53
+ swiss.allRounds.map: round =>
55
54
pairingMap get round match
56
55
case Some (pairing) =>
57
56
pairing.status match
@@ -63,8 +62,6 @@ private object SwissSheet:
63
62
case None if player.byes(round) => Bye
64
63
case None if round.value == 1 => Late
65
64
case None => Absent
66
- }
67
- }
68
65
69
66
final private class SwissSheetApi (mongo : SwissMongo )(using
70
67
Executor ,
@@ -76,24 +73,22 @@ final private class SwissSheetApi(mongo: SwissMongo)(using
76
73
sort : Bdoc
77
74
): Source [(SwissPlayer , Map [SwissRoundNumber , SwissPairing ], SwissSheet ), ? ] =
78
75
val readPreference =
79
- if ( swiss.finishedAt.exists(_ isBefore nowInstant.minusSeconds(10 ) ))
80
- temporarilyPrimary
76
+ if swiss.finishedAt.exists(_ isBefore nowInstant.minusSeconds(10 ))
77
+ then temporarilyPrimary
81
78
else ReadPreference .primary
82
79
SwissPlayer
83
- .fields { f =>
80
+ .fields: f =>
84
81
mongo.player.find($doc(f.swissId -> swiss.id)).sort(sort)
85
- }
86
82
.cursor[SwissPlayer ](readPreference)
87
83
.documentSource()
88
- .mapAsync(4 ) { player =>
89
- SwissPairing .fields { f =>
90
- mongo.pairing.list[ SwissPairing ](
91
- $doc(f.swissId -> swiss.id, f.players -> player.userId),
92
- readPreference
93
- ) dmap { player -> _ }
94
- }
95
- }
96
- .map { (player, pairings) =>
84
+ .mapAsync(4 ): player =>
85
+ SwissPairing .fields: f =>
86
+ mongo.pairing
87
+ .list[ SwissPairing ](
88
+ $doc(f.swissId -> swiss.id, f.players -> player.userId),
89
+ readPreference
90
+ )
91
+ .dmap(player -> _)
92
+ .map: (player, pairings) =>
97
93
val pairingMap = pairings.mapBy(_.round)
98
94
(player, pairingMap, SwissSheet .one(swiss, pairingMap, player))
99
- }
0 commit comments