Exemple #1
0
        protected TeamModel CreateTeamViewModel(
            IScoreboardRow row,
            Tenant.Entities.Affiliation?aff,
            Tenant.Entities.Category?cat,
            bool ispublic,
            ProblemStatisticsModel[]?stat = null)
        {
            var prob = new ScoreCellModel[Problems.Count];

            foreach (var pp in row.ScoreCache)
            {
                var p = Problems.Find(pp.ProblemId);
                if (p == null)
                {
                    continue;
                }
                var pid = p.Rank - 1;
                prob[pid] = RankingStrategy.ToCell(pp, ispublic);

                if (stat == null)
                {
                    continue;
                }
                if (prob[pid].Score.HasValue)
                {
                    var score = prob[pid].Score !.Value;
                    if (prob[pid].IsFirstToSolve)
                    {
                        stat[pid].FirstSolve ??= score;
                    }
                    stat[pid].Accepted++;
                    stat[pid].Rejected += prob[pid].JudgedCount - 1;
                    stat[pid].Pending  += prob[pid].PendingCount;
                    stat[pid].MaxScore  = System.Math.Max(stat[pid].MaxScore, score);
                }
                else
                {
                    stat[pid].Rejected += prob[pid].JudgedCount;
                    stat[pid].Pending  += prob[pid].PendingCount;
                }
            }

            var(points, penalty, lastac) = RankingStrategy.GetRanks(row.RankCache, ispublic);
            return(new TeamModel
            {
                TeamId = row.TeamId,
                TeamName = row.TeamName,
                Affiliation = aff?.Name ?? "",
                AffiliationId = aff?.Abbreviation ?? "null",
                Category = cat?.Name ?? "",
                CategoryColor = cat?.Color ?? "#ffffff",
                Eligible = cat?.IsEligible ?? false,
                Points = points,
                Penalty = penalty,
                LastAc = lastac,
                Problems = prob,
            });
        }
Exemple #2
0
 public TinyBoard(
     ScoreboardModel scb,
     int teamid,
     Category category,
     Affiliation affiliation)
     : base(scb)
 {
     _row         = scb.Data[teamid];
     _category    = category;
     _affiliation = affiliation;
 }