<commit_before><?php

namespace Abienvenu\KyjoukanBundle\Service;

use Abienvenu\KyjoukanBundle\Entity\Game;
use Abienvenu\KyjoukanBundle\Entity\Pool;
use Abienvenu\KyjoukanBundle\Entity\Team;

class RankService
{
	public function getPoolRanks(Pool $pool)
	{
		$rankings = [];
		/** @var Team $team */
		foreach ($pool->getTeams() as $team)
		{
			$rankings[$team->getId()] = ["team" => $team->getName(), "win" => 0, "played" => 0, "loose" => 0, "advantage" => 0, "points" => 0];
		}

		/** @var Game $game */
		foreach ($pool->getGames() as $game)
		{
			if ($game->getScore1() && $game->getScore2())
			{
				if ($game->getScore1() >= $game->getScore2())
				{
					$rankings[$game->getTeam1()->getId()]["win"]++;
					$rankings[$game->getTeam2()->getId()]["loose"]++;
				}
				else
				{
					$rankings[$game->getTeam1()->getId()]["loose"]++;
					$rankings[$game->getTeam2()->getId()]["win"]++;
				}
				$rankings[$game->getTeam1()->getId()]["played"]++;
				$rankings[$game->getTeam2()->getId()]["played"]++;
				$rankings[$game->getTeam1()->getId()]["advantage"] += $game->getScore1() - $game->getScore2();
				$rankings[$game->getTeam2()->getId()]["advantage"] += $game->getScore2() - $game->getScore1();
				$rankings[$game->getTeam1()->getId()]["points"] += $game->getScore1();
				$rankings[$game->getTeam2()->getId()]["points"] += $game->getScore2();
			}
		}<commit_msg>fix : a match is played if one score is not 0<commit_after><?php

namespace Abienvenu\KyjoukanBundle\Service;

use Abienvenu\KyjoukanBundle\Entity\Game;
use Abienvenu\KyjoukanBundle\Entity\Pool;
use Abienvenu\KyjoukanBundle\Entity\Team;

class RankService
{
	public function getPoolRanks(Pool $pool)
	{
		$rankings = [];
		/** @var Team $team */
		foreach ($pool->getTeams() as $team)
		{
			$rankings[$team->getId()] = ["team" => $team->getName(), "win" => 0, "played" => 0, "loose" => 0, "advantage" => 0, "points" => 0];
		}

		/** @var Game $game */
		foreach ($pool->getGames() as $game)
		{
			if ($game->getScore1() || $game->getScore2())
			{
				if ($game->getScore1() >= $game->getScore2())
				{
					$rankings[$game->getTeam1()->getId()]["win"]++;
					$rankings[$game->getTeam2()->getId()]["loose"]++;
				}
				else
				{
					$rankings[$game->getTeam1()->getId()]["loose"]++;
					$rankings[$game->getTeam2()->getId()]["win"]++;
				}
				$rankings[$game->getTeam1()->getId()]["played"]++;
				$rankings[$game->getTeam2()->getId()]["played"]++;
				$rankings[$game->getTeam1()->getId()]["advantage"] += $game->getScore1() - $game->getScore2();
				$rankings[$game->getTeam2()->getId()]["advantage"] += $game->getScore2() - $game->getScore1();
				$rankings[$game->getTeam1()->getId()]["points"] += $game->getScore1();
				$rankings[$game->getTeam2()->getId()]["points"] += $game->getScore2();
			}
		}
{'fraction_non_alphanumeric': 0.2617857142857143, 'fraction_numerical': 0.018214285714285714, 'mean_word_length': 4.4073359073359075, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 85, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '775779', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1060, 'n_words': 142}