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
|
||||
};
|
||||
} else {
|
||||
// Vérifier si mise à jour nécessaire (seulement si pas de modifs locales récentes)
|
||||
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'
|
||||
};
|
||||
}
|
||||
// Toujours mettre à jour les données Jira (écrasement forcé)
|
||||
|
||||
// Détecter les changements et créer la liste des modifications
|
||||
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) {
|
||||
changes.push(`Titre: "${existingTask.title}" → "${taskData.title}"`);
|
||||
changes.push(`Titre: préservé localement ("${existingTask.title}")`);
|
||||
}
|
||||
if (existingTask.description !== taskData.description) {
|
||||
changes.push(`Description modifiée`);
|
||||
@@ -306,7 +297,7 @@ export class JiraService {
|
||||
changes.push(`Statut: ${existingTask.status} → ${taskData.status}`);
|
||||
}
|
||||
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)) {
|
||||
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({
|
||||
where: { id: existingTask.id },
|
||||
data: {
|
||||
title: taskData.title,
|
||||
title: finalTitle,
|
||||
description: taskData.description,
|
||||
status: taskData.status,
|
||||
priority: taskData.priority,
|
||||
priority: finalPriority,
|
||||
dueDate: taskData.dueDate,
|
||||
jiraProject: taskData.jiraProject,
|
||||
jiraKey: taskData.jiraKey,
|
||||
jiraType: taskData.jiraType,
|
||||
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)
|
||||
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 {
|
||||
type: 'updated',
|
||||
taskKey: jiraTask.key,
|
||||
@@ -559,10 +550,10 @@ export class JiraService {
|
||||
'Complete': 'done',
|
||||
|
||||
// Statuts bloqués
|
||||
'Validating': 'blocked', // Phase de validation
|
||||
'Blocked': 'blocked',
|
||||
'On Hold': 'blocked',
|
||||
'En attente du support': 'blocked' // Français - bloqué en attente
|
||||
'Validating': 'freeze', // Phase de validation
|
||||
'Blocked': 'freeze',
|
||||
'On Hold': 'freeze',
|
||||
'En attente du support': 'freeze' // Français - bloqué en attente
|
||||
};
|
||||
|
||||
return statusMapping[jiraStatus] || 'todo';
|
||||
|
||||
Reference in New Issue
Block a user