fix: update JiraService tag assignment and status mapping

- Changed comments to singular form for clarity regarding Jira tag assignment.
- Removed unused assignProjectTag method to streamline the JiraService.
- Enhanced status mapping with additional French translations for better localization.
This commit is contained in:
Julien Froidefond
2025-09-17 14:13:44 +02:00
parent c8119faead
commit 95df2ad257

View File

@@ -244,9 +244,8 @@ export class JiraService {
} }
}); });
// Assigner les tags Jira // Assigner le tag Jira
await this.assignJiraTag(newTask.id); await this.assignJiraTag(newTask.id);
await this.assignProjectTag(newTask.id, jiraTask.project.key);
console.log(` Nouvelle tâche créée: ${jiraTask.key}`); console.log(` Nouvelle tâche créée: ${jiraTask.key}`);
return 'created'; return 'created';
@@ -277,9 +276,8 @@ export class JiraService {
if (!hasChanges) { if (!hasChanges) {
console.log(`⏭️ Aucun changement pour ${jiraTask.key}, skip mise à jour`); 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.assignJiraTag(existingTask.id);
await this.assignProjectTag(existingTask.id, jiraTask.project.key);
return 'skipped'; 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.assignJiraTag(existingTask.id);
await this.assignProjectTag(existingTask.id, jiraTask.project.key);
console.log(`🔄 Tâche mise à jour: ${jiraTask.key}`); console.log(`🔄 Tâche mise à jour: ${jiraTask.key}`);
return 'updated'; 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<void> {
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 * Mappe un issue Jira vers le format JiraTask
*/ */
@@ -460,27 +407,38 @@ export class JiraService {
*/ */
private mapJiraStatusToInternal(jiraStatus: string): string { private mapJiraStatusToInternal(jiraStatus: string): string {
const statusMapping: Record<string, string> = { const statusMapping: Record<string, string> = {
// 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', 'To Do': 'todo',
'Open': 'todo', 'Open': 'todo',
'Backlog': 'todo', 'Ouvert': 'todo', // Français
'Selected for Development': 'todo', 'Selected for Development': 'todo',
'A faire': 'todo', // Français
// Statuts "In Progress" // Statuts "In Progress"
'In Progress': 'in_progress', 'In Progress': 'in_progress',
'En cours': 'in_progress', // Français
'In Review': 'in_progress', 'In Review': 'in_progress',
'Code Review': 'in_progress', 'Code Review': 'in_progress',
'Code review': 'in_progress', // Variante casse
'Testing': 'in_progress', 'Testing': 'in_progress',
'Validating': 'in_progress', // Phase de validation
// Statuts "Done" // Statuts "Done"
'Done': 'done', 'Done': 'done',
'Closed': 'done', 'Closed': 'done',
'Resolved': 'done', 'Resolved': 'done',
'Complete': 'done', 'Complete': 'done',
'Product Delivery': 'done', // Livré en prod
// Statuts bloqués // Statuts bloqués
'Blocked': 'blocked', 'Blocked': 'blocked',
'On Hold': 'blocked' 'On Hold': 'blocked',
'En attente du support': 'blocked' // Français - bloqué en attente
}; };
return statusMapping[jiraStatus] || 'todo'; return statusMapping[jiraStatus] || 'todo';