UI, Mark/Report Conds. and DateTime entry

This commit is contained in:
clarkerubber 2015-02-03 01:28:33 +11:00
parent 1b1a5bf8bc
commit 7433a458db
6 changed files with 90 additions and 7 deletions

View file

@ -12,6 +12,7 @@ import lila.rating.PerfType
import lila.security.Permission
import lila.user.tube.userTube
import lila.user.{ User => UserModel, UserRepo }
import lila.evaluation.PlayerAggregateAssessment
import views._
object User extends LilaController {
@ -147,7 +148,7 @@ object User extends LilaController {
def mod(username: String) = Secure(_.UserSpy) { implicit ctx =>
me => OptionFuOk(UserRepo named username) { user =>
(Env.evaluation.evaluator find user) zip (Env.security userSpy user.id) zip (Env.mod.assessApi.getResultsByUserId(user.id, 25)) map {
case ((eval, spy), gameResults) => html.user.mod(user, spy, eval, gameResults)
case ((eval, spy), gameResults) => html.user.mod(user, spy, eval, PlayerAggregateAssessment(gameResults))
}
}
}

View file

@ -1,4 +1,4 @@
@(u: User, spy: lila.security.UserSpy, eval: Option[lila.evaluation.Evaluation], gameResults: List[lila.evaluation.GameGroupResult])(implicit ctx: Context)
@(u: User, spy: lila.security.UserSpy, eval: Option[lila.evaluation.Evaluation], aggregateAssessment: lila.evaluation.PlayerAggregateAssessment)(implicit ctx: Context)
@import lila.evaluation.Display
@ -77,8 +77,39 @@
}
</div>
}
@if(gameResults.nonEmpty) {
@if(aggregateAssessment.gameGroupResults.nonEmpty) {
<div class="evaluation results">
<table class="reportCard">
<thead>
<tr>
<th>
<span class="@(if(aggregateAssessment.markPri) "mark" else "noMark")">Cheating</span>
</th>
<th>
<span class="@(if(aggregateAssessment.markSec) "mark" else "noMark")">Cheating</span>
</th>
<th>
<span class="@(if(aggregateAssessment.report) "report" else "noReport")">Report</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<span class="sig_5">@aggregateAssessment.cheatingSum</span> / 2
</td>
<td>
<span class="sig_5">@aggregateAssessment.cheatingSum</span> +
<span class="sig_4">@aggregateAssessment.likelyCheatingSum</span> / 5
</td>
<td>
<span class="sig_5">@aggregateAssessment.cheatingSum</span> +
<span class="sig_4">@aggregateAssessment.likelyCheatingSum</span> +
<span class="sig_3">@aggregateAssessment.unclearSum</span> / 5
</td>
</tr>
</tbody>
</table>
<p class="legend">
@Range(1, 6).map { i =>
<span class="sig_@i">@Display.assessmentString(i)</span>
@ -107,7 +138,7 @@
</tr>
</thead>
<tbody>
@gameResults.map { result =>
@aggregateAssessment.gameGroupResults.map { result =>
<tr>
<td><a href="@routes.Round.watcher(result.gameId, result.color.name)">@routes.Round.watcher(result.gameId, result.color.name)</a></td>
<td>@result.sfAvg ± @result.sfSd</td>

View file

@ -38,6 +38,25 @@ case class PeerGame(
}) + " game at " + matchPercentage + "% confidence"
}
case class PlayerAggregateAssessment(
gameGroupResults: List[GameGroupResult]
) {
import Statistics.listSum
def sumAssessment(x: Int): Int =
listSum(gameGroupResults.map { result =>
if (result.aggregate.assessment == x && (result.aggregate.positiveMatch || result.aggregate.confidence > 80)) 1
else 0
})
val cheatingSum: Int = sumAssessment(5)
val likelyCheatingSum: Int = sumAssessment(4)
val unclearSum: Int = sumAssessment(3)
val markPri: Boolean = cheatingSum >= 2
val markSec: Boolean = cheatingSum + likelyCheatingSum >= 5
val report: Boolean = cheatingSum + likelyCheatingSum + unclearSum >= 5
}
case class AggregateAssessment(
assessment: Int,
confidence: Int,
@ -62,6 +81,7 @@ case class GameGroupResult(
white: Boolean, // The side of the game being talked about
bestMatch: PeerGame,
secondaryMatches: List[PeerGame],
date: DateTime,
// Meta infos
sfAvg: Int,
sfSd: Int,
@ -70,7 +90,7 @@ case class GameGroupResult(
blur: Int,
hold: Boolean
) {
import Statistics.listSum
import Statistics.{listSum, listAverage}
val color = Color(white)
val aggregate: AggregateAssessment = {
def maxConfidence(xs: List[PeerGame]): Int = xs match {
@ -87,7 +107,10 @@ case class GameGroupResult(
case a if (a.positiveMatch) => 2 * a.matchPercentage
case a => a.matchPercentage
})).toInt,
maxConfidence(peers),
listAverage(peers.map{ _ match {
case i if (i.positiveMatch) => List.fill(2)(i.matchPercentage)
case i => List(i.matchPercentage)
}}.flatten).toInt,
peers.exists(_.positiveMatch)
)
}

View file

@ -6,6 +6,7 @@ import lila.db.BSON.BSONJodaDateTimeHandler
import lila.evaluation.{ PlayerAssessment, GameGroupResult, GameResults, GameGroup, Analysed, PeerGame, MatchAndSig }
import lila.game.Game
import lila.game.{ Game, GameRepo }
import org.joda.time.DateTime
import reactivemongo.bson._
import scala.concurrent._
@ -86,6 +87,7 @@ final class AssessApi(collRef: Coll, collRes: Coll, logApi: ModlogApi) {
white = source.color.white,
bestMatch = a,
secondaryMatches = b,
date = DateTime.now,
sfAvg = source.sfAvg,
sfSd = source.sfSd,
mtAvg = source.mtAvg,

View file

@ -294,7 +294,7 @@ table.modAssessment td.match a {
color: #759900;
}
table.modAssessment td.partial a {
/*color: #d59120;*/
color: #d59120;
}
table.modAssessment td.noMatch {
color: #ac524f;

View file

@ -278,4 +278,30 @@ div.user_show .results table.slist th {
}
div.user_show .results table.slist td {
text-align: center;
}
div.user_show .reportCard {
margin: 0 auto 10px auto;
}
div.user_show .reportCard th {
text-align: center;
font-weight: bold;
font-size: 2em;
padding: 0 20px 5px 20px;
}
div.user_show .reportCard td {
text-align: center;
font-weight: bold;
font-size: 1.2em;
}
div.user_show .reportCard .mark {
color: #dc322f; /* red */
}
div.user_show .reportCard .noMark {
/*color: #dc322f;*/ /* red */
}
div.user_show .reportCard .report {
color: #B8AA1A; /* red */
}
div.user_show .reportCard .noReport {
/*color: #dc322f;*/ /* red */
}