insights moves per game
parent
7baa0d92bd
commit
5e30eaded8
|
@ -36,8 +36,8 @@ private final class AggregationPipeline {
|
|||
}).some.filterNot(_.isEmpty) map Match
|
||||
|
||||
// #TODO make it depend on move matchers and metric
|
||||
def projectForMove = Project(BSONDocument(
|
||||
"_id" -> false,
|
||||
def projectForMove(keepId: Boolean = false) = Project(BSONDocument(
|
||||
"_id" -> keepId,
|
||||
"moves" -> true
|
||||
) ++ dimension.dbKey.startsWith("moves.").fold(
|
||||
BSONDocument(),
|
||||
|
@ -52,21 +52,34 @@ private final class AggregationPipeline {
|
|||
),
|
||||
sampleGames :: ((metric match {
|
||||
case M.MeanCpl => List(
|
||||
projectForMove,
|
||||
projectForMove(),
|
||||
unwindMoves,
|
||||
matchMoves,
|
||||
sampleMoves,
|
||||
group(dimension, Avg("moves.c"))
|
||||
)
|
||||
case M.NbMoves => List(
|
||||
projectForMove,
|
||||
projectForMove(keepId = true),
|
||||
unwindMoves,
|
||||
matchMoves,
|
||||
sampleMoves,
|
||||
group(dimension, SumValue(1))
|
||||
GroupField(dimension.dbKey)(
|
||||
"v" -> SumValue(1),
|
||||
"games" -> AddToSet("_id")
|
||||
).some,
|
||||
Project(BSONDocument(
|
||||
"v" -> true,
|
||||
"nbGames" -> BSONDocument("$size" -> "$games")
|
||||
)).some,
|
||||
Project(BSONDocument(
|
||||
"v" -> BSONDocument(
|
||||
"$divide" -> BSONArray("$v", "$nbGames")
|
||||
),
|
||||
"nb" -> "$nbGames"
|
||||
)).some
|
||||
)
|
||||
case M.Movetime => List(
|
||||
projectForMove,
|
||||
projectForMove(),
|
||||
unwindMoves,
|
||||
matchMoves,
|
||||
sampleMoves,
|
||||
|
@ -93,7 +106,7 @@ private final class AggregationPipeline {
|
|||
regroupStacked
|
||||
)
|
||||
case M.PieceRole => List(
|
||||
projectForMove,
|
||||
projectForMove(),
|
||||
unwindMoves,
|
||||
matchMoves,
|
||||
sampleMoves,
|
||||
|
|
|
@ -36,7 +36,7 @@ object Metric {
|
|||
|
||||
case object OpponentRating extends Metric("opponentRating", "Opponent rating", Game, Average)
|
||||
|
||||
case object NbMoves extends Metric("nbMoves", "Number of moves", Move, Count)
|
||||
case object NbMoves extends Metric("nbMoves", "Moves per game", Game, Count)
|
||||
|
||||
case object PieceRole extends Metric("pieceRole", "Piece moved", Move, Percent)
|
||||
|
||||
|
|
|
@ -18,8 +18,7 @@ var colors = {
|
|||
green: '#759900',
|
||||
red: '#dc322f',
|
||||
orange: '#d59120',
|
||||
blue: '#007599',
|
||||
translucid: 'rgba(0,0,0,0.3)'
|
||||
blue: '#007599'
|
||||
};
|
||||
var resultColors = {
|
||||
Victory: colors.green,
|
||||
|
@ -37,7 +36,7 @@ function makeChart(el, data) {
|
|||
animation: {
|
||||
duration: 300
|
||||
},
|
||||
color: 'rgba(80,80,80,0.3)'
|
||||
color: 'rgba(80,80,80,0.2)'
|
||||
};
|
||||
var valueSeries = data.series.map(function(s) {
|
||||
var c = {
|
||||
|
|
Loading…
Reference in New Issue