diff --git a/src/FourthDown.Api/FourthDown.Api.csproj b/src/FourthDown.Api/FourthDown.Api.csproj index 2589983..7f6a16a 100644 --- a/src/FourthDown.Api/FourthDown.Api.csproj +++ b/src/FourthDown.Api/FourthDown.Api.csproj @@ -9,6 +9,7 @@ + diff --git a/src/FourthDown.Shared/FourthDown.Shared.csproj b/src/FourthDown.Shared/FourthDown.Shared.csproj index c2ab040..21908a5 100644 --- a/src/FourthDown.Shared/FourthDown.Shared.csproj +++ b/src/FourthDown.Shared/FourthDown.Shared.csproj @@ -5,6 +5,7 @@ + diff --git a/src/FourthDown.Shared/Models/GameDetail.cs b/src/FourthDown.Shared/Models/GameDetail.cs index 17f5233..e3f666c 100644 --- a/src/FourthDown.Shared/Models/GameDetail.cs +++ b/src/FourthDown.Shared/Models/GameDetail.cs @@ -1,5 +1,7 @@ +#nullable enable using System.Collections.Generic; using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace FourthDown.Shared.Models { @@ -8,59 +10,71 @@ internal class GameRaw public DataObject Data { get; set; } } + [UsedImplicitly] internal class DataObject { public Viewer Viewer { get; set; } } + [UsedImplicitly] internal class Viewer { public GameDetail GameDetail { get; set; } } + [UsedImplicitly] public class HomePointsOvertime { } + [UsedImplicitly] public class GameTeam { public IReadOnlyList Abbreviation { get; set; } public IReadOnlyList NickName { get; set; } } + [UsedImplicitly] public class Period { } + [UsedImplicitly] public class ScoringSummary { public int PlayId { get; set; } - public string PlayDescription { get; set; } + public string? PlayDescription { get; set; } public int PatPlayId { get; set; } public int HomeScore { get; set; } public int VisitorScore { get; set; } } + [UsedImplicitly] public class VisitorPointsOvertime { } + [UsedImplicitly] public class CurrentFahrenheit { } + [UsedImplicitly] public class Location { } + [UsedImplicitly] public class LongDescription { } + [UsedImplicitly] public class CurrentRealFeelFahrenheit { } + [UsedImplicitly] public class Weather { public CurrentFahrenheit CurrentFahrenheit { get; set; } @@ -70,6 +84,7 @@ public class Weather public CurrentRealFeelFahrenheit CurrentRealFeelFahrenheit { get; set; } } + [UsedImplicitly] public class YardLine { } @@ -77,14 +92,14 @@ public class YardLine public class Drive { public int QuarterStart { get; set; } - public string EndTransition { get; set; } - public string EndYardLine { get; set; } + public string? EndTransition { get; set; } + public string? EndYardLine { get; set; } public bool EndedWithScore { get; set; } public int FirstDowns { get; set; } - public string GameClockEnd { get; set; } - public string GameClockStart { get; set; } - public string HowEndedDescription { get; set; } - public string HowStartedDescription { get; set; } + public string? GameClockEnd { get; set; } + public string? GameClockStart { get; set; } + public string? HowEndedDescription { get; set; } + public string? HowStartedDescription { get; set; } public bool Inside20 { get; set; } public double OrderSequence { get; set; } public int PlayCount { get; set; } @@ -93,67 +108,69 @@ public class Drive public int PlaySeqEnded { get; set; } public int PlaySeqStarted { get; set; } public int QuarterEnd { get; set; } - public string StartTransition { get; set; } - public string StartYardLine { get; set; } - public string TimeOfPossession { get; set; } + public string? StartTransition { get; set; } + public string? StartYardLine { get; set; } + public string? TimeOfPossession { get; set; } public int Yards { get; set; } public int YardsPenalized { get; set; } - public string PossessionTeamAbbreviation { get; set; } - public string PossessionTeamNickName { get; set; } - public string PossessionTeamFranchiseCurrentLogoUrl { get; set; } + public string? PossessionTeamAbbreviation { get; set; } + public string? PossessionTeamNickName { get; set; } + public string? PossessionTeamFranchiseCurrentLogoUrl { get; set; } } + [UsedImplicitly] public class PlayStat { public int StatId { get; set; } public int Yards { get; set; } - public string PlayerName { get; set; } - public string TeamId { get; set; } - public string TeamAbbreviation { get; set; } - public string GsisPlayerId { get; set; } + public string? PlayerName { get; set; } + public string? TeamId { get; set; } + public string? TeamAbbreviation { get; set; } + public string? GsisPlayerId { get; set; } } + [UsedImplicitly] public class Play { - public string ClockTime { get; set; } + public string? ClockTime { get; set; } public int Down { get; set; } - public string EndClockTime { get; set; } - public string EndYardLine { get; set; } + public string? EndClockTime { get; set; } + public string? EndYardLine { get; set; } public bool FirstDown { get; set; } public bool GoalToGo { get; set; } public bool NextPlayIsGoalToGo { get; set; } - public string NextPlayType { get; set; } + public string? NextPlayType { get; set; } public double OrderSequence { get; set; } public bool PenaltyOnPlay { get; set; } - public int PlayClock { get; set; } + [JsonIgnore] public int PlayClock { get; set; } public bool PlayDeleted { get; set; } - public string PlayDescription { get; set; } - public string PlayDescriptionWithJerseyNumbers { get; set; } + public string? PlayDescription { get; set; } + public string? PlayDescriptionWithJerseyNumbers { get; set; } public int PlayId { get; set; } - public string PlayType { get; set; } + public string? PlayType { get; set; } public IList PlayStats { get; set; } - public string PrePlayByPlay { get; set; } + public string? PrePlayByPlay { get; set; } public int Quarter { get; set; } public bool ScoringPlay { get; set; } - public string ShortDescription { get; set; } + public string? ShortDescription { get; set; } public bool SpecialTeamsPlay { get; set; } - public string TimeOfDay { get; set; } - public string YardLine { get; set; } + public string? TimeOfDay { get; set; } + public string? YardLine { get; set; } public int Yards { get; set; } public int YardsToGo { get; set; } public int? DriveNetYards { get; set; } public int? DrivePlayCount { get; set; } public int? DriveSequenceNumber { get; set; } - public string DriveTimeOfPossession { get; set; } - public string PossessionTeamAbbreviation { get; set; } - public string PossessionTeamNickName { get; set; } - public string PossessionTeamFranchiseCurrentLogoUrl { get; set; } + public string? DriveTimeOfPossession { get; set; } + public string? PossessionTeamAbbreviation { get; set; } + public string? PossessionTeamNickName { get; set; } + public string? PossessionTeamFranchiseCurrentLogoUrl { get; set; } public bool? IsBigPlay { get; set; } - public string ScoringPlayType { get; set; } - public string ScoringTeamId { get; set; } - public string ScoringTeamAbbreviation { get; set; } - public string ScoringTeamNickName { get; set; } - public string StPlayType { get; set; } + public string? ScoringPlayType { get; set; } + public string? ScoringTeamId { get; set; } + public string? ScoringTeamAbbreviation { get; set; } + public string? ScoringTeamNickName { get; set; } + public string? StPlayType { get; set; } } public class GameDetail diff --git a/src/FourthDown.Shared/Repositories/Json/JsonGamePlayRepository.cs b/src/FourthDown.Shared/Repositories/Json/JsonGamePlayRepository.cs index adc4346..4707541 100644 --- a/src/FourthDown.Shared/Repositories/Json/JsonGamePlayRepository.cs +++ b/src/FourthDown.Shared/Repositories/Json/JsonGamePlayRepository.cs @@ -31,23 +31,22 @@ public async Task GetGamePlaysAsync(Game game, CancellationToken can { using var scope = _tracer.BuildTrace(nameof(GetGamePlaysAsync)); - scope.LogStart(nameof(GetGamePlaysAsync)); - - var url = GetGameUrl(game.GameId, game.Season); - - scope.LogEnd(nameof(GetGamePlaysAsync)); - if (_gamesCache.TryGetValue(game, out var gameDetail)) { _logger.LogInformation($"Game found in cache: {game.GameId}"); return gameDetail; } + scope.LogStart(nameof(GetGamePlaysAsync)); + + var url = GetGameUrl(game.GameId, game.Season); gameDetail = await GetGameJson(url, cancellationToken, scope); gameDetail.Game = game; _gamesCache[game] = gameDetail; + scope.LogEnd(nameof(GetGamePlaysAsync)); + return gameDetail; }