Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring/metrics interface #10

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 42 additions & 14 deletions src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,36 @@ GitMetricExporter >> addDelayUntilFirstChurnExporter: exportBrowserModel [

{ #category : #'as yet unclassified' }
GitMetricExporter >> addEntitiesFromUserNames: userNames [
"import all the project since a certain time"

'Import all projects from the Git repository' recordInfo.
projectCache := projectCache ifNil: [
glhImporter importProjectsSince: sinceTimeLimit ].

"then collect the project in which the user has be seen commited"
entities addAll: (userNames collect: [ :username |
| projects metrics |
projects := self findProjectsOfUser: username inside: projectCache.
| projects metrics i size |
projects := self findCommitAuthorNamed: username amongProjects: projectCache.

metrics := GitMetric4User new.
metrics
glhImporter: glhImporter;
findUserNamed: username.




i := 0.
size := projects size.
metrics itsProjects: (projects collect: [ :p |
MyLogs logProgress: 'complete import of project #' over: projects.

(' ' join: {
'complete import of project:'.
p name printString.
'['.
(i := i + 1) printString.
'/'.
size.
']' }) recordInfo.

p id -> (glhImporter completeImportProject: p) ]) asDictionary.

metrics ]).
Expand Down Expand Up @@ -382,26 +396,40 @@ GitMetricExporter >> exportOver: aCollectionOfDateWeekMonthOrYear [
'Done computing' recordInfo
]

{ #category : #'as yet unclassified' }
GitMetricExporter >> findProjectsOfUser: aCollection [
self shouldBeImplemented.
]

{ #category : #projects }
GitMetricExporter >> findProjectsOfUser: username inside: aCollectionOfProjects [
GitMetricExporter >> findCommitAuthorNamed: username amongProjects: aCollectionOfProjects [

| response itsProjects |
| response itsProjects i size |
i := 1.
size := aCollectionOfProjects size.
itsProjects := aCollectionOfProjects select: [ :project |
(' ' join: {
'search'.
username printString.
'in Project:'.
project name printString.
'['.
(i := i + 1) printString.
'/'.
size.
']' }) recordInfo.

response := glhImporter glhApi
commitsOfUser: username
inProject: project id since: '01 january 2023' asDateAndTime until: '24 may 2024' asDateAndTime.
inProject: project id
since: '01 january 2023' asDateAndTime
until: '24 may 2024' asDateAndTime.
response := glhImporter parseCommitsResult: response.

response isNotEmpty ].

^ itsProjects
]

{ #category : #'as yet unclassified' }
GitMetricExporter >> findProjectsOfUser: aCollection [
self shouldBeImplemented.
]

{ #category : #accessing }
GitMetricExporter >> glhImporter: anImporter [

Expand Down
3 changes: 2 additions & 1 deletion src/GitLabHealth-Model-Importer/GLHModelImporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ GLHModelImporter >> importProjectsSince: since [
"copy import from commits"

| newlyFoundProjects page foundProject amount |
'import all Projects into the model' recordInfo.
('import all Projects since: ', since printString) recordInfo.

"number of projects per page"
amount := 100.
Expand All @@ -708,6 +708,7 @@ GLHModelImporter >> importProjectsSince: since [
| results |
page := page + 1.
('import projects page #' , page printString) recordInfo.

results := self glhApi projects: amount since: since page: page.

newlyFoundProjects := glhModel
Expand Down
Loading