|
|
@@ -83,30 +83,20 @@ class WebDbConnection {
|
|
|
echo "</br></br> League </br>";
|
|
|
var_dump($league);
|
|
|
|
|
|
- die();
|
|
|
-/*
|
|
|
+ $lookback = $league['lookback'];
|
|
|
+ $betMargin = $league['betMargin'];
|
|
|
|
|
|
- final int lookBack;
|
|
|
- if (leagueInfo.getLookback() != 0) {
|
|
|
- lookBack = leagueInfo.getLookback();
|
|
|
- } else {
|
|
|
- lookBack = 10;
|
|
|
- }
|
|
|
+ $homeTeamResults = $this->getTeamResults($match['homeTeam'], $lookback, true);
|
|
|
+ $awayTeamResults = $this->getTeamResults($match['awayTeam'], $lookback, false);
|
|
|
|
|
|
- final float betMargin;
|
|
|
- if (leagueInfo.getBetMargin() != 0) {
|
|
|
- betMargin = 1 + (leagueInfo.getBetMargin() / (float)100);
|
|
|
- } else {
|
|
|
- betMargin = 1.1f; // Default value???
|
|
|
- }
|
|
|
+ echo "</br></br> HomeTeam </br>";
|
|
|
+ var_dump($homeTeamResults);
|
|
|
|
|
|
- final TeamResults homeTeamResults = GuiMysql.getInstance().getTeamResults(soccerMatch.getHomeTeam().getTeamId(), lookBack, true);
|
|
|
- final TeamResults awayTeamResults = GuiMysql.getInstance().getTeamResults(soccerMatch.getAwayTeam().getTeamId(), lookBack, false);
|
|
|
+ echo "</br></br> AwayTeam </br>";
|
|
|
+ var_dump($awayTeamResults);
|
|
|
|
|
|
- if (soccerMatch.getHomeTeam().getCountryName().equals("finland")) {
|
|
|
- System.out.println("HomeTeam " + soccerMatch.getHomeTeam().getTeamName() + " " + homeTeamResults);
|
|
|
- System.out.println("AwayTeam " + soccerMatch.getAwayTeam().getTeamName() + " " + homeTeamResults);
|
|
|
- }
|
|
|
+ die();
|
|
|
+/*
|
|
|
|
|
|
final float homeWinPercent = (homeTeamResults.getWins() + awayTeamResults.getLosses()) / Float.valueOf(homeTeamResults.getCount() + awayTeamResults.getCount())* 100;
|
|
|
final float drawPercent = (homeTeamResults.getDraws() + awayTeamResults.getDraws()) / Float.valueOf(homeTeamResults.getCount() + awayTeamResults.getCount()) * 100;
|
|
|
@@ -132,4 +122,23 @@ class WebDbConnection {
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
+
|
|
|
+ public function getTeamResults($teamId, $numResults, $isHomeTeam) {
|
|
|
+ $sql = "";
|
|
|
+ if ($isHomeTeam) {
|
|
|
+ $sql = "SELECT count(case when homeScore > awayScore then 1 end) wins, " +
|
|
|
+ "count(case when awayScore > homeScore then 1 end) lost, " +
|
|
|
+ "count(case when homeScore = awayScore then 1 end) draws " +
|
|
|
+ "FROM (SELECT * FROM SoccerResults WHERE homeTeam = " . $teamId . " AND " +
|
|
|
+ "HomeScore >= 0 AND awayScore >= 0 ORDER BY gameDate DESC LIMIT " . $numResults . ") as t";
|
|
|
+ } else {
|
|
|
+ $sql = "SELECT count(case when homeScore < awayScore then 1 end) wins, " +
|
|
|
+ "count(case when awayScore < homeScore then 1 end) lost, " +
|
|
|
+ "count(case when homeScore = awayScore then 1 end) draws " +
|
|
|
+ "FROM (SELECT * FROM SoccerResults WHERE awayTeam = " . $teamId . " AND " +
|
|
|
+ "HomeScore >= 0 AND awayScore >= 0 ORDER BY gameDate DESC LIMIT " . $numResults . ") as t";
|
|
|
+ }
|
|
|
+
|
|
|
+ return $mysql->getSqlAsArray($sql);
|
|
|
+ }
|
|
|
}
|