|
@@ -33,10 +33,10 @@ class WebDbConnection {
|
|
|
$mysql = $this->dbCon->getConnection();
|
|
$mysql = $this->dbCon->getConnection();
|
|
|
$sql = "SELECT id, name FROM Country WHERE id IN (SELECT countryId FROM SoccerResults WHERE DATE(gameDate) >= DATE(NOW())) GROUP BY name ORDER BY prio DESC, name ASC";
|
|
$sql = "SELECT id, name FROM Country WHERE id IN (SELECT countryId FROM SoccerResults WHERE DATE(gameDate) >= DATE(NOW())) GROUP BY name ORDER BY prio DESC, name ASC";
|
|
|
|
|
|
|
|
- $result = $mysql->query( $sql );
|
|
|
|
|
- if ($result === false) {
|
|
|
|
|
- echo $result->error;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// $result = $mysql->query( $sql );
|
|
|
|
|
+// if ($result === false) {
|
|
|
|
|
+// echo $result->error;
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
return $this->getSqlAsArray($sql);
|
|
return $this->getSqlAsArray($sql);
|
|
|
}
|
|
}
|
|
@@ -45,11 +45,114 @@ class WebDbConnection {
|
|
|
$mysql = $this->dbCon->getConnection();
|
|
$mysql = $this->dbCon->getConnection();
|
|
|
$sql = "SELECT id, name, countryId FROM League WHERE id IN (SELECT leagueId FROM SoccerResults WHERE DATE(gameDate) >= DATE(NOW())) GROUP BY name ORDER BY prio DESC, name ASC";
|
|
$sql = "SELECT id, name, countryId FROM League WHERE id IN (SELECT leagueId FROM SoccerResults WHERE DATE(gameDate) >= DATE(NOW())) GROUP BY name ORDER BY prio DESC, name ASC";
|
|
|
|
|
|
|
|
- $result = $mysql->query( $sql );
|
|
|
|
|
- if ($result === false) {
|
|
|
|
|
- echo $result->error;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// $result = $mysql->query( $sql );
|
|
|
|
|
+// if ($result === false) {
|
|
|
|
|
+// echo $result->error;
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
return $this->getSqlAsArray($sql);
|
|
return $this->getSqlAsArray($sql);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public function getMatches($countryId, $leagueId ) {
|
|
|
|
|
+ $mysql = $this->dbCon->getConnection();
|
|
|
|
|
+
|
|
|
|
|
+ $sql = "SELECT res.*, " .
|
|
|
|
|
+ "hTeam.name as homeTeamName, aTeam.name as awayTeamName " .
|
|
|
|
|
+ "FROM SoccerResults as res " .
|
|
|
|
|
+ "Join Team as hTeam ON res.homeTeam = hTeam.id " .
|
|
|
|
|
+ "Join Team as aTeam ON res.awayTeam = aTeam.id " .
|
|
|
|
|
+ "WHERE " .
|
|
|
|
|
+ "DATE(gameDate) >= DATE(NOW()) " .
|
|
|
|
|
+ "AND res.leagueId = " . $leagueId .
|
|
|
|
|
+ "AND res.countryId = " . $coutryId .
|
|
|
|
|
+ "ORDER BY prio DESC, gameDate ASC";
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ $result = $this->getSqlAsArray($sql);
|
|
|
|
|
+
|
|
|
|
|
+ return $this->prepareMatches($result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function prepareMatches($matches) {
|
|
|
|
|
+ foreach ($matches as $match) {
|
|
|
|
|
+
|
|
|
|
|
+ var_dump($match);
|
|
|
|
|
+ die();
|
|
|
|
|
+ }
|
|
|
|
|
+ /*
|
|
|
|
|
+ for (final SoccerMatch soccerMatch : upcomingMatches) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ final Map<String, Object> match = new HashMap<>();
|
|
|
|
|
+ match.put("homeTeam", soccerMatch.getHomeTeam().getTeamName());
|
|
|
|
|
+ match.put("awayTeam", soccerMatch.getAwayTeam().getTeamName());
|
|
|
|
|
+ match.put("odds1", soccerMatch.getOdds1());
|
|
|
|
|
+ match.put("oddsX", soccerMatch.getOddsX());
|
|
|
|
|
+ match.put("odds2", soccerMatch.getOdds2());
|
|
|
|
|
+
|
|
|
|
|
+ final ArrayList<Float> avgHomeTeamGoals = calculateAvgHomeScore(soccerMatch.getHomeTeam().getTeamId());
|
|
|
|
|
+ final ArrayList<Float> avgAwayTeamGoals = calculateAvgAwayScore(soccerMatch.getAwayTeam().getTeamId());
|
|
|
|
|
+
|
|
|
|
|
+ match.put("gameDate", soccerMatch.getGameDate().toString());
|
|
|
|
|
+ match.put("avgScoreHome", avgHomeTeamGoals.get(0));
|
|
|
|
|
+ match.put("avgConcededHome", avgHomeTeamGoals.get(1));
|
|
|
|
|
+ match.put("avgScoreAway", avgAwayTeamGoals.get(0));
|
|
|
|
|
+ match.put("avgConcededAway", avgAwayTeamGoals.get(1));
|
|
|
|
|
+ match.put("goalsHome",
|
|
|
|
|
+ GuiMysql.getInstance().round(new BigDecimal(avgHomeTeamGoals.get(0) + avgAwayTeamGoals.get(1)),
|
|
|
|
|
+ GuiMysql.getInstance().getIncrement(), RoundingMode.HALF_UP));
|
|
|
|
|
+ match.put("goalsAway",
|
|
|
|
|
+ GuiMysql.getInstance().round(new BigDecimal(avgAwayTeamGoals.get(0) + avgHomeTeamGoals.get(1)),
|
|
|
|
|
+ GuiMysql.getInstance().getIncrement(), RoundingMode.HALF_UP));
|
|
|
|
|
+ match.put("goalDiff",
|
|
|
|
|
+ GuiMysql.getInstance()
|
|
|
|
|
+ .round(new BigDecimal((avgHomeTeamGoals.get(0) + avgAwayTeamGoals.get(1))
|
|
|
|
|
+ - (avgAwayTeamGoals.get(0) + avgHomeTeamGoals.get(1))),
|
|
|
|
|
+ GuiMysql.getInstance().getIncrement(), RoundingMode.HALF_UP));
|
|
|
|
|
+ match.put("country", soccerMatch.getHomeTeam().getCountryName());
|
|
|
|
|
+ match.put("league", soccerMatch.getHomeTeam().getTeamLeague());
|
|
|
|
|
+
|
|
|
|
|
+ final DecimalFormat df = new DecimalFormat("#.##");
|
|
|
|
|
+ df.setRoundingMode(RoundingMode.CEILING);
|
|
|
|
|
+
|
|
|
|
|
+ final League leagueInfo = GuiMysql.getInstance().getLeagueInfo(soccerMatch.getHomeTeam().getTeamLeague());
|
|
|
|
|
+
|
|
|
|
|
+ final int lookBack;
|
|
|
|
|
+ if (leagueInfo.getLookback() != 0) {
|
|
|
|
|
+ lookBack = leagueInfo.getLookback();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ lookBack = 10;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ final float betMargin;
|
|
|
|
|
+ if (leagueInfo.getBetMargin() != 0) {
|
|
|
|
|
+ betMargin = 1 + (leagueInfo.getBetMargin() / (float)100);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ betMargin = 1.1f; // Default value???
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ final TeamResults homeTeamResults = GuiMysql.getInstance().getTeamResults(soccerMatch.getHomeTeam().getTeamId(), lookBack, true);
|
|
|
|
|
+ final TeamResults awayTeamResults = GuiMysql.getInstance().getTeamResults(soccerMatch.getAwayTeam().getTeamId(), lookBack, false);
|
|
|
|
|
+
|
|
|
|
|
+ if (soccerMatch.getHomeTeam().getCountryName().equals("finland")) {
|
|
|
|
|
+ System.out.println("HomeTeam " + soccerMatch.getHomeTeam().getTeamName() + " " + homeTeamResults);
|
|
|
|
|
+ System.out.println("AwayTeam " + soccerMatch.getAwayTeam().getTeamName() + " " + homeTeamResults);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ 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;
|
|
|
|
|
+ final float awayWinPercent = (homeTeamResults.getLosses() + awayTeamResults.getWins()) / Float.valueOf(homeTeamResults.getCount() + awayTeamResults.getCount()) * 100;
|
|
|
|
|
+
|
|
|
|
|
+ match.put("homeWin", String.format("%.02f", homeWinPercent) + "(" + String.format("%.02f", (100 / homeWinPercent) * betMargin) + ")");
|
|
|
|
|
+ match.put("draw", String.format("%.02f", drawPercent) + "(" + String.format("%.02f", (100 / drawPercent ) * betMargin) + ")");
|
|
|
|
|
+ match.put("awayWin", String.format("%.02f", awayWinPercent) + "(" + String.format("%.02f", (100 / awayWinPercent) * betMargin) + ")");
|
|
|
|
|
+
|
|
|
|
|
+ matches.add(match);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ originalMatches = matches;
|
|
|
|
|
+ matchTable.getItems().addAll(matches);
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|