fix: update JiraService to preserve local task title and priority
- Removed unnecessary checks for local updates, ensuring Jira data is always updated. - Preserved local task title and priority during updates to maintain user modifications. - Updated logging to reflect changes in task update behavior.
This commit is contained in:
@@ -278,26 +278,17 @@ export class JiraService {
|
|||||||
taskTitle: jiraTask.summary
|
taskTitle: jiraTask.summary
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// Vérifier si mise à jour nécessaire (seulement si pas de modifs locales récentes)
|
// Toujours mettre à jour les données Jira (écrasement forcé)
|
||||||
const jiraUpdated = new Date(jiraTask.updated);
|
|
||||||
const localUpdated = existingTask.updatedAt;
|
|
||||||
|
|
||||||
// Si la tâche locale a été modifiée après la dernière update Jira, on skip
|
|
||||||
if (localUpdated > jiraUpdated) {
|
|
||||||
console.log(`⏭️ Tâche ${jiraTask.key} modifiée localement, skip mise à jour`);
|
|
||||||
return {
|
|
||||||
type: 'skipped',
|
|
||||||
taskKey: jiraTask.key,
|
|
||||||
taskTitle: jiraTask.summary,
|
|
||||||
reason: 'Modifiée localement après la dernière mise à jour Jira'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Détecter les changements et créer la liste des modifications
|
// Détecter les changements et créer la liste des modifications
|
||||||
const changes: string[] = [];
|
const changes: string[] = [];
|
||||||
|
|
||||||
|
// Préserver le titre et la priorité si modifiés localement
|
||||||
|
const finalTitle = existingTask.title !== taskData.title ? existingTask.title : taskData.title;
|
||||||
|
const finalPriority = existingTask.priority !== taskData.priority ? existingTask.priority : taskData.priority;
|
||||||
|
|
||||||
if (existingTask.title !== taskData.title) {
|
if (existingTask.title !== taskData.title) {
|
||||||
changes.push(`Titre: "${existingTask.title}" → "${taskData.title}"`);
|
changes.push(`Titre: préservé localement ("${existingTask.title}")`);
|
||||||
}
|
}
|
||||||
if (existingTask.description !== taskData.description) {
|
if (existingTask.description !== taskData.description) {
|
||||||
changes.push(`Description modifiée`);
|
changes.push(`Description modifiée`);
|
||||||
@@ -306,7 +297,7 @@ export class JiraService {
|
|||||||
changes.push(`Statut: ${existingTask.status} → ${taskData.status}`);
|
changes.push(`Statut: ${existingTask.status} → ${taskData.status}`);
|
||||||
}
|
}
|
||||||
if (existingTask.priority !== taskData.priority) {
|
if (existingTask.priority !== taskData.priority) {
|
||||||
changes.push(`Priorité: ${existingTask.priority} → ${taskData.priority}`);
|
changes.push(`Priorité: préservée localement (${existingTask.priority})`);
|
||||||
}
|
}
|
||||||
if ((existingTask.dueDate?.getTime() || null) !== (taskData.dueDate?.getTime() || null)) {
|
if ((existingTask.dueDate?.getTime() || null) !== (taskData.dueDate?.getTime() || null)) {
|
||||||
const oldDate = existingTask.dueDate ? existingTask.dueDate.toLocaleDateString() : 'Aucune';
|
const oldDate = existingTask.dueDate ? existingTask.dueDate.toLocaleDateString() : 'Aucune';
|
||||||
@@ -337,27 +328,27 @@ export class JiraService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mettre à jour seulement les champs Jira (pas les modifs locales)
|
// Mettre à jour les champs Jira (titre et priorité préservés si modifiés)
|
||||||
await prisma.task.update({
|
await prisma.task.update({
|
||||||
where: { id: existingTask.id },
|
where: { id: existingTask.id },
|
||||||
data: {
|
data: {
|
||||||
title: taskData.title,
|
title: finalTitle,
|
||||||
description: taskData.description,
|
description: taskData.description,
|
||||||
status: taskData.status,
|
status: taskData.status,
|
||||||
priority: taskData.priority,
|
priority: finalPriority,
|
||||||
dueDate: taskData.dueDate,
|
dueDate: taskData.dueDate,
|
||||||
jiraProject: taskData.jiraProject,
|
jiraProject: taskData.jiraProject,
|
||||||
jiraKey: taskData.jiraKey,
|
jiraKey: taskData.jiraKey,
|
||||||
jiraType: taskData.jiraType,
|
jiraType: taskData.jiraType,
|
||||||
assignee: taskData.assignee,
|
assignee: taskData.assignee,
|
||||||
updatedAt: taskData.updatedAt // Seulement si changements réels
|
updatedAt: taskData.updatedAt
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// S'assurer que le tag Jira est assigné (pour les anciennes tâches)
|
// S'assurer que le tag Jira est assigné (pour les anciennes tâches)
|
||||||
await this.assignJiraTag(existingTask.id);
|
await this.assignJiraTag(existingTask.id);
|
||||||
|
|
||||||
console.log(`🔄 Tâche mise à jour: ${jiraTask.key} (${changes.length} changement${changes.length > 1 ? 's' : ''})`);
|
console.log(`🔄 Tâche mise à jour (titre/priorité préservés): ${jiraTask.key} (${changes.length} changement${changes.length > 1 ? 's' : ''})`);
|
||||||
return {
|
return {
|
||||||
type: 'updated',
|
type: 'updated',
|
||||||
taskKey: jiraTask.key,
|
taskKey: jiraTask.key,
|
||||||
@@ -559,10 +550,10 @@ export class JiraService {
|
|||||||
'Complete': 'done',
|
'Complete': 'done',
|
||||||
|
|
||||||
// Statuts bloqués
|
// Statuts bloqués
|
||||||
'Validating': 'blocked', // Phase de validation
|
'Validating': 'freeze', // Phase de validation
|
||||||
'Blocked': 'blocked',
|
'Blocked': 'freeze',
|
||||||
'On Hold': 'blocked',
|
'On Hold': 'freeze',
|
||||||
'En attente du support': 'blocked' // Français - bloqué en attente
|
'En attente du support': 'freeze' // Français - bloqué en attente
|
||||||
};
|
};
|
||||||
|
|
||||||
return statusMapping[jiraStatus] || 'todo';
|
return statusMapping[jiraStatus] || 'todo';
|
||||||
|
|||||||
Reference in New Issue
Block a user