Skip to content

Commit

Permalink
refactor and rename
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Nov 28, 2015
1 parent eb657cd commit 93952cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
17 changes: 7 additions & 10 deletions modules/insight/src/main/AggregationPipeline.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ private final class AggregationPipeline {
"v" -> f,
"nb" -> SumValue(1)
).some
private val regroupStacked = GroupField("_id.dimension")(
"nb" -> SumField("v"),
"stack" -> PushMulti(
"metric" -> "_id.metric",
"v" -> "v")).some

def apply(question: Question[_], userId: String): NonEmptyList[PipelineOperator] = {
import question.{ dimension, metric }
Expand Down Expand Up @@ -60,23 +65,15 @@ private final class AggregationPipeline {
GroupMulti("dimension" -> dimension.dbKey, "metric" -> "result")(
"v" -> SumValue(1)
).some,
GroupField("_id.dimension")(
"nb" -> SumField("v"),
"stack" -> PushMulti(
"metric" -> "_id.metric",
"v" -> "v")).some
regroupStacked
)
case M.PieceRole => List(
unwindMoves,
moveMatcher,
GroupMulti("dimension" -> dimension.dbKey, "metric" -> "moves.r")(
"v" -> SumValue(1)
).some,
GroupField("_id.dimension")(
"nb" -> SumField("v"),
"stack" -> PushMulti(
"metric" -> "_id.metric",
"v" -> "v")).some
regroupStacked
)
}) ::: (dimension match {
case D.Opening => List(sortNb, limit(12))
Expand Down
2 changes: 1 addition & 1 deletion modules/insight/src/main/Metric.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object Metric {
import DataType._
import Position._

case object MeanCpl extends Metric("meanCpl", "Mean CPL", Move, Average)
case object MeanCpl extends Metric("meanCpl", "Average centipawn loss", Move, Average)

case object Movetime extends Metric("movetime", "Move time", Move, Seconds)

Expand Down

0 comments on commit 93952cf

Please sign in to comment.