Fix score position and percentage
This commit is contained in:
parent
d9d9959be9
commit
ed765541e9
2 changed files with 2 additions and 2 deletions
|
@ -8,7 +8,7 @@ class GameRepository extends EntityRepository
|
||||||
{
|
{
|
||||||
public function getPositionForGame(Game $game) {
|
public function getPositionForGame(Game $game) {
|
||||||
$query = $this->_em->createQuery(
|
$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([
|
->setParameters([
|
||||||
'score' => $game->getScore(),
|
'score' => $game->getScore(),
|
||||||
|
|
|
@ -125,6 +125,6 @@ class Position {
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function getPercentage() {
|
public function getPercentage() {
|
||||||
return ($this->position / $this->total) * 100;
|
return ( ($this->total-$this->position+1) / $this->total) * 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue