Skip to content

Commit

Permalink
Fix the null reference warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
yang-er committed Apr 15, 2021
1 parent a167f26 commit cbcd55e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 28 deletions.
6 changes: 4 additions & 2 deletions src/Scoreboard/Models/FullBoardViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,15 @@ private IEnumerable<TeamModel> GetViewModel(
}
}

var aff = Affiliations.TryGetValue(item.AffiliationId, out var __aff) ? __aff : null;

yield return new TeamModel
{
ContestId = IsPublic ? default(int?) : ContestId,
TeamId = item.TeamId,
TeamName = item.TeamName,
Affiliation = Affiliations.GetValueOrDefault(item.AffiliationId)?.Name ?? "",
AffiliationId = Affiliations.GetValueOrDefault(item.AffiliationId)?.Abbreviation ?? "null",
Affiliation = aff?.Name ?? "",
AffiliationId = aff?.Abbreviation ?? "null",
Category = catName,
CategoryColor = cats[catid].Color,
Points = point,
Expand Down
23 changes: 0 additions & 23 deletions src/Scoreboard/NetstandardCompatibility.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Scoreboard/Query/CFRank.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public async Task RefreshCache(IScoreboard store, ScoreboardRefreshEvent args)
rcc.Add(s.TeamId,
new RankCache { ContestId = cid, TeamId = s.TeamId });
var rc = rcc[s.TeamId];
int score = scores.GetValueOrDefault(sc.ProblemId);
scores.TryGetValue(sc.ProblemId, out int score);

var time = sc.SolveTimePublic = (s.Time - args.StartTime).TotalSeconds;
var timee = (int)(time / 60);
Expand Down
7 changes: 5 additions & 2 deletions src/Scoreboard/Query/OIRank.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,21 @@ public async Task RefreshCache(IScoreboard store, ScoreboardRefreshEvent args)

foreach (var r in scc.GroupBy(t => t.Key.Item1, v => v.Value))
{
lastop1.TryGetValue(r.Key, out var ttp);
lastop2.TryGetValue(r.Key, out var ttr);

var item = new RankCache
{
ContestId = cid,
TeamId = r.Key,
TotalTimePublic = ttp,
TotalTimeRestricted = ttr,
};

foreach (var rr in r)
{
item.PointsPublic += rr.ScorePublic ?? 0;
item.PointsRestricted += rr.ScoreRestricted ?? 0;
item.TotalTimePublic = lastop1.GetValueOrDefault(r.Key);
item.TotalTimeRestricted = lastop2.GetValueOrDefault(r.Key);
}

rcc.Add(r.Key, item);
Expand Down

0 comments on commit cbcd55e

Please sign in to comment.