Skip to content

refactor: clean up WorkspaceBuildLogs types #4738

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

Merged
merged 3 commits into from
Oct 25, 2022
Merged
Changes from 1 commit
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
Next Next commit
refactor: clean up types in WorkspaceBuildLogs
  • Loading branch information
jsjoeio committed Oct 24, 2022
commit d694a89aa64dbe4db87f8e4595b01ddc2b8429d6
16 changes: 8 additions & 8 deletions site/src/components/WorkspaceBuildLogs/WorkspaceBuildLogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ const Language = {
}

type Stage = ProvisionerJobLog["stage"]
type LogsGroupedByStage = Record<Stage, ProvisionerJobLog[]>
type GroupLogsByStageFn = (logs: ProvisionerJobLog[]) => LogsGroupedByStage

const groupLogsByStage = (logs: ProvisionerJobLog[]) => {
const logsByStage: Record<Stage, ProvisionerJobLog[]> = {}
export const groupLogsByStage: GroupLogsByStageFn = (logs) => {
const logsByStage: LogsGroupedByStage = {}

for (const log of logs) {
// If there is no log in the stage record, add an empty array
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (logsByStage[log.stage] === undefined) {
logsByStage[log.stage] = []
if (log.stage in logsByStage) {
logsByStage[log.stage].push(log)
} else {
logsByStage[log.stage] = [log]
}

logsByStage[log.stage].push(log)
}

return logsByStage
Expand Down