Example #1
0
 Task <int> IRejudgingContext.RejudgeAsync(
     Expression <Func <Submission, Judging, bool> > predicate,
     Rejudging rejudging,
     bool fullTest)
 {
     return(Polygon.Rejudgings.BatchRejudgeAsync(predicate, rejudging, fullTest));
 }
Example #2
0
        async Task <CheckResult <Rejudging> > IRejudgingContext.SystemTestAsync(int uid)
        {
            if (Contest.GetState() < Entities.ContestState.Ended)
            {
                return(CheckResult <Rejudging> .Fail("Contest should be ended first."));
            }

            if (Contest.Settings.SystemTestRejudgingId != null)
            {
                var rej = await Polygon.Rejudgings.FindAsync(Contest.Id, Contest.Settings.SystemTestRejudgingId.Value);

                return(rej != null
                    ? CheckResult <Rejudging> .Succeed(rej)
                    : CheckResult <Rejudging> .Fail($"Rejudging {Contest.Settings.SystemTestRejudgingId.Value} not found."));
            }

            if (await Polygon.Rejudgings.CountUndoneAsync(Contest.Id) != 0)
            {
                return(CheckResult <Rejudging> .Fail("There's pending rejudgings."));
            }

            var rejudging = new Rejudging
            {
                ContestId  = Contest.Id,
                Reason     = "System Test",
                StartTime  = DateTimeOffset.Now,
                EndTime    = DateTimeOffset.Now,
                IssuedBy   = uid,
                OperatedBy = uid,
                Applied    = true,
            };

            rejudging = await Polygon.Rejudgings.CreateAsync(rejudging);

            var settings = Contest.Settings.Clone();

            settings.SystemTestRejudgingId = rejudging.Id;
            var settingsJson = settings.ToJson();

            await UpdateContestAsync(c => new Entities.Contest {
                SettingsJson = settingsJson
            });

            var startTime = Contest.StartTime !.Value;
            var endTime   = (Contest.StartTime + Contest.EndTime) !.Value;
            int count     = await Polygon.Rejudgings.BatchRejudgeAsync(
                (s, j) => j.Status == Verdict.Accepted && s.Time >= startTime && s.Time <= endTime,
                rejudging, immediateApply : true, stageAsRunning : true);

            if (count == 0)
            {
                await Polygon.Rejudgings.DeleteAsync(rejudging);

                return(CheckResult <Rejudging> .Fail("There's no accepted submissions in this contest."));
            }

            await Mediator.Publish(new Events.ScoreboardRefreshEvent(this));

            await Db.Judgings
            .Where(j => j.RejudgingId == rejudging.Id)
            .BatchUpdateAsync(j => new Judging {
                Status = Verdict.Pending
            });

            return(CheckResult <Rejudging> .Succeed(rejudging));
        }
Example #3
0
 Task IRejudgingContext.ApplyAsync(Rejudging rejudge, int uid)
 {
     return(Polygon.Rejudgings.ApplyAsync(rejudge, uid));
 }
Example #4
0
 Task IRejudgingContext.CancelAsync(Rejudging rejudge, int uid)
 {
     return(Polygon.Rejudgings.CancelAsync(rejudge, uid));
 }
Example #5
0
 Task <IEnumerable <RejudgingDifference> > IRejudgingContext.ViewAsync(
     Rejudging rejudge,
     Expression <Func <Judging, Judging, Submission, bool> >?filter)
 {
     return(Polygon.Rejudgings.ViewAsync(rejudge, filter));
 }
Example #6
0
 Task IRejudgingContext.DeleteAsync(Rejudging entity)
 {
     return(Polygon.Rejudgings.DeleteAsync(entity));
 }
Example #7
0
 Task <Rejudging> IRejudgingContext.CreateAsync(Rejudging entity)
 {
     return(Polygon.Rejudgings.CreateAsync(entity));
 }