Skip to content

Commit 102f0b5

Browse files
authored
Merge pull request #1676 - Production Deploy (01.04.2026)
Production Deploy (01.04.2026)
2 parents 876212a + d573baa commit 102f0b5

5 files changed

Lines changed: 48 additions & 18 deletions

File tree

Services/Common/OJS.Workers/OJS.Workers.ExecutionStrategies/Models/JsonExecutionResult.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ namespace OJS.Workers.ExecutionStrategies.Models
1010
public class JsonExecutionResult
1111
{
1212
private const string InvalidJsonReplace = "]}[},!^@,Invalid,!^@,{]{[";
13+
private const string MissingJsonStructureError = "Invalid console output! Please make sure there are no console.log statements in the solution. The system expects JSON output from Mocha test results.";
14+
private const string MissingPassingFieldError = "Invalid console output! Please make sure there are no console.log statements in the solution. Missing or invalid 'passing' array in test results.";
15+
private const string MissingFailuresFieldError = "Invalid console output! Please make sure there are no console.log statements in the solution. Missing or invalid 'failures' array with 'err.message' fields.";
1316

1417
public IList<string> TestErrors { get; set; }
1518

@@ -68,7 +71,7 @@ public static JsonExecutionResult Parse(string result, bool forceErrorExtracting
6871
}
6972
catch
7073
{
71-
error = "Invalid console output!";
74+
error = MissingJsonStructureError;
7275
}
7376

7477
var testsIndexes = new List<int>();
@@ -80,7 +83,7 @@ public static JsonExecutionResult Parse(string result, bool forceErrorExtracting
8083
}
8184
catch
8285
{
83-
error = "Invalid console output!";
86+
error = MissingPassingFieldError;
8487
}
8588
}
8689

@@ -97,7 +100,7 @@ public static JsonExecutionResult Parse(string result, bool forceErrorExtracting
97100
}
98101
catch
99102
{
100-
error = "Invalid console output!";
103+
error = MissingFailuresFieldError;
101104
}
102105
}
103106

Services/Common/OJS.Workers/OJS.Workers.ExecutionStrategies/NodeJs/NodeJsPreprocessExecuteAndRunAllUnitTestsWithMochaExecutionStrategy.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,23 +107,18 @@ protected override async Task<IExecutionResult<TestResult>> ExecuteAgainstTestsI
107107
protected static string FormatTests(IEnumerable<TestContext> tests, bool isTypeScript)
108108
{
109109
var formattedTests = new List<string>();
110-
var testCounter = 1;
111110

112111
foreach (var test in tests)
113112
{
114113
// Use simple sequential test names
115-
var testName = $"Test{testCounter}";
116114
var testContent = test.Input.Trim();
117115

118116
// Format the test with proper it() wrapper
119117
var formattedTest = $@"
120118
{(isTypeScript ? "// @ts-ignore" : "")}
121-
it('{testName}', function () {{
122-
{testContent}
123-
}})";
119+
{testContent}";
124120

125121
formattedTests.Add(formattedTest);
126-
testCounter++;
127122
}
128123

129124
// Join all formatted tests

Services/Common/OJS.Workers/OJS.Workers.ExecutionStrategies/NodeJs/Typescript/TypeScriptProjectMochaUnitTestsExecutionStrategy.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,24 @@ protected override async Task<IExecutionResult<TestResult>> ExecuteAgainstTestsI
2323
{
2424
SaveZipSubmission(executionContext.FileContent, this.WorkingDirectory);
2525

26+
var esBuildExecutionArguments = new[]
27+
{
28+
"src/index.ts",
29+
"--bundle",
30+
"--platform=node",
31+
"--format=cjs",
32+
"--target=node21",
33+
"--packages=external",
34+
"--drop:console",
35+
"--outfile=dist/app.bundle.js"
36+
};
37+
2638
var executor = this.CreateStandardExecutor();
2739
var bundleResult = await executor.Execute(
2840
this.Settings.EsBuildModulePath,
2941
executionContext.TimeLimit,
3042
executionContext.MemoryLimit,
31-
executionArguments: ["src/index.ts", "--bundle", "--platform=node", "--format=cjs", "--target=node21", "--packages=external", "--outfile=dist/app.bundle.js"],
43+
executionArguments: esBuildExecutionArguments,
3244
workingDirectory: this.WorkingDirectory,
3345
cancellationToken: cancellationToken);
3446

Services/UI/OJS.Services.Ui.Business/Implementations/ContestsBusinessService.cs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace OJS.Services.Ui.Business.Implementations;
1313
using OJS.Services.Infrastructure.Constants;
1414
using OJS.Services.Infrastructure.Extensions;
1515
using OJS.Services.Infrastructure.Models;
16+
using OJS.Services.Infrastructure;
1617
using OJS.Services.Ui.Business.Cache;
1718
using OJS.Services.Ui.Business.Validations.Implementations.Contests;
1819
using OJS.Services.Ui.Data;
@@ -34,7 +35,8 @@ public class ContestsBusinessService(
3435
IContestParticipantsCacheService contestParticipantsCacheService,
3536
IContestsCacheService contestsCacheService,
3637
ILecturersInContestsCacheService lecturersInContestsCache,
37-
IContestDetailsValidationService contestDetailsValidationService)
38+
IContestDetailsValidationService contestDetailsValidationService,
39+
IDatesService datesService)
3840
: IContestsBusinessService
3941
{
4042
public async Task<ServiceResult<ContestDetailsServiceModel>> GetContestDetails(int id)
@@ -328,6 +330,8 @@ public async Task<ContestSearchServiceResultModel> GetSearchContestsByName(
328330
.MapCollection<ContestForListingServiceModel>()
329331
.ToPagedListAsync(model.PageNumber, model.ItemsPerPage);
330332

333+
this.SetContestVisibility(searchContests);
334+
331335
modelResult.Contests = searchContests;
332336
modelResult.TotalContestsCount = allContestsQueryable.Count();
333337

@@ -344,6 +348,8 @@ public async Task<PagedResult<ContestForListingServiceModel>> GetAllByFiltersAnd
344348
var pagedContests =
345349
await contestsData.GetAllAsPageByFiltersAndSorting<ContestForListingServiceModel>(model, includeHidden);
346350

351+
this.SetContestVisibility(pagedContests.Items);
352+
347353
var participantResultsByContest = new Dictionary<int, List<ParticipantResultServiceModel>>();
348354
if (user.IsAuthenticated)
349355
{
@@ -390,6 +396,8 @@ public async Task<PagedResult<ContestForListingServiceModel>> GetParticipatedByU
390396
participatedContests,
391397
sortAndFilterModel);
392398

399+
this.SetContestVisibility(participatedContestsInPage.Items);
400+
393401
var participantResultsByContest = new Dictionary<int, List<ParticipantResultServiceModel>>();
394402
var loggedInUser = userProviderService.GetCurrentUser();
395403

@@ -499,10 +507,16 @@ await pagedContests.Items.ForEachAsync(c =>
499507
.ToListAsync();
500508

501509
public async Task<IEnumerable<ContestForListingServiceModel>> GetAllParticipatedContests(string username)
502-
=> await contestsData
503-
.GetLatestForParticipantByUsername(username)
504-
.MapCollection<ContestForListingServiceModel>()
505-
.ToListAsync();
510+
{
511+
var contests = await contestsData
512+
.GetLatestForParticipantByUsername(username)
513+
.MapCollection<ContestForListingServiceModel>()
514+
.ToListAsync();
515+
516+
this.SetContestVisibility(contests);
517+
518+
return contests;
519+
}
506520

507521
private static async Task<Dictionary<int, List<ParticipantResultServiceModel>>> MapParticipationResultsToContestsInPage(
508522
IQueryable<Participant> participants)
@@ -565,4 +579,13 @@ private async Task<ContestFiltersServiceModel> GetNestedFilterCategoriesIfAny(Co
565579
official,
566580
isUserAdminOrLecturerInContest);
567581
}
582+
583+
private void SetContestVisibility(IEnumerable<ContestForListingServiceModel> contests)
584+
{
585+
var now = datesService.GetUtcNow();
586+
foreach (var contest in contests)
587+
{
588+
contest.IsVisible = contest.IsVisible || contest.VisibleFrom <= now;
589+
}
590+
}
568591
}

Services/UI/OJS.Services.Ui.Models/Contests/ContestForListingServiceModel.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ public void RegisterMappings(IProfileExpression configuration)
8484
.SelectMany(pg => pg.Problems)
8585
.Where(x => !x.IsDeleted)
8686
.Sum(pr => pr.MaximumPoints)))
87-
.ForMember(
88-
c => c.IsVisible,
89-
opt => opt.MapFrom(s => s.IsVisible || s.VisibleFrom <= DateTime.UtcNow))
9087
// For online contests:
9188
// In a problem group with multiple problems, compete points are derived from a single problem,
9289
// unlike practice mode where points can be accumulated from all problems across groups.

0 commit comments

Comments
 (0)