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

refactor(event): align event payloads with backend #645

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions src/features/events/state/eventsState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const selectRuns = (state: RootState): Run[] => {
const unique = Array.from(new Set(events.map(d => d.sessionID))).filter(id => id !== runId)

return unique.map((d) => {
return NewRunFromEventLog(d, events.filter(e => e.data.mode !== 'apply'))
return NewRunFromEventLog(d, events.filter(e => e.payload.mode !== 'apply'))
})
}

Expand All @@ -36,7 +36,7 @@ export const eventsReducer = createReducer(initialState, {

function addRunEvent (state: EventsState, action: EventLogAction) {
state.events.push(action.data)
state.events.sort((a, b) => a.ts - b.ts)
state.events.sort((a, b) => a.timestamp - b.timestamp)
}

function removeEvent (state: EventsState, action: RemoveEventAction) {
Expand Down
6 changes: 3 additions & 3 deletions src/features/workflow/output/LogLinePrint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ const LogLinePrint: React.FC<LogLineProps> = ({ line }) => {
switch (line.type) {
case EventLogLineType.ETPrint:
// TODO (b5) - utilize line.data.lvl to set output colour
return <p className='log_line_print_text text-sm whitespace-pre-wrap text-gray-500'>{line.data.msg}</p>
return <p className='log_line_print_text text-sm whitespace-pre-wrap text-gray-500'>{line.payload.msg}</p>
case EventLogLineType.ETError:
return <p className='text-sm whitespace-pre-wrap text-dangerred'>{line.data.msg}</p>
return <p className='text-sm whitespace-pre-wrap text-dangerred'>{line.payload.msg}</p>
default:
return <p className='whitespace-pre-wrap'>{line.data.msg}</p>
return <p className='whitespace-pre-wrap'>{line.payload.msg}</p>
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/features/workflow/output/Output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Output: React.FC<OutputProps> = ({ data, status, wasEdited }) => {
case EventLogLineType.ETError:
return <LogLinePrint key={i} line={line} />
case EventLogLineType.ETDatasetPreview:
return <DatasetPreview key={i} data={line.data as Dataset}/>
return <DatasetPreview key={i} data={line.payload as Dataset} />
default:
return <p key={i}>{JSON.stringify(line, undefined, 2)}</p>
}
Expand Down
8 changes: 4 additions & 4 deletions src/qri/eventLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ export enum EventLogLineType {

export interface EventLogLine {
type: EventLogLineType
ts: number
timestamp: number
sessionID: string
data: Record<string, any>
payload: Record<string, any>
}

export function NewEventLogLine (data: Record<string, any>): EventLogLine {
return {
type: data.type,
ts: data.ts,
timestamp: data.timestamp,
sessionID: data.sessionID,
data: data.data
payload: data.payload
}
}

Expand Down
22 changes: 11 additions & 11 deletions src/qri/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ export function runAddLogStep (run: Run, line: EventLogLine): Run {
switch (line.type) {
case EventLogLineType.ETTransformStart:
run.status = 'running'
run.initID = line.data.initID
run.startTime = new Date(toMilliFromNano(line.ts))
run.initID = line.payload.initID
run.startTime = new Date(toMilliFromNano(line.timestamp))
run.steps = []
break
case EventLogLineType.ETTransformStop:
run.initID = line.data.initID
run.status = line.data.status || 'failed'
run.stopTime = new Date(toMilliFromNano(line.ts))
run.initID = line.payload.initID
run.status = line.payload.status || 'failed'
run.stopTime = new Date(toMilliFromNano(line.timestamp))
if (run.startTime) {
run.duration = toNanoFromMilli(run.startTime?.getTime() - run.stopTime?.getTime())
}
Expand All @@ -90,16 +90,16 @@ export function runAddLogStep (run: Run, line: EventLogLine): Run {
if (run.steps === undefined) {
run.steps = []
}
const s = NewRunStep(line.data)
const s = NewRunStep(line.payload)
s.status = 'running'
s.startTime = new Date(line.ts)
s.startTime = new Date(line.timestamp)
run.steps.push(s)
break
case EventLogLineType.ETTransformStepStop:
const step = lastStep(run)
if (step) {
step.stopTime = new Date(line.ts)
step.status = line.data.status || 'failed'
step.stopTime = new Date(line.timestamp)
step.status = line.payload.status || 'failed'
if (step.startTime) {
step.duration = toNanoFromMilli(step.stopTime.getTime() - step.startTime.getTime())
}
Expand All @@ -109,7 +109,7 @@ export function runAddLogStep (run: Run, line: EventLogLine): Run {
if (run.steps === undefined) {
run.steps = []
}
run.steps.push(NewRunStep(line.data))
run.steps.push(NewRunStep(line.payload))
break

case EventLogLineType.ETPrint:
Expand All @@ -124,7 +124,7 @@ export function runAddLogStep (run: Run, line: EventLogLine): Run {
break

case EventLogLineType.ETDatasetPreview:
run.dsPreview = NewDataset(line.data)
run.dsPreview = NewDataset(line.payload)
}
return run
}
Expand Down