MatchMakingLobby/Services/MatchMakingService.php
function getAverageTimeBetweenMatches($lobbyLogin, $scriptName, $titleIdString)
	{
		$creationTimestamps = $this->db->execute(
			'SELECT UNIX_TIMESTAMP(creationDate) '.
			'FROM Matches m '.
			'WHERE m.lobbyLogin = %s '.
			'AND m.scriptName = %s '.
			'AND m.titleIdString = %s '.
			'AND m.state NOT IN (%s) AND m.creationDate > DATE_SUB(NOW(), INTERVAL 1 HOUR) '.
			'ORDER BY creationDate ASC LIMIT 10', $this->db->quote($lobbyLogin),
			$this->db->quote($scriptName), $this->db->quote($titleIdString), implode(',',array(Match::PLAYER_CANCEL))
		)->fetchArrayOfSingleValues();

		if(count($creationTimestamps) < 2)
		{
			return -1;
		}

		$sum = 0;
		for($i = 1; $i < count($creationTimestamps); $i++)
		{
			$sum += $creationTimestamps[$i] - $creationTimestamps[$i - 1];
		}
		return $sum / (count($creationTimestamps) - 1);
	}
function getAverageTimeBetweenMatches($lobbyLogin, $scriptName, $titleIdString)
	{
		$creationTimestamps = $this->db->execute(
			'SELECT UNIX_TIMESTAMP(creationDate) '.
			'FROM Matches m '.
			'WHERE m.lobbyLogin = %s '.
			'AND m.scriptName = %s '.
			'AND m.titleIdString = %s '.
			'AND m.state NOT IN (%s) AND m.creationDate > DATE_SUB(NOW(), INTERVAL 1 HOUR) '.
			'ORDER BY creationDate ASC LIMIT 10', $this->db->quote($lobbyLogin),
			$this->db->quote($scriptName), $this->db->quote($titleIdString), implode(',',array(Match::PLAYER_CANCEL))
		)->fetchArrayOfSingleValues();

		if(count($creationTimestamps) < 2)
		{
			return -1;
		}

		$sum = 0;
		for($i = 1; $i < count($creationTimestamps); $i++)
		{
			$sum += $creationTimestamps[$i] - $creationTimestamps[$i - 1];
		}
		return $sum / (count($creationTimestamps) - 1);
	}
function getAverageTimeBetweenMatches ( $ lobbyLogin , $ scriptName , $ titleIdString ) { $ creationTimestamps = $ this -> db -> execute ( 'SELECT UNIX_TIMESTAMP(creationDate) ' . 'FROM Matches m ' . 'WHERE m.lobbyLogin = %s ' . 'AND m.scriptName = %s ' . 'AND m.titleIdString = %s ' . 'AND m.state NOT IN (%s) AND m.creationDate > DATE_SUB(NOW(), INTERVAL 1 HOUR) ' . 'ORDER BY creationDate ASC LIMIT 10' , $ this -> db -> quote ( $ lobbyLogin ) , $ this -> db -> quote ( $ scriptName ) , $ this -> db -> quote ( $ titleIdString ) , implode ( ',' , array ( Match :: PLAYER_CANCEL ) ) ) -> fetchArrayOfSingleValues ( ) ; if ( count ( $ creationTimestamps ) < 2 ) { return - 1 ; } $ sum = 0 ; for ( $ i = 1 ; $ i < count ( $ creationTimestamps ) ; $ i ++ ) { $ sum += $ creationTimestamps [ $ i ] - $ creationTimestamps [ $ i - 1 ] ; } return $ sum / ( count ( $ creationTimestamps ) - 1 ) ; }
Get average time between two match. This time is compute with matches over the last hour
If there is not anough matches in database, it returns -1
@param string $lobbyLogin
@param string $scriptName
@param string $titleIdString
@return float Number of seconds
Get average time between two match . This time is compute with matches over the last hour If there is not anough matches in database it returns - 1