diff --git a/services/jira.ts b/services/jira.ts index 48ef4f3..9f45725 100644 --- a/services/jira.ts +++ b/services/jira.ts @@ -244,9 +244,8 @@ export class JiraService { } }); - // Assigner les tags Jira + // Assigner le tag Jira await this.assignJiraTag(newTask.id); - await this.assignProjectTag(newTask.id, jiraTask.project.key); console.log(`➕ Nouvelle tâche créée: ${jiraTask.key}`); return 'created'; @@ -277,9 +276,8 @@ export class JiraService { if (!hasChanges) { console.log(`⏭️ Aucun changement pour ${jiraTask.key}, skip mise à jour`); - // S'assurer que les tags Jira sont assignés (pour les anciennes tâches) même en skip + // S'assurer que le tag Jira est assigné (pour les anciennes tâches) même en skip await this.assignJiraTag(existingTask.id); - await this.assignProjectTag(existingTask.id, jiraTask.project.key); return 'skipped'; } @@ -302,9 +300,8 @@ export class JiraService { } }); - // S'assurer que les tags Jira sont assignés (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.assignProjectTag(existingTask.id, jiraTask.project.key); console.log(`🔄 Tâche mise à jour: ${jiraTask.key}`); return 'updated'; @@ -354,56 +351,6 @@ export class JiraService { } } - /** - * Assigne un tag de projet Jira à une tâche (crée le tag si nécessaire) - */ - private async assignProjectTag(taskId: string, projectKey: string): Promise { - try { - const tagName = `📋 ${projectKey}`; - - // Vérifier si le tag projet existe déjà - let projectTag = await prisma.tag.findUnique({ - where: { name: tagName } - }); - - if (!projectTag) { - // Créer le tag projet s'il n'existe pas - projectTag = await prisma.tag.create({ - data: { - name: tagName, - color: '#4F46E5', // Violet pour les projets - isPinned: false - } - }); - console.log(`✅ Tag projet "${tagName}" créé automatiquement`); - } - - // Vérifier si le tag est déjà assigné - const existingAssignment = await prisma.taskTag.findUnique({ - where: { - taskId_tagId: { - taskId: taskId, - tagId: projectTag.id - } - } - }); - - if (!existingAssignment) { - // Créer l'assignation du tag - await prisma.taskTag.create({ - data: { - taskId: taskId, - tagId: projectTag.id - } - }); - console.log(`🏷️ Tag projet "${tagName}" assigné à la tâche`); - } - } catch (error) { - console.error('Erreur lors de l\'assignation du tag projet:', error); - // Ne pas faire échouer la sync pour un problème de tag - } - } - /** * Mappe un issue Jira vers le format JiraTask */ @@ -460,27 +407,38 @@ export class JiraService { */ private mapJiraStatusToInternal(jiraStatus: string): string { const statusMapping: Record = { - // Statuts "To Do" + // Statuts "Backlog" (pas encore priorisés) + 'Backlog': 'backlog', + 'Product backlog': 'backlog', + 'Product Discovery': 'backlog', // Phase de découverte + + // Statuts "To Do" (priorisés, prêts à développer) 'To Do': 'todo', 'Open': 'todo', - 'Backlog': 'todo', + 'Ouvert': 'todo', // Français 'Selected for Development': 'todo', + 'A faire': 'todo', // Français // Statuts "In Progress" 'In Progress': 'in_progress', + 'En cours': 'in_progress', // Français 'In Review': 'in_progress', 'Code Review': 'in_progress', + 'Code review': 'in_progress', // Variante casse 'Testing': 'in_progress', + 'Validating': 'in_progress', // Phase de validation // Statuts "Done" 'Done': 'done', 'Closed': 'done', 'Resolved': 'done', 'Complete': 'done', + 'Product Delivery': 'done', // Livré en prod // Statuts bloqués 'Blocked': 'blocked', - 'On Hold': 'blocked' + 'On Hold': 'blocked', + 'En attente du support': 'blocked' // Français - bloqué en attente }; return statusMapping[jiraStatus] || 'todo';