Skip to content

Commit

Permalink
fix(GLHModelImporter): small bug when running main script
Browse files Browse the repository at this point in the history
  • Loading branch information
knowbased committed Jan 9, 2025
1 parent 43f1725 commit 6f20239
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
43 changes: 22 additions & 21 deletions src/GitLabHealth-Model-Importer/GLHModelImporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,12 @@ GLHModelImporter >> importAllGroups [
^ groups
]

{ #category : #'as yet unclassified' }
{ #category : #commits }
GLHModelImporter >> importAndLoadLatestsCommitsOfProject: aGLHProject [

| commits |
self completeImportProject: aGLHProject.
commits := self importLastestCommitsOfProject: aGLHProject.
| commits completedProject |
completedProject := self completeImportProject: aGLHProject.
commits := self importLastestCommitsOfProject: completedProject.
commits do: [ :commit | self completeImportedCommit: commit ].
self chainsCommitsFrom: commits.
^ commits
Expand Down Expand Up @@ -413,23 +413,25 @@ GLHModelImporter >> importCommitsOfProject: aProject since: fromDate until: toDa
GLHModelImporter >> importContributedProjectsOfUser: aGLHUser [

| remaningProjects params results projects |
params := {
#order_by -> 'last_activity_at'.
#simple -> 'true'.
} asDictionary.
results := self repoApi projects contributedProjectsOfUser: aGLHUser id withParams: params.

projects := (results collect: [ :projectsJson | self parseArrayOfProject: projectsJson ]) flattened.

self glhModel
addAll: projects
unless: self blockOnIdEquality.

params := {
(#order_by -> 'last_activity_at').
(#simple -> 'true') } asDictionary.
results := self repoApi projects
contributedProjectsOfUser: aGLHUser id
withParams: params.

projects := (results collect: [ :projectsJson |
self parseArrayOfProject: projectsJson ]) flattened.
projects := self glhModel
addAll: projects
unless: self blockOnIdEquality.

remaningProjects := self importProjects:
((projects collect: #id) difference:
((self userCatalogue atId: aGLHUser id) at:
#contributedProjects)).


aGLHUser contributedProjects
addAll: projects , remaningProjects
unless: self blockOnIdEquality.
Expand Down Expand Up @@ -714,12 +716,11 @@ GLHModelImporter >> importUserByUsername: anUsername [
result := self repoApi users allWithParams: params.

"when result is an error"
result isArray ifFalse: [ result := { result } ].
(result isCollection not and: result isEmpty) ifTrue: [ result := { result } ].

searchResult := (result collect: [ :usersJson |
NeoJSONReader fromString: usersJson ])
first.

searchResult := result ifEmpty: [ result ] ifNotEmpty: [(result collect: [ :usersJson |
NeoJSONReader fromString: usersJson ]) first].

(searchResult class = Dictionary and: [
(searchResult at: #message) includesSubstring:
'403 Forbidden' ])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ GLPHModelImporter >> commitsOfProject: aGLHProject forRefName: refName until: to

{ #category : #'private - api' }
GLPHModelImporter >> completeImportProject: aGLHProject [
|completedProject|
completedProject := super completeImportProject: aGLHProject.

| completedProject |
completedProject := super completeImportProject: aGLHProject.
"for this initial import, with only look at some but not all MR"
withInitialMergeRequest ifTrue: [ self
importMergeRequests: completedProject
since: DateAndTime today
until: DateAndTime now. ].
withInitialMergeRequest ifTrue: [
self
importMergeRequests: completedProject
since: DateAndTime today
until: DateAndTime now ].

^ completedProject
]
Expand Down

0 comments on commit 6f20239

Please sign in to comment.