Refactor ClearSubmissionsDialog and DuplicateChainDialog components by removing unnecessary whitespace; improve code cleanliness and maintainability.

This commit is contained in:
2025-12-14 13:00:57 +03:00
parent 88b95a7651
commit 1d364a2351
3 changed files with 26 additions and 3 deletions

View File

@@ -75,3 +75,5 @@ export const ClearSubmissionsDialog: React.FC<ClearSubmissionsDialogProps> = ({
)
}

View File

@@ -104,3 +104,5 @@ export const DuplicateChainDialog: React.FC<DuplicateChainDialogProps> = ({
)
}

View File

@@ -409,13 +409,32 @@ router.get('/challenge/stats/v2', (req, res) => {
return;
}
// Фильтруем данные по выбранной цепочке
const filteredChain = statsV2.chainsDetailed.find(c => c.chainId === chainId);
// Сначала проверяем наличие цепочки в chains.json
const chains = getChains();
const chain = chains.find(c => c.id === chainId);
if (!filteredChain) {
if (!chain) {
return respondError(res, 'Chain not found', 404);
}
// Ищем данные цепочки в stats-v2.json
let filteredChain = statsV2.chainsDetailed.find(c => c.chainId === chainId);
// Если цепочка не найдена в stats-v2.json, создаем пустую структуру на основе chains.json
if (!filteredChain) {
filteredChain = {
chainId: chain.id,
name: chain.name,
totalTasks: chain.tasks.length,
tasks: chain.tasks.map(t => ({
taskId: t.id,
title: t.title,
description: t.description || ''
})),
participantProgress: []
};
}
// Фильтруем tasksTable - только задания из этой цепочки
const chainTaskIds = new Set(filteredChain.tasks.map(t => t.taskId));
const filteredTasksTable = statsV2.tasksTable.filter(t => chainTaskIds.has(t.taskId));