diff --git a/VERSION b/VERSION index c4e41f9..c5106e6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.3 +4.0.4 diff --git a/play-life-backend/main.go b/play-life-backend/main.go index 2447408..fdd79ed 100644 --- a/play-life-backend/main.go +++ b/play-life-backend/main.go @@ -6515,22 +6515,16 @@ func (a *App) getTaskDetailHandler(w http.ResponseWriter, r *http.Request) { // Загружаем все награды всех подзадач одним запросом if len(subtaskIDs) > 0 { - placeholders := make([]string, len(subtaskIDs)) - args := make([]interface{}, len(subtaskIDs)) - for i, id := range subtaskIDs { - placeholders[i] = fmt.Sprintf("$%d", i+1) - args[i] = id - } - - query := fmt.Sprintf(` + // Используем параметризованный запрос с ANY(ARRAY[...]) + query := ` SELECT rc.task_id, rc.id, rc.position, p.name AS project_name, rc.value, rc.use_progression FROM reward_configs rc JOIN projects p ON rc.project_id = p.id - WHERE rc.task_id = ANY(ARRAY[%s]) + WHERE rc.task_id = ANY($1::int[]) ORDER BY rc.task_id, rc.position - `, strings.Join(placeholders, ",")) + ` - subtaskRewardRows, err := a.DB.Query(query, args...) + subtaskRewardRows, err := a.DB.Query(query, pq.Array(subtaskIDs)) if err != nil { log.Printf("Error querying subtask rewards: %v", err) } else { diff --git a/play-life-web/package.json b/play-life-web/package.json index 83bc5da..2409ec6 100644 --- a/play-life-web/package.json +++ b/play-life-web/package.json @@ -1,6 +1,6 @@ { "name": "play-life-web", - "version": "4.0.3", + "version": "4.0.4", "type": "module", "scripts": { "dev": "vite", diff --git a/play-life-web/src/components/TaskDetail.jsx b/play-life-web/src/components/TaskDetail.jsx index 1ef6da1..407e653 100644 --- a/play-life-web/src/components/TaskDetail.jsx +++ b/play-life-web/src/components/TaskDetail.jsx @@ -331,10 +331,20 @@ const formatTelegramMessage = (task, rewards, subtasks, selectedSubtasks, progre // Формируем сообщения подзадач const subtaskMessages = [] + // #region agent log + fetch('http://127.0.0.1:7243/ingest/dd59cdcd-2e10-41ef-b65f-ebbaae0d7424',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'TaskDetail.jsx:333',message:'Starting subtask messages processing',data:{subtasksCount:subtasks.length,selectedSubtasksCount:selectedSubtasks.size,selectedSubtasks:Array.from(selectedSubtasks)},timestamp:Date.now(),sessionId:'debug-session',runId:'run2',hypothesisId:'B'})}).catch(()=>{}); + // #endregion subtasks.forEach(subtask => { + // #region agent log + fetch('http://127.0.0.1:7243/ingest/dd59cdcd-2e10-41ef-b65f-ebbaae0d7424',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'TaskDetail.jsx:336',message:'Checking subtask',data:{subtaskId:subtask.task.id,isSelected:selectedSubtasks.has(subtask.task.id),hasRewardMessage:!!(subtask.task.reward_message && subtask.task.reward_message.trim() !== ''),rewardsCount:subtask.rewards?.length||0},timestamp:Date.now(),sessionId:'debug-session',runId:'run2',hypothesisId:'B'})}).catch(()=>{}); + // #endregion if (!selectedSubtasks.has(subtask.task.id)) return if (!subtask.task.reward_message || subtask.task.reward_message.trim() === '') return + // #region agent log + fetch('http://127.0.0.1:7243/ingest/dd59cdcd-2e10-41ef-b65f-ebbaae0d7424',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'TaskDetail.jsx:340',message:'Processing subtask for message',data:{subtaskId:subtask.task.id,subtaskName:subtask.task.name,rewardsCount:subtask.rewards?.length||0,rewards:subtask.rewards,rewardMessage:subtask.task.reward_message},timestamp:Date.now(),sessionId:'debug-session',runId:'run2',hypothesisId:'B'})}).catch(()=>{}); + // #endregion + // Вычисляем score для наград подзадачи const subtaskRewardStrings = {} subtask.rewards.forEach(reward => { @@ -393,6 +403,9 @@ function TaskDetail({ taskId, onClose, onRefresh, onTaskCompleted, onNavigate }) throw new Error('Ошибка загрузки задачи') } const data = await response.json() + // #region agent log + fetch('http://127.0.0.1:7243/ingest/dd59cdcd-2e10-41ef-b65f-ebbaae0d7424',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'TaskDetail.jsx:395',message:'TaskDetail data loaded',data:{taskId:taskId,subtasksCount:data.subtasks?.length||0,subtasks:data.subtasks?.map(st=>({id:st.task?.id,name:st.task?.name,rewardsCount:st.rewards?.length||0,rewards:st.rewards}))},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{}); + // #endregion setTaskDetail(data) // Используем информацию о wishlist из ответа API @@ -621,6 +634,9 @@ function TaskDetail({ taskId, onClose, onRefresh, onTaskCompleted, onNavigate })
{subtasks.map((subtask) => { const subtaskName = subtask.task.name || 'Подзадача' + // #region agent log + fetch('http://127.0.0.1:7243/ingest/dd59cdcd-2e10-41ef-b65f-ebbaae0d7424',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'TaskDetail.jsx:622',message:'Rendering subtask',data:{subtaskId:subtask.task.id,subtaskName:subtaskName,rewardsCount:subtask.rewards?.length||0,rewards:subtask.rewards},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'C'})}).catch(()=>{}); + // #endregion return (