feat: implement project ignore list for Jira synchronization
- Updated `JiraConfigForm` to include an input for ignored projects, allowing users to specify projects to exclude from synchronization. - Enhanced `JiraService` with a method to filter out tasks from ignored projects, improving task management. - Modified user preferences to store ignored projects, ensuring persistence across sessions. - Updated API routes to handle ignored projects in configuration, enhancing overall functionality. - Marked the corresponding task as complete in TODO.md.
This commit is contained in:
@@ -10,6 +10,7 @@ export interface JiraConfig {
|
||||
baseUrl: string;
|
||||
email: string;
|
||||
apiToken: string;
|
||||
ignoredProjects?: string[]; // Liste des clés de projets à ignorer (ex: ["DEMO", "TEST"])
|
||||
}
|
||||
|
||||
export interface JiraSyncAction {
|
||||
@@ -56,6 +57,28 @@ export class JiraService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filtre les tâches Jira selon les projets ignorés
|
||||
*/
|
||||
private filterIgnoredProjects(jiraTasks: JiraTask[]): JiraTask[] {
|
||||
if (!this.config.ignoredProjects || this.config.ignoredProjects.length === 0) {
|
||||
return jiraTasks;
|
||||
}
|
||||
|
||||
const ignoredSet = new Set(this.config.ignoredProjects.map(p => p.toUpperCase()));
|
||||
|
||||
return jiraTasks.filter(task => {
|
||||
const projectKey = task.project.key.toUpperCase();
|
||||
const shouldIgnore = ignoredSet.has(projectKey);
|
||||
|
||||
if (shouldIgnore) {
|
||||
console.log(`🚫 Ticket ${task.key} ignoré (projet ${task.project.key} dans la liste d'exclusion)`);
|
||||
}
|
||||
|
||||
return !shouldIgnore;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les tickets assignés à l'utilisateur connecté avec pagination
|
||||
*/
|
||||
@@ -207,11 +230,15 @@ export class JiraService {
|
||||
|
||||
console.log(`📋 ${jiraTasks.length} tickets trouvés dans Jira`);
|
||||
|
||||
// Récupérer la liste des IDs Jira actuels pour le nettoyage
|
||||
const currentJiraIds = new Set(jiraTasks.map(task => task.id));
|
||||
// Filtrer les tâches selon les projets ignorés
|
||||
const filteredTasks = this.filterIgnoredProjects(jiraTasks);
|
||||
console.log(`🔽 ${filteredTasks.length} tickets après filtrage des projets ignorés (${jiraTasks.length - filteredTasks.length} ignorés)`);
|
||||
|
||||
// Récupérer la liste des IDs Jira actuels pour le nettoyage (après filtrage)
|
||||
const currentJiraIds = new Set(filteredTasks.map(task => task.id));
|
||||
|
||||
// Synchroniser chaque ticket
|
||||
for (const jiraTask of jiraTasks) {
|
||||
for (const jiraTask of filteredTasks) {
|
||||
try {
|
||||
const syncAction = await this.syncSingleTask(jiraTask);
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ const DEFAULT_PREFERENCES: UserPreferences = {
|
||||
enabled: false,
|
||||
baseUrl: '',
|
||||
email: '',
|
||||
apiToken: ''
|
||||
apiToken: '',
|
||||
ignoredProjects: []
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user