Add user filtering and progress overview to submissions page; enhance localization for user selection and progress display

This commit is contained in:
2025-12-09 14:37:04 +03:00
parent d8d39ea443
commit cbf2168e52
6 changed files with 189 additions and 7 deletions

View File

@@ -200,6 +200,28 @@
}
],
"activeParticipants": [
{
"userId": "6909b51512c75d75a36a52bf",
"nickname": "Примаков А.А.",
"totalSubmissions": 14,
"completedTasks": 1,
"chainProgress": [
{
"chainId": "6909ad8612c75d75a36a4c58",
"chainName": "Это тестовая цепочка заданий",
"totalTasks": 2,
"completedTasks": 1,
"progressPercent": 50
},
{
"chainId": "690a30b1e723507972c44098",
"chainName": "Навыки работы с нейросетями для начинающих (пошагово)",
"totalTasks": 20,
"completedTasks": 1,
"progressPercent": 5
}
]
},
{
"userId": "user_1",
"nickname": "alex_dev",

View File

@@ -61,6 +61,32 @@ const getStatsV2 = () => {
return statsV2Cache;
};
// Enrich SystemStatsV2 with real user ids/nicknames from users.json
const getStatsV2WithUsers = () => {
const statsV2 = getStatsV2();
const users = getUsers();
const mapParticipant = (participant, index) => {
const user = users[index];
if (!user) return participant;
return {
...participant,
userId: user.id,
nickname: user.nickname,
};
};
return {
...statsV2,
activeParticipants: statsV2.activeParticipants.map(mapParticipant),
chainsDetailed: statsV2.chainsDetailed.map((chain) => ({
...chain,
participantProgress: chain.participantProgress.map(mapParticipant),
})),
};
};
router.use(timer());
// ============= TASKS =============
@@ -282,7 +308,7 @@ router.get('/challenge/stats', (req, res) => {
// GET /api/challenge/stats/v2
router.get('/challenge/stats/v2', (req, res) => {
const statsV2 = getStatsV2();
const statsV2 = getStatsV2WithUsers();
const chainId = req.query.chainId;
// Если chainId не передан, возвращаем все данные