From 7ad7b7e6a57c4350ee459d83f37b8ff29eff2ca0 Mon Sep 17 00:00:00 2001 From: Benoit Verhaeghe Date: Fri, 26 Jul 2024 10:10:02 +0200 Subject: [PATCH] all tests are green now :) --- src/JiraPharoAPI/JiraPharoImporter.class.st | 26 +++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/JiraPharoAPI/JiraPharoImporter.class.st b/src/JiraPharoAPI/JiraPharoImporter.class.st index 273603f..495d4c2 100644 --- a/src/JiraPharoAPI/JiraPharoImporter.class.st +++ b/src/JiraPharoAPI/JiraPharoImporter.class.st @@ -25,6 +25,16 @@ JiraPharoImporter >> api: anObject [ api := anObject ] +{ #category : #'api - import' } +JiraPharoImporter >> ensureUser: aPotentialUser [ + "Search is user is already in model" + + (self model allWithType: JPUser) + detect: [ :user | user = aPotentialUser ] + ifOne: [ :userFromModel | ^ userFromModel ]. + ^ self model add: aPotentialUser +] + { #category : #'api - import' } JiraPharoImporter >> extractAllIssuesOf: aUsername [ @@ -66,18 +76,10 @@ JiraPharoImporter >> importAllIssuesOf: aUsername [ { #category : #'api - import' } JiraPharoImporter >> loadAssigneeForIssuesToLoad: issuesToLoad [ - | assigneeToLoad | - assigneeToLoad := issuesToLoad iterator - | [ :issue | issue assignee ] collectIt - | [ :assignee | assignee isNil ] rejectIt - | - [ :assignee | self model includes: assignee ] - rejectIt > Set. - assigneeToLoad do: [ :assignee | - (self model allWithType: JPIssue) - select: [ :issue | issue assignee = assignee ] - thenDo: [ :issue | issue assignee: assignee ] ]. - self model addAll: assigneeToLoad + issuesToLoad + reject: [ :issue | issue assignee isNil ] + thenDo: [ :issue | + issue assignee: (self ensureUser: issue assignee) ] ] { #category : #'api - import' }