Add workplaceNumber field to user authentication and statistics API. Update frontend components and localization to support new field. Enhance user experience by displaying workplace information in relevant areas.
This commit is contained in:
@@ -203,6 +203,7 @@
|
||||
{
|
||||
"userId": "6909b51512c75d75a36a52bf",
|
||||
"nickname": "Примаков А.А.",
|
||||
"workplaceNumber": "PC-07",
|
||||
"totalSubmissions": 14,
|
||||
"completedTasks": 1,
|
||||
"chainProgress": [
|
||||
@@ -225,6 +226,7 @@
|
||||
{
|
||||
"userId": "user_1",
|
||||
"nickname": "alex_dev",
|
||||
"workplaceNumber": "PC-01",
|
||||
"totalSubmissions": 18,
|
||||
"completedTasks": 12,
|
||||
"chainProgress": [
|
||||
@@ -247,6 +249,7 @@
|
||||
{
|
||||
"userId": "user_2",
|
||||
"nickname": "maria_coder",
|
||||
"workplaceNumber": "PC-05",
|
||||
"totalSubmissions": 15,
|
||||
"completedTasks": 9,
|
||||
"chainProgress": [
|
||||
@@ -269,6 +272,7 @@
|
||||
{
|
||||
"userId": "user_3",
|
||||
"nickname": "ivan_programmer",
|
||||
"workplaceNumber": "PC-12",
|
||||
"totalSubmissions": 10,
|
||||
"completedTasks": 5,
|
||||
"chainProgress": [
|
||||
@@ -291,6 +295,7 @@
|
||||
{
|
||||
"userId": "user_4",
|
||||
"nickname": "kate_fullstack",
|
||||
"workplaceNumber": "PC-03",
|
||||
"totalSubmissions": 22,
|
||||
"completedTasks": 15,
|
||||
"chainProgress": [
|
||||
@@ -313,6 +318,7 @@
|
||||
{
|
||||
"userId": "user_5",
|
||||
"nickname": "dmitry_backend",
|
||||
"workplaceNumber": "PC-15",
|
||||
"totalSubmissions": 12,
|
||||
"completedTasks": 6,
|
||||
"chainProgress": [
|
||||
@@ -335,6 +341,7 @@
|
||||
{
|
||||
"userId": "user_6",
|
||||
"nickname": "anna_react",
|
||||
"workplaceNumber": "PC-08",
|
||||
"totalSubmissions": 14,
|
||||
"completedTasks": 7,
|
||||
"chainProgress": [
|
||||
@@ -376,6 +383,7 @@
|
||||
{
|
||||
"userId": "user_1",
|
||||
"nickname": "alex_dev",
|
||||
"workplaceNumber": "PC-01",
|
||||
"taskProgress": [
|
||||
{ "taskId": "task_1", "taskTitle": "Создание REST API", "status": "completed" },
|
||||
{ "taskId": "task_2", "taskTitle": "Работа с базой данных MongoDB", "status": "completed" },
|
||||
@@ -394,6 +402,7 @@
|
||||
{
|
||||
"userId": "user_2",
|
||||
"nickname": "maria_coder",
|
||||
"workplaceNumber": "PC-05",
|
||||
"taskProgress": [
|
||||
{ "taskId": "task_1", "taskTitle": "Создание REST API", "status": "completed" },
|
||||
{ "taskId": "task_2", "taskTitle": "Работа с базой данных MongoDB", "status": "completed" },
|
||||
@@ -412,6 +421,7 @@
|
||||
{
|
||||
"userId": "user_3",
|
||||
"nickname": "ivan_programmer",
|
||||
"workplaceNumber": "PC-12",
|
||||
"taskProgress": [
|
||||
{ "taskId": "task_1", "taskTitle": "Создание REST API", "status": "completed" },
|
||||
{ "taskId": "task_2", "taskTitle": "Работа с базой данных MongoDB", "status": "completed" },
|
||||
@@ -430,6 +440,7 @@
|
||||
{
|
||||
"userId": "user_4",
|
||||
"nickname": "kate_fullstack",
|
||||
"workplaceNumber": "PC-03",
|
||||
"taskProgress": [
|
||||
{ "taskId": "task_1", "taskTitle": "Создание REST API", "status": "completed" },
|
||||
{ "taskId": "task_2", "taskTitle": "Работа с базой данных MongoDB", "status": "completed" },
|
||||
@@ -448,6 +459,7 @@
|
||||
{
|
||||
"userId": "user_5",
|
||||
"nickname": "dmitry_backend",
|
||||
"workplaceNumber": "PC-15",
|
||||
"taskProgress": [
|
||||
{ "taskId": "task_1", "taskTitle": "Создание REST API", "status": "completed" },
|
||||
{ "taskId": "task_2", "taskTitle": "Работа с базой данных MongoDB", "status": "completed" },
|
||||
@@ -466,6 +478,7 @@
|
||||
{
|
||||
"userId": "user_6",
|
||||
"nickname": "anna_react",
|
||||
"workplaceNumber": "PC-08",
|
||||
"taskProgress": [
|
||||
{ "taskId": "task_1", "taskTitle": "Создание REST API", "status": "completed" },
|
||||
{ "taskId": "task_2", "taskTitle": "Работа с базой данных MongoDB", "status": "pending" },
|
||||
@@ -503,6 +516,7 @@
|
||||
{
|
||||
"userId": "user_1",
|
||||
"nickname": "alex_dev",
|
||||
"workplaceNumber": "PC-01",
|
||||
"taskProgress": [
|
||||
{ "taskId": "task_11", "taskTitle": "React компоненты", "status": "completed" },
|
||||
{ "taskId": "task_12", "taskTitle": "React Hooks", "status": "completed" },
|
||||
@@ -521,6 +535,7 @@
|
||||
{
|
||||
"userId": "user_2",
|
||||
"nickname": "maria_coder",
|
||||
"workplaceNumber": "PC-05",
|
||||
"taskProgress": [
|
||||
{ "taskId": "task_11", "taskTitle": "React компоненты", "status": "completed" },
|
||||
{ "taskId": "task_12", "taskTitle": "React Hooks", "status": "completed" },
|
||||
@@ -539,6 +554,7 @@
|
||||
{
|
||||
"userId": "user_3",
|
||||
"nickname": "ivan_programmer",
|
||||
"workplaceNumber": "PC-12",
|
||||
"taskProgress": [
|
||||
{ "taskId": "task_11", "taskTitle": "React компоненты", "status": "completed" },
|
||||
{ "taskId": "task_12", "taskTitle": "React Hooks", "status": "completed" },
|
||||
@@ -557,6 +573,7 @@
|
||||
{
|
||||
"userId": "user_4",
|
||||
"nickname": "kate_fullstack",
|
||||
"workplaceNumber": "PC-03",
|
||||
"taskProgress": [
|
||||
{ "taskId": "task_11", "taskTitle": "React компоненты", "status": "completed" },
|
||||
{ "taskId": "task_12", "taskTitle": "React Hooks", "status": "completed" },
|
||||
@@ -575,6 +592,7 @@
|
||||
{
|
||||
"userId": "user_5",
|
||||
"nickname": "dmitry_backend",
|
||||
"workplaceNumber": "PC-15",
|
||||
"taskProgress": [
|
||||
{ "taskId": "task_11", "taskTitle": "React компоненты", "status": "completed" },
|
||||
{ "taskId": "task_12", "taskTitle": "React Hooks", "status": "pending" },
|
||||
@@ -593,6 +611,7 @@
|
||||
{
|
||||
"userId": "user_6",
|
||||
"nickname": "anna_react",
|
||||
"workplaceNumber": "PC-08",
|
||||
"taskProgress": [
|
||||
{ "taskId": "task_11", "taskTitle": "React компоненты", "status": "completed" },
|
||||
{ "taskId": "task_12", "taskTitle": "React Hooks", "status": "completed" },
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
"_id": "user001",
|
||||
"id": "user001",
|
||||
"nickname": "alex_student",
|
||||
"workplaceNumber": "PC-01",
|
||||
"createdAt": "2024-10-15T08:30:00.000Z"
|
||||
},
|
||||
"task": {
|
||||
@@ -31,6 +32,7 @@
|
||||
"_id": "user001",
|
||||
"id": "user001",
|
||||
"nickname": "alex_student",
|
||||
"workplaceNumber": "PC-01",
|
||||
"createdAt": "2024-10-15T08:30:00.000Z"
|
||||
},
|
||||
"task": {
|
||||
@@ -56,6 +58,7 @@
|
||||
"_id": "user002",
|
||||
"id": "user002",
|
||||
"nickname": "maria_dev",
|
||||
"workplaceNumber": "PC-05",
|
||||
"createdAt": "2024-10-16T10:15:00.000Z"
|
||||
},
|
||||
"task": {
|
||||
@@ -81,6 +84,7 @@
|
||||
"_id": "user003",
|
||||
"id": "user003",
|
||||
"nickname": "ivan_coder",
|
||||
"workplaceNumber": "PC-12",
|
||||
"createdAt": "2024-10-17T14:20:00.000Z"
|
||||
},
|
||||
"task": {
|
||||
@@ -106,6 +110,7 @@
|
||||
"_id": "user004",
|
||||
"id": "user004",
|
||||
"nickname": "olga_js",
|
||||
"workplaceNumber": "PC-03",
|
||||
"createdAt": "2024-10-18T09:00:00.000Z"
|
||||
},
|
||||
"task": {
|
||||
@@ -131,6 +136,7 @@
|
||||
"_id": "user005",
|
||||
"id": "user005",
|
||||
"nickname": "dmitry_react",
|
||||
"workplaceNumber": "PC-15",
|
||||
"createdAt": "2024-10-20T11:45:00.000Z"
|
||||
},
|
||||
"task": {
|
||||
@@ -156,6 +162,7 @@
|
||||
"_id": "user006",
|
||||
"id": "user006",
|
||||
"nickname": "anna_frontend",
|
||||
"workplaceNumber": "PC-08",
|
||||
"createdAt": "2024-10-22T16:30:00.000Z"
|
||||
},
|
||||
"task": {
|
||||
|
||||
@@ -3,36 +3,42 @@
|
||||
"_id": "user001",
|
||||
"id": "user001",
|
||||
"nickname": "alex_student",
|
||||
"workplaceNumber": "PC-01",
|
||||
"createdAt": "2024-10-15T08:30:00.000Z"
|
||||
},
|
||||
{
|
||||
"_id": "user002",
|
||||
"id": "user002",
|
||||
"nickname": "maria_dev",
|
||||
"workplaceNumber": "PC-05",
|
||||
"createdAt": "2024-10-16T10:15:00.000Z"
|
||||
},
|
||||
{
|
||||
"_id": "user003",
|
||||
"id": "user003",
|
||||
"nickname": "ivan_coder",
|
||||
"workplaceNumber": "PC-12",
|
||||
"createdAt": "2024-10-17T14:20:00.000Z"
|
||||
},
|
||||
{
|
||||
"_id": "user004",
|
||||
"id": "user004",
|
||||
"nickname": "olga_js",
|
||||
"workplaceNumber": "PC-03",
|
||||
"createdAt": "2024-10-18T09:00:00.000Z"
|
||||
},
|
||||
{
|
||||
"_id": "user005",
|
||||
"id": "user005",
|
||||
"nickname": "dmitry_react",
|
||||
"workplaceNumber": "PC-15",
|
||||
"createdAt": "2024-10-20T11:45:00.000Z"
|
||||
},
|
||||
{
|
||||
"_id": "user006",
|
||||
"id": "user006",
|
||||
"nickname": "anna_frontend",
|
||||
"workplaceNumber": "PC-08",
|
||||
"createdAt": "2024-10-22T16:30:00.000Z"
|
||||
},
|
||||
{
|
||||
@@ -45,6 +51,7 @@
|
||||
"_id": "user008",
|
||||
"id": "user008",
|
||||
"nickname": "elena_fullstack",
|
||||
"workplaceNumber": "PC-20",
|
||||
"createdAt": "2024-10-28T10:00:00.000Z"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -604,18 +604,24 @@ router.get('/challenge/chain/:chainId/submissions', (req, res) => {
|
||||
filteredSubmissions.forEach(sub => {
|
||||
const subUserId = typeof sub.user === 'object' ? sub.user.id : sub.user;
|
||||
const subUserNickname = typeof sub.user === 'object' ? sub.user.nickname : '';
|
||||
const subUserWorkplaceNumber = typeof sub.user === 'object' ? sub.user.workplaceNumber : undefined;
|
||||
|
||||
// Найти nickname если не заполнен
|
||||
// Найти nickname и workplaceNumber если не заполнены
|
||||
let nickname = subUserNickname;
|
||||
if (!nickname) {
|
||||
let workplaceNumber = subUserWorkplaceNumber;
|
||||
if (!nickname || !workplaceNumber) {
|
||||
const user = users.find(u => u.id === subUserId);
|
||||
nickname = user ? user.nickname : subUserId;
|
||||
if (user) {
|
||||
nickname = nickname || user.nickname || subUserId;
|
||||
workplaceNumber = workplaceNumber || user.workplaceNumber;
|
||||
}
|
||||
}
|
||||
|
||||
if (!participantMap.has(subUserId)) {
|
||||
participantMap.set(subUserId, {
|
||||
userId: subUserId,
|
||||
nickname: nickname,
|
||||
workplaceNumber: workplaceNumber,
|
||||
completedTasks: new Set(),
|
||||
totalTasks: chain.tasks.length,
|
||||
});
|
||||
@@ -632,6 +638,7 @@ router.get('/challenge/chain/:chainId/submissions', (req, res) => {
|
||||
const participants = Array.from(participantMap.values()).map(p => ({
|
||||
userId: p.userId,
|
||||
nickname: p.nickname,
|
||||
workplaceNumber: p.workplaceNumber,
|
||||
completedTasks: p.completedTasks.size,
|
||||
totalTasks: p.totalTasks,
|
||||
progressPercent: p.totalTasks > 0
|
||||
|
||||
Reference in New Issue
Block a user