Fix score position and percentage

This commit is contained in:
Ruben 2016-09-05 12:04:46 +01:00
parent d9d9959be9
commit ed765541e9
2 changed files with 2 additions and 2 deletions

View file

@ -8,7 +8,7 @@ class GameRepository extends EntityRepository
{
public function getPositionForGame(Game $game) {
$query = $this->_em->createQuery(
"SELECT COUNT(g.id) FROM ". Game::class ." g WHERE g.score < :score AND g.level = :level"
"SELECT COUNT(g.id) FROM ". Game::class ." g WHERE g.score > :score AND g.level = :level"
)
->setParameters([
'score' => $game->getScore(),

View file

@ -125,6 +125,6 @@ class Position {
* @return float
*/
public function getPercentage() {
return ($this->position / $this->total) * 100;
return ( ($this->total-$this->position+1) / $this->total) * 100;
}
}