mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-23 02:47:10 +00:00
Merge branch 'master' of https://gitlab.prodcontest.ru/team-15/project
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
from sys import stdout
|
||||
from uuid import uuid4
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import Count, Q
|
||||
from django.core.exceptions import ValidationError
|
||||
from mdeditor.fields import MDTextField
|
||||
|
||||
from apps.competition.models import Competition
|
||||
@@ -78,6 +80,36 @@ class CompetitionTask(BaseModel):
|
||||
verbose_name="кол-во проверяющих для зачета задачи",
|
||||
)
|
||||
|
||||
def clean(self):
|
||||
super().clean()
|
||||
# if self.correct_answer_file and self.type not in ["checker", "input"]:
|
||||
# raise ValidationError({
|
||||
# "type": "Если загружен файл правильного ответа, то тип проверки не может быть ручным"
|
||||
# })
|
||||
if not self.correct_answer_file and self.type != "review":
|
||||
raise ValidationError({
|
||||
"correct_answer_file": "Загрузите правильный ответ"
|
||||
})
|
||||
|
||||
# if self.answer_file_path and not self.type == "checker":
|
||||
# raise ValidationError({
|
||||
# "type": "Укажите другой тип задания: этот не совместим с путем правильного ответа"
|
||||
# })
|
||||
if not self.answer_file_path and self.type == "checker":
|
||||
raise ValidationError({
|
||||
"answer_file_path": "Введите путь правильного ответа - это нужно для корректной работы чекера"
|
||||
})
|
||||
|
||||
if not self.reviewers and self.type == "review":
|
||||
raise ValidationError({
|
||||
"reviewers": "Загрузите ревьюверов - кто будет проверять задания, если не они?"
|
||||
})
|
||||
# elif self.reviewers and not self.type == "review":
|
||||
# raise ValidationError({
|
||||
# "type": "Проверьте тип - вы ввели ревьюверов, но задание не является ручным"
|
||||
# })
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ def analyze_data_task(self, submission_id):
|
||||
submission = CompetitionTaskSubmission.objects.get(id=submission_id)
|
||||
try:
|
||||
code = submission.content.read()
|
||||
print("YA SSF")
|
||||
files = [
|
||||
{
|
||||
"url": (
|
||||
@@ -43,7 +42,7 @@ def analyze_data_task(self, submission_id):
|
||||
)
|
||||
response.raise_for_status()
|
||||
result = response.json()
|
||||
print("HOHOHO")
|
||||
print(result, response.request)
|
||||
|
||||
submission.stdout.save("output.txt", ContentFile(result["output"]))
|
||||
submission.result = {
|
||||
@@ -59,6 +58,7 @@ def analyze_data_task(self, submission_id):
|
||||
except httpx.RequestError:
|
||||
self.retry(countdown=2**self.request.retries)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
submission.result = {"error": str(e), "success": False}
|
||||
submission.status = CompetitionTaskSubmission.StatusChoices.CHECKED
|
||||
submission.earned_points = 0
|
||||
|
||||
@@ -88,7 +88,9 @@ async def download_file(
|
||||
session: aiohttp.ClientSession, url: str, dest_path: str
|
||||
) -> None:
|
||||
try:
|
||||
async with session.get(url, timeout=aiohttp.ClientTimeout(total=30)) as resp:
|
||||
async with session.get(
|
||||
url, timeout=aiohttp.ClientTimeout(total=30)
|
||||
) as resp:
|
||||
if resp.status != 200:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
@@ -266,15 +268,19 @@ async def execute_code(request: ExecutionRequest) -> ExecutionResponse:
|
||||
|
||||
result_hash = hashlib.sha256(output.encode()).hexdigest()
|
||||
|
||||
return ExecutionResponse(
|
||||
response = ExecutionResponse(
|
||||
success=success,
|
||||
hash_match=(
|
||||
result_hash == request.expected_hash if request.expected_hash else None
|
||||
result_hash == request.expected_hash
|
||||
if request.expected_hash
|
||||
else None
|
||||
),
|
||||
output=output[:5000],
|
||||
result_hash=result_hash,
|
||||
error=error[:5000],
|
||||
)
|
||||
print(response.model_dump_json())
|
||||
return response
|
||||
|
||||
|
||||
@app.get("/health", response_model=HealthCheckResponse)
|
||||
|
||||
@@ -2,7 +2,7 @@ import { User } from "@/shared/types/user";
|
||||
|
||||
export const UserInfo = ({ user }: { user: User }) => {
|
||||
return (
|
||||
<section className="flex flex-1 flex-col items-center gap-6 text-center md:max-w-[420px] md:items-start md:text-ellipsis">
|
||||
<section className="flex flex-1 flex-col items-center gap-6 text-center md:max-w-[420px] md:items-start md:text-left md:text-ellipsis">
|
||||
{user.avatar && (
|
||||
<div className="aspect-square h-auto w-full max-w-[300px] overflow-hidden rounded-full border">
|
||||
<img
|
||||
|
||||
@@ -163,7 +163,7 @@ const ReviewContent = ({ review }: { review: Review }) => {
|
||||
<div className="flex flex-col gap-5">
|
||||
<h2 className="text-3xl font-semibold">Ответ</h2>
|
||||
|
||||
<div className="bg-background rounded-xl px-5 py-3 text-lg">
|
||||
<div className="bg-background rounded-xl px-5 py-3 text-lg break-words">
|
||||
{extension === "txt" ? (
|
||||
content
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user