Skip to content

Commit d694a89

Browse files
committed
refactor: clean up types in WorkspaceBuildLogs
1 parent afb806f commit d694a89

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

site/src/components/WorkspaceBuildLogs/WorkspaceBuildLogs.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ const Language = {
1010
}
1111

1212
type Stage = ProvisionerJobLog["stage"]
13+
type LogsGroupedByStage = Record<Stage, ProvisionerJobLog[]>
14+
type GroupLogsByStageFn = (logs: ProvisionerJobLog[]) => LogsGroupedByStage
1315

14-
const groupLogsByStage = (logs: ProvisionerJobLog[]) => {
15-
const logsByStage: Record<Stage, ProvisionerJobLog[]> = {}
16+
export const groupLogsByStage: GroupLogsByStageFn = (logs) => {
17+
const logsByStage: LogsGroupedByStage = {}
1618

1719
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]
2224
}
23-
24-
logsByStage[log.stage].push(log)
2525
}
2626

2727
return logsByStage

0 commit comments

Comments
 (0)