File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
site/src/components/WorkspaceBuildLogs Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -10,18 +10,18 @@ const Language = {
10
10
}
11
11
12
12
type Stage = ProvisionerJobLog [ "stage" ]
13
+ type LogsGroupedByStage = Record < Stage , ProvisionerJobLog [ ] >
14
+ type GroupLogsByStageFn = ( logs : ProvisionerJobLog [ ] ) => LogsGroupedByStage
13
15
14
- const groupLogsByStage = ( logs : ProvisionerJobLog [ ] ) => {
15
- const logsByStage : Record < Stage , ProvisionerJobLog [ ] > = { }
16
+ export const groupLogsByStage : GroupLogsByStageFn = ( logs ) => {
17
+ const logsByStage : LogsGroupedByStage = { }
16
18
17
19
for ( const log of logs ) {
18
- // If there is no log in the stage record, add an empty array
19
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
20
- if ( logsByStage [ log . stage ] === undefined ) {
21
- logsByStage [ log . stage ] = [ ]
20
+ if ( log . stage in logsByStage ) {
21
+ logsByStage [ log . stage ] . push ( log )
22
+ } else {
23
+ logsByStage [ log . stage ] = [ log ]
22
24
}
23
-
24
- logsByStage [ log . stage ] . push ( log )
25
25
}
26
26
27
27
return logsByStage
You can’t perform that action at this time.
0 commit comments