//TODO: not sure how much this impacts interest... revisit this private InterestLevel CalculatePossessionInterest(MatchStatsEntity match) { var interest = InterestLevel.VeryBoring; if (match.HomePossesion > 80 || match.AwayPossesion > 80) { interest = InterestLevel.Exciting; } return(interest); }
public void GivenHighScoringGameTheCorrectInterestLevelIsReturned() { var matchStats = new MatchStatsEntity { HomeScore = 15, AwayScore = 15 }; var interest = _interestCalculator.CalculateMatchInterest(matchStats); Assert.AreEqual(interest, InterestLevel.Exciting); }
public MatchStatsEntity Execute(MatchEntity matchToCheck) { MatchStatsEntity matchStats = null; try { _logger.LogMessage(string.Format("{0} execution started - {1}", this.GetType().Name, DateTime.Now)); _logger.LogMessage(string.Format("Calling API to get match stats for [{0}] vs [{1}] - {2}", matchToCheck.HomeTeam, matchToCheck.AwayTeam, DateTime.Now)); var stats = _api.GetMatchCommentary(matchToCheck.CompetitionId, matchToCheck.MatchId); if (stats != null && stats.match_stats != null && stats.match_stats.localteam != null && stats.match_stats.localteam.Any() && stats.match_stats.visitorteam != null && stats.match_stats.visitorteam.Any()) { //TODO: implement a better mapper matchStats = new MatchStatsEntity { AwayCorners = stats.match_stats.visitorteam[0].corners, AwayPossesion = StringHelpers.ParsePossessionTime(stats.match_stats.visitorteam[0].possesiontime), AwayRedCards = stats.match_stats.visitorteam[0].redcards, AwaySaves = stats.match_stats.visitorteam[0].saves, AwayScore = StringHelpers.ParseAwayScore(matchToCheck.Score), AwayShots = stats.match_stats.visitorteam[0].shots_total, AwayShotsOnGoal = stats.match_stats.visitorteam[0].shots_onGoal, AwayYellowCards = stats.match_stats.visitorteam[0].yellowcards, HomeCorners = stats.match_stats.localteam[0].corners, HomePossesion = StringHelpers.ParsePossessionTime(stats.match_stats.localteam[0].possesiontime), HomeRedCards = stats.match_stats.localteam[0].redcards, HomeSaves = stats.match_stats.localteam[0].saves, HomeScore = StringHelpers.ParseHomeScore(matchToCheck.Score), HomeShots = stats.match_stats.localteam[0].shots_total, HomeShotsOnGoal = stats.match_stats.localteam[0].shots_onGoal, HomeYellowCards = stats.match_stats.localteam[0].yellowcards, }; } _logger.LogMessage(string.Format("{0} finished successfully - {1}", this.GetType().Name, DateTime.Now)); } catch (Exception ex) { _logger.LogMessage(string.Format("{0} error occurred - {1}", this.GetType().Name, ex.Message), true); } return(matchStats); }
private InterestLevel CalculateRedCardInterest(MatchStatsEntity match) { var interest = InterestLevel.VeryBoring; if (match.HomeRedCards + match.AwayRedCards > 2) { interest = InterestLevel.Exciting; } else if (match.HomeRedCards + match.AwayRedCards > 1) { interest = InterestLevel.Interesting; } return(interest); }
public InterestLevel CalculateMatchInterest(MatchStatsEntity match) { //TODO: there's got to be a way to the comparison and assignment if higher value simpler var interest = InterestLevel.Unknown; //total score var totalScoreInterest = CalculateTotalScoreInterest(match); if (totalScoreInterest > interest) { interest = totalScoreInterest; } //red cards var redCardInterest = CalculateRedCardInterest(match); if (redCardInterest > interest) { interest = redCardInterest; } //shots on goal var shotsOnGoalInterest = CalculateShotsOnGoalInterest(match); if (shotsOnGoalInterest > interest) { interest = shotsOnGoalInterest; } //shots var shotsInterest = CalculateShotsInterest(match); if (shotsInterest > interest) { interest = shotsInterest; } //possession var possessionInterest = CalculatePossessionInterest(match); if (possessionInterest > interest) { interest = possessionInterest; } return(interest); }
private InterestLevel CalculateShotsOnGoalInterest(MatchStatsEntity match) { var interest = InterestLevel.VeryBoring; if (match.HomeShotsOnGoal > 10 || match.AwayShotsOnGoal > 10) { interest = InterestLevel.Exciting; } else if (match.HomeShotsOnGoal > 6 || match.AwayShotsOnGoal > 6) { interest = InterestLevel.Interesting; } else if (match.HomeShotsOnGoal > 2 || match.AwayShotsOnGoal > 2) { interest = InterestLevel.Boring; } return(interest); }
private InterestLevel CalculateTotalScoreInterest(MatchStatsEntity match) { var interest = InterestLevel.VeryBoring; if (match.HomeScore + match.AwayScore >= 7) { interest = InterestLevel.Exciting; } else if (match.HomeScore + match.AwayScore >= 3) { interest = InterestLevel.Interesting; } else if (match.HomeScore + match.AwayScore >= 1) { interest = InterestLevel.Boring; } return(interest); }
private InterestLevel CalculateShotsInterest(MatchStatsEntity match) { var interest = InterestLevel.VeryBoring; if (match.HomeShots > 20 || match.AwayShots > 20) { interest = InterestLevel.Exciting; } else if (match.HomeShots > 16 || match.AwayShots > 16) { interest = InterestLevel.Interesting; } else if (match.HomeShots > 4 || match.AwayShots > 4) { interest = InterestLevel.Boring; } return(interest); }
public InterestLevel Execute(MatchStatsEntity match) { var interest = InterestLevel.Unknown; try { _logger.LogMessage(string.Format("{0} execution started - {1}", this.GetType().Name, DateTime.Now)); interest = _interestCalculator.CalculateMatchInterest(match); _logger.LogMessage(string.Format("Match interest level rated at - *[{0}]*", interest)); _logger.LogMessage(string.Format("{0} finished successfully - {1}", this.GetType().Name, DateTime.Now)); } catch (Exception ex) { _logger.LogMessage(string.Format("{0} error occurred - {1}", this.GetType().Name, ex.Message), true); } return(interest); }