Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions JustBigO(Fun)/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ public async Task<IActionResult> AnalyzeComplexity(

try
{
// Gestionăm timeout-ul de 10 secunde să nu blocăm interfața.
// Gestionăm timeout-ul de 30 secunde să nu blocăm interfața.
var analyzeTask = complexityAnalyzer.AnalyzeCodeAsync(model.SourceCode);
var timeoutTask = Task.Delay(TimeSpan.FromSeconds(10));
var timeoutTask = Task.Delay(TimeSpan.FromSeconds(30));

if (await Task.WhenAny(analyzeTask, timeoutTask) == analyzeTask)
{
Expand Down Expand Up @@ -333,13 +333,13 @@ public async Task<IActionResult> SubmitSolution(
string timeO = "O(?)";
string spaceO = "O(?)";

// 2. Dacă codul trece testele, apelăm Agentul AI cu TIMEOUT de 10 secunde
// 2. Dacă codul trece testele, apelăm Agentul AI cu TIMEOUT de 30 secunde
if (isSuccess)
{
try
{
var analyzeTask = complexityAnalyzer.AnalyzeCodeAsync(model.SourceCode);
var timeoutTask = Task.Delay(TimeSpan.FromSeconds(10));
var timeoutTask = Task.Delay(TimeSpan.FromSeconds(30));

if (await Task.WhenAny(analyzeTask, timeoutTask) == analyzeTask)
{
Expand Down
7 changes: 6 additions & 1 deletion JustBigO(Fun)/Services/DockerCodeExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.EntityFrameworkCore;
using System.Diagnostics;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text;
using System.Text.RegularExpressions;

Expand All @@ -13,7 +14,11 @@
private readonly IServiceScopeFactory _scopeFactory;
private readonly ILogger<DockerCodeExecutor> _logger;
private static readonly Encoding Utf8NoBom = new UTF8Encoding(false);
private static readonly JsonSerializerOptions JsonOptions = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase };
private static readonly JsonSerializerOptions JsonOptions = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
Converters = { new JsonStringEnumConverter() }
};

public DockerCodeExecutor(IServiceScopeFactory scopeFactory, ILogger<DockerCodeExecutor> logger)
{
Expand Down Expand Up @@ -281,7 +286,7 @@
else
{
result.Output = output.Trim();
result.Status = IsMatch(result.Output, result.Expected) ? SubmissionStatus.Accepted : SubmissionStatus.WrongAnswer;

Check warning on line 289 in JustBigO(Fun)/Services/DockerCodeExecutor.cs

View workflow job for this annotation

GitHub Actions / Build & Test (CI)

Possible null reference argument for parameter 'expected' in 'bool DockerCodeExecutor.IsMatch(string actual, string expected)'.

Check warning on line 289 in JustBigO(Fun)/Services/DockerCodeExecutor.cs

View workflow job for this annotation

GitHub Actions / Build & Test (CI)

Possible null reference argument for parameter 'expected' in 'bool DockerCodeExecutor.IsMatch(string actual, string expected)'.
}
}

Expand Down
24 changes: 12 additions & 12 deletions JustBigO(Fun)/Views/Home/Solve.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@
.replace(/"/g, '&quot;');
}

// Functie ajutatoare pentru timeout Frontend (10 secunde)
// Functie ajutatoare pentru timeout Frontend (30 secunde)
async function fetchWithTimeout(resource, options = {}) {
const { timeout = 10000 } = options;
const { timeout = 30000 } = options;
const controller = new AbortController();
const id = setTimeout(() => controller.abort(), timeout);
const response = await fetch(resource, {
Expand Down Expand Up @@ -244,12 +244,12 @@
try {
// Impunem limită la apelul SignalR
const invokeTask = connection.invoke("TranslateCode", sourceCode, sourceLang, targetLang);
const timeoutTask = new Promise((_, reject) => setTimeout(() => reject(new Error("Timeout")), 10000));
const timeoutTask = new Promise((_, reject) => setTimeout(() => reject(new Error("Timeout")), 30000));
await Promise.race([invokeTask, timeoutTask]);
} catch (err) {
console.error("Translation Error: ", err);
if (err.message === "Timeout") {
window.aiEditor.setValue("// Timeout: Agentul AI a depășit timpul de așteptare de 10s.\n// Platforma nu a fost blocată. Încearcă din nou mai târziu.");
window.aiEditor.setValue("// Timeout: Agentul AI a depășit timpul de așteptare de 30s.\n// Platforma nu a fost blocată. Încearcă din nou mai târziu.");
} else {
window.aiEditor.setValue("// Error translating code.");
}
Expand Down Expand Up @@ -278,7 +278,7 @@
sourceCode: sourceCode,
language: language
}),
timeout: 10000 // 10 secunde limită
timeout: 30000 // 30 secunde limită
});

if ((response.redirected && response.url.includes('Login')) || response.status === 401) {
Expand All @@ -291,7 +291,7 @@
hintContainer.textContent = data.hint || "No hint was returned.";
} catch (err) {
if (err.name === 'AbortError' || err.message === 'Timeout') {
hintContainer.innerHTML = '<span class="text-danger">Timpul de așteptare a expirat (10s). Agentul AI este momentan suprasolicitat.</span>';
hintContainer.innerHTML = '<span class="text-danger">Timpul de așteptare a expirat (30s). Agentul AI este momentan suprasolicitat.</span>';
} else {
hintContainer.textContent = "Error requesting hint: " + err.message;
}
Expand Down Expand Up @@ -320,7 +320,7 @@
sourceCode: sourceCode,
language: language
}),
timeout: 10000
timeout: 30000
});

if ((response.redirected && response.url.includes('Login')) || response.status === 401) {
Expand Down Expand Up @@ -351,7 +351,7 @@
consoleOutput.innerHTML = msg;
} catch (err) {
if (err.name === 'AbortError' || err.message === 'Timeout') {
consoleOutput.innerHTML = '<div class="p-2 text-danger">Timeout: Agentul AI a depășit timpul alocat (10s). Platforma nu a fost blocată.</div>';
consoleOutput.innerHTML = '<div class="p-2 text-danger">Timeout: Agentul AI a depășit timpul alocat (30s). Platforma nu a fost blocată.</div>';
} else {
consoleOutput.innerHTML = '<div class="p-2 text-danger">Complete current code failed: ' + err.message + '</div>';
}
Expand Down Expand Up @@ -387,7 +387,7 @@
sourceCode: sourceCode,
language: language
}),
timeout: 10000
timeout: 30000
});

if ((response.redirected && response.url.includes('Login')) || response.status === 401) {
Expand All @@ -411,7 +411,7 @@
preCode.textContent = '';
preDs.textContent = '';
if (err.name === 'AbortError' || err.message === 'Timeout') {
preSteps.textContent = 'Timeout: Agentul AI a depășit timpul de așteptare de 10 secunde.';
preSteps.textContent = 'Timeout: Agentul AI a depășit timpul de așteptare de 30 secunde.';
} else {
preSteps.textContent = 'Error: ' + err.message;
}
Expand Down Expand Up @@ -515,7 +515,7 @@
results.forEach((r, idx) => {
const isOk = r.status === 'Accepted';
html += `
<div class="mb-4 p-2 border ${isOk ? 'border-success' : 'border-danger'} rounded bg-dark">
<div class="mb-4 p-2 rounded jbo-testcase ${isOk ? 'jbo-testcase--pass' : 'jbo-testcase--fail'}">
<div class="d-flex justify-content-between">
<strong>Test Case #${idx + 1}</strong>
<span class="badge ${isOk ? 'bg-success' : 'bg-danger'}">${r.status}</span>
Expand Down Expand Up @@ -574,7 +574,7 @@
sourceCode: sourceCode,
language: document.getElementById('languageSelect').value
}),
timeout: 10000
timeout: 30000
});

if (aiResponse.ok) {
Expand Down
22 changes: 19 additions & 3 deletions JustBigO(Fun)/wwwroot/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -648,14 +648,30 @@ body {
}

.jbo-console-panel {
height: 180px;
height: 340px;
background: rgba(15,23,42,0.96);
border: 1px solid rgba(148,163,184,0.3);
border-radius: 0.75rem;
display: flex;
flex-direction: column;
}

/* Test-case result boxes (Submit output) */
.jbo-testcase {
border: 1px solid transparent;
background: rgba(15,23,42,0.6);
}

.jbo-testcase--pass {
border-color: #22c55e !important;
background: rgba(34,197,94,0.12) !important;
}

.jbo-testcase--fail {
border-color: #ef4444 !important;
background: rgba(239,68,68,0.10) !important;
}

.jbo-console-header {
display: flex;
justify-content: space-between;
Expand Down Expand Up @@ -703,6 +719,8 @@ body {
background: rgba(15, 23, 42, 0.85);
border: 1px solid rgba(148, 163, 184, 0.25);
color: #cbd5e1;
max-height: 24rem;
overflow-y: auto;
}

.jbo-improve-pre {
Expand All @@ -715,8 +733,6 @@ body {
border-radius: 0.35rem;
padding: 0.5rem 0.65rem;
margin: 0;
max-height: 12rem;
overflow-y: auto;
color: #e2e8f0;
}

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

JustBigO-Fun is an ASP.NET Core 9.0 MVC platform for algorithmic challenges, inspired by sites like LeetCode.

> 🎥 **Demo (screencast):** https://youtu.be/4bKce7Ch55Y

> 📄 The application's technical documentation (features, tech stack, run instructions) is in the **[Project Documentation](#project-documentation)** section at the end of this README.

---
Expand Down
Loading