Skip to content

Commit 8f4ddfa

Browse files
authored
Merge pull request #215 from moosetechnology/fix-commit-distributions
fixing commit not sort and comparing commit within different time zone
2 parents dca6e70 + ce0f3ed commit 8f4ddfa

9 files changed

+579
-576
lines changed
Lines changed: 80 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,80 @@
1-
Class {
2-
#name : #GLHCommitDistributionVisualization,
3-
#superclass : #MiAbstractVisualization,
4-
#instVars : [
5-
'groupCommitBlock'
6-
],
7-
#category : #'GitLabHealth-Model-Visualization'
8-
}
9-
10-
{ #category : #'instance creation' }
11-
GLHCommitDistributionVisualization >> forCommits: commits [
12-
13-
| c lb oldestCommit horizontal commitGroups groupToCommitByDate alreadyAdded dates |
14-
c := RSCompositeChart new.
15-
commits ifEmpty: [ ^ c canvas].
16-
oldestCommit := commits last.
17-
dates := (oldestCommit committed_date to: Date today) dates.
18-
19-
commitGroups := commits groupedBy: self groupCommitBlock.
20-
21-
groupToCommitByDate := commitGroups associations collect: [ :assoc |
22-
assoc key -> (dates collect: [ :date |
23-
date
24-
->
25-
(assoc value select: [ :commit |
26-
commit committed_date asDate = date ]) ]) ].
27-
28-
alreadyAdded := dates collect: [ :d | 0 ].
29-
groupToCommitByDate do: [ :assocGroupToCommitByDate |
30-
| chart |
31-
chart := (RSAbstractChart barHeights:
32-
(assocGroupToCommitByDate value collect: [ :dateToCommit |
33-
dateToCommit value size ])) bottom: alreadyAdded.
34-
c add: chart.
35-
alreadyAdded := chart yValues ].
36-
37-
horizontal := c horizontalTick fromNames:
38-
(dates collect: [ :date | date printString ]).
39-
horizontal configuration fontSize: 2.
40-
horizontal useDiagonalLabel.
41-
c verticalTick integer.
42-
c ylabel: 'Number of commits'.
43-
c title: 'Number of commits by date'.
44-
c build.
45-
lb := RSLegend new.
46-
lb layout vertical.
47-
commitGroups keys doWithIndex: [ :groupObject :index |
48-
lb
49-
text: groupObject fullDisplayString
50-
withBoxColor: (c plots at: index) computeColor ].
51-
lb container: c canvas.
52-
lb location
53-
right;
54-
middle;
55-
offset: 10 @ 0.
56-
lb build.
57-
^ c canvas
58-
]
59-
60-
{ #category : #'as yet unclassified' }
61-
GLHCommitDistributionVisualization >> groupCommitBlock [
62-
63-
^ groupCommitBlock
64-
]
65-
66-
{ #category : #'as yet unclassified' }
67-
GLHCommitDistributionVisualization >> groupCommitBlock: anObject [
68-
69-
groupCommitBlock := anObject
70-
]
71-
72-
{ #category : #initialization }
73-
GLHCommitDistributionVisualization >> initialize [
74-
75-
super initialize.
76-
groupCommitBlock := [ :commit | commit commitCreator ]
77-
]
1+
Class {
2+
#name : #GLHCommitDistributionVisualization,
3+
#superclass : #MiAbstractVisualization,
4+
#instVars : [
5+
'groupCommitBlock'
6+
],
7+
#category : #'GitLabHealth-Model-Visualization'
8+
}
9+
10+
{ #category : #'instance creation' }
11+
GLHCommitDistributionVisualization >> forCommits: aCommitsCollection [
12+
13+
| c lb horizontal commitGroups groupToCommitByDate alreadyAdded dates commits|
14+
c := RSCompositeChart new.
15+
aCommitsCollection ifEmpty: [ ^ c canvas].
16+
commits := (aCommitsCollection sort: [ :c1 :c2 | c1 committed_date > c2 committed_date ]).
17+
"collect dates from oldest to youngest among commits"
18+
dates := (commits last committed_date to: commits first committed_date) dates.
19+
20+
"default is group by commitCreator (initialize)"
21+
commitGroups := commits groupedBy: self groupCommitBlock.
22+
23+
groupToCommitByDate := commitGroups associations collect: [ :assoc |
24+
assoc key -> (dates collect: [ :date |
25+
date
26+
->
27+
(assoc value select: [ :commit |
28+
"weird, but only way I know to compare two dates with different timezone."
29+
commit committed_date asDate asString = date asString ]) ]) ].
30+
31+
alreadyAdded := dates collect: [ :d | 0 ].
32+
groupToCommitByDate do: [ :assocGroupToCommitByDate |
33+
| chart |
34+
chart := (RSAbstractChart barHeights:
35+
(assocGroupToCommitByDate value collect: [ :dateToCommit |
36+
dateToCommit value size ])) bottom: alreadyAdded.
37+
c add: chart.
38+
alreadyAdded := alreadyAdded + chart yValues ].
39+
40+
horizontal := c horizontalTick fromNames:
41+
(dates collect: [ :date | date printString ]).
42+
horizontal configuration fontSize: 10.
43+
horizontal useDiagonalLabel.
44+
c verticalTick integer.
45+
c ylabel: 'Number of commits'.
46+
c title: 'Number of commits by date'.
47+
c build.
48+
lb := RSLegend new.
49+
lb layout vertical.
50+
commitGroups keys doWithIndex: [ :groupObject :index |
51+
lb
52+
text: groupObject fullDisplayString
53+
withBoxColor: (c plots at: index) computeColor ].
54+
lb container: c canvas.
55+
lb location
56+
right;
57+
middle;
58+
offset: 10 @ 0.
59+
lb build.
60+
^ c canvas
61+
]
62+
63+
{ #category : #'as yet unclassified' }
64+
GLHCommitDistributionVisualization >> groupCommitBlock [
65+
66+
^ groupCommitBlock
67+
]
68+
69+
{ #category : #'as yet unclassified' }
70+
GLHCommitDistributionVisualization >> groupCommitBlock: anObject [
71+
72+
groupCommitBlock := anObject
73+
]
74+
75+
{ #category : #initialization }
76+
GLHCommitDistributionVisualization >> initialize [
77+
78+
super initialize.
79+
groupCommitBlock := [ :commit | commit commitCreator ]
80+
]
Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
1-
Class {
2-
#name : #GLHCommitHiedraVisualization,
3-
#superclass : #SpPresenter,
4-
#instVars : [
5-
'groupCommitBlock',
6-
'hiedraColumnController',
7-
'ancestorIds'
8-
],
9-
#category : #'GitLabHealth-Model-Visualization'
10-
}
11-
12-
{ #category : #'instance creation' }
13-
GLHCommitHiedraVisualization >> forCommits: commits [
14-
15-
| table |
16-
table := self newTable.
17-
table items: commits.
18-
self initializeHiedraColumnForCommits: commits.
19-
table
20-
addColumn: (SpImageTableColumn evaluated: [ :item |
21-
hiedraColumnController cellMorphAtValue: item ]);
22-
addColumn: (SpStringTableColumn evaluated: [ :item | item message ]);
23-
addColumn: (SpStringTableColumn evaluated: [:commit | String streamContents:[:str | commit committed_date asDate printOn: str format: #(1 2 3 $ 2 2) ] ]).
24-
hiedraColumnController ruler:
25-
(HiRulerBuilder newRulerValues: commits linksBlock: [ :aCommit |
26-
(aCommit parentCommits collect: #id) collect: [ :id |
27-
commits detect: [ :each | each id = id ] ] ]).
28-
hiedraColumnController reset.
29-
"After #reset, we know the desired width for the column."
30-
table columns first width: hiedraColumnController rulerWidth.
31-
table columns last width: 75.
32-
^ table
33-
]
34-
35-
{ #category : #initialization }
36-
GLHCommitHiedraVisualization >> initialize [
37-
38-
super initialize.
39-
]
40-
41-
{ #category : #'as yet unclassified' }
42-
GLHCommitHiedraVisualization >> initializeHiedraColumnForCommits: commits [
43-
44-
hiedraColumnController := HiColumnController new.
45-
hiedraColumnController renderer
46-
linkWidth: 3.5;
47-
nodeRadius: 1.5;
48-
nodeBorderWidth: 3.0;
49-
arrowSize: 0;
50-
nodeConnectionOffset: 3;
51-
cellWidth: 8";
52-
useUniformColorStrategy".
53-
"Adjust the ruler rendering settings with table's row height."
54-
hiedraColumnController renderer rowHeight:
55-
FTTableMorph defaultRowHeight floor
56-
]
1+
Class {
2+
#name : #GLHCommitHiedraVisualization,
3+
#superclass : #SpPresenter,
4+
#instVars : [
5+
'groupCommitBlock',
6+
'hiedraColumnController',
7+
'ancestorIds'
8+
],
9+
#category : #'GitLabHealth-Model-Visualization'
10+
}
11+
12+
{ #category : #'instance creation' }
13+
GLHCommitHiedraVisualization >> forCommits: commits [
14+
15+
| table |
16+
table := self newTable.
17+
table items: commits.
18+
self initializeHiedraColumnForCommits: commits.
19+
table
20+
addColumn: (SpImageTableColumn evaluated: [ :item |
21+
hiedraColumnController cellMorphAtValue: item ]);
22+
addColumn: (SpStringTableColumn evaluated: [ :item | item message ]);
23+
addColumn: (SpStringTableColumn evaluated: [:commit | String streamContents:[:str | commit committed_date asDate printOn: str format: #(1 2 3 $ 2 2) ] ]).
24+
hiedraColumnController ruler:
25+
(HiRulerBuilder newRulerValues: commits linksBlock: [ :aCommit |
26+
(aCommit parentCommits collect: #id) collect: [ :id |
27+
commits detect: [ :each | each id = id ] ] ]).
28+
hiedraColumnController reset.
29+
"After #reset, we know the desired width for the column."
30+
table columns first width: hiedraColumnController rulerWidth.
31+
table columns last width: 75.
32+
^ table
33+
]
34+
35+
{ #category : #initialization }
36+
GLHCommitHiedraVisualization >> initialize [
37+
38+
super initialize.
39+
]
40+
41+
{ #category : #'as yet unclassified' }
42+
GLHCommitHiedraVisualization >> initializeHiedraColumnForCommits: commits [
43+
44+
hiedraColumnController := HiColumnController new.
45+
hiedraColumnController renderer
46+
linkWidth: 3.5;
47+
nodeRadius: 1.5;
48+
nodeBorderWidth: 3.0;
49+
arrowSize: 0;
50+
nodeConnectionOffset: 3;
51+
cellWidth: 8";
52+
useUniformColorStrategy".
53+
"Adjust the ruler rendering settings with table's row height."
54+
hiedraColumnController renderer rowHeight:
55+
FTTableMorph defaultRowHeight floor
56+
]
Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
1-
Class {
2-
#name : #GLHGroupCSVExporter,
3-
#superclass : #MiAbstractVisualization,
4-
#category : #'GitLabHealth-Model-Visualization'
5-
}
6-
7-
{ #category : #running }
8-
GLHGroupCSVExporter >> forGroup: aGLHGroup [
9-
^String streamContents: [ :output |
10-
self headerLineOn: output.
11-
self forGroup: aGLHGroup on: output ]
12-
]
13-
14-
{ #category : #running }
15-
GLHGroupCSVExporter >> forGroup: aGLHGroup on: outputStream [
16-
17-
(aGLHGroup allToScope: GLHGroup) do: [ :group |
18-
group projects do: [ :project |
19-
self forProject: project inGroup: aGLHGroup onStream: outputStream ]
20-
]
21-
]
22-
23-
{ #category : #running }
24-
GLHGroupCSVExporter >> forProject: aGHLProject inGroup: aGLHGroup onStream: outputStream [
25-
26-
outputStream
27-
<< $" ;
28-
<< aGLHGroup name ;
29-
<< '","' ;
30-
<< aGHLProject name ;
31-
<< '","' ;
32-
<< (self pipelineResult: aGHLProject) ;
33-
<< '",' ;
34-
<< aGHLProject lastPipelineDate asDate ddmmyyyy ;
35-
cr
36-
]
37-
38-
{ #category : #running }
39-
GLHGroupCSVExporter >> headerLineOn: outputStream [
40-
41-
outputStream
42-
<< '"Group","Project","CI result","Date"' ;
43-
cr
44-
]
45-
46-
{ #category : #running }
47-
GLHGroupCSVExporter >> pipelineResult: aGHLProject [
48-
49-
^aGHLProject lastPipeline
50-
ifNil: [ #noCI ]
51-
ifNotNil: [ :lastPipeline |
52-
(lastPipeline status = #success)
53-
ifTrue: [ #passed ]
54-
ifFalse: [ #failed ]
55-
]
56-
57-
]
1+
Class {
2+
#name : #GLHGroupCSVExporter,
3+
#superclass : #MiAbstractVisualization,
4+
#category : #'GitLabHealth-Model-Visualization'
5+
}
6+
7+
{ #category : #running }
8+
GLHGroupCSVExporter >> forGroup: aGLHGroup [
9+
^String streamContents: [ :output |
10+
self headerLineOn: output.
11+
self forGroup: aGLHGroup on: output ]
12+
]
13+
14+
{ #category : #running }
15+
GLHGroupCSVExporter >> forGroup: aGLHGroup on: outputStream [
16+
17+
(aGLHGroup allToScope: GLHGroup) do: [ :group |
18+
group projects do: [ :project |
19+
self forProject: project inGroup: aGLHGroup onStream: outputStream ]
20+
]
21+
]
22+
23+
{ #category : #running }
24+
GLHGroupCSVExporter >> forProject: aGHLProject inGroup: aGLHGroup onStream: outputStream [
25+
26+
outputStream
27+
<< $" ;
28+
<< aGLHGroup name ;
29+
<< '","' ;
30+
<< aGHLProject name ;
31+
<< '","' ;
32+
<< (self pipelineResult: aGHLProject) ;
33+
<< '",' ;
34+
<< aGHLProject lastPipelineDate asDate ddmmyyyy ;
35+
cr
36+
]
37+
38+
{ #category : #running }
39+
GLHGroupCSVExporter >> headerLineOn: outputStream [
40+
41+
outputStream
42+
<< '"Group","Project","CI result","Date"' ;
43+
cr
44+
]
45+
46+
{ #category : #running }
47+
GLHGroupCSVExporter >> pipelineResult: aGHLProject [
48+
49+
^aGHLProject lastPipeline
50+
ifNil: [ #noCI ]
51+
ifNotNil: [ :lastPipeline |
52+
(lastPipeline status = #success)
53+
ifTrue: [ #passed ]
54+
ifFalse: [ #failed ]
55+
]
56+
57+
]

0 commit comments

Comments
 (0)