Skip to content

Commit

Permalink
Use the UploadProgress in the ingest file flow
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskerr committed Nov 20, 2020
1 parent 760d373 commit 332f3b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/js/flows/getZealot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ConnectionStatuses from "../state/ConnectionStatuses"

const createBrimFetcher = (dispatch, getState) => {
return (hostPort: string) => {
const {promise, stream} = createFetcher(hostPort)
const {promise, ...rest} = createFetcher(hostPort)

const wrappedPromise = (args: FetchArgs): Promise<any> => {
return promise(args).catch((e) => {
Expand All @@ -22,7 +22,7 @@ const createBrimFetcher = (dispatch, getState) => {
})
}

return {promise: wrappedPromise, stream}
return {promise: wrappedPromise, ...rest}
}
}

Expand Down
14 changes: 3 additions & 11 deletions src/js/flows/ingestFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,6 @@ const trackProgress = (client, gDispatch, clusterId) => {
else return status.pcap_read_size / status.pcap_total_size || 0
}

function logPostStatusToPercent(status): number {
// log_total_size may not be present
if (!status.log_total_size) return 1
else return status.log_read_size / status.log_total_size
}

gDispatch(space.setIngestProgress(0))
for await (const {type, ...status} of stream) {
switch (type) {
Expand All @@ -167,14 +161,13 @@ const trackProgress = (client, gDispatch, clusterId) => {
gDispatch(space.setIngestSnapshot(status.snapshot_count))
if (status.snapshot_count > 0) updateSpaceDetails()
break
case "LogPostStatus":
gDispatch(space.setIngestProgress(logPostStatusToPercent(status)))
case "UploadProgress":
gDispatch(space.setIngestProgress(status.progress))
updateSpaceDetails()
break
case "LogPostResponse":
console.log(status)
updateSpaceDetails()
;(status.warnings || []).forEach((warning) => {
status.warnings.forEach((warning) => {
gDispatch(space.appendIngestWarning(warning))
})
break
Expand All @@ -190,7 +183,6 @@ const trackProgress = (client, gDispatch, clusterId) => {
throw errors.logsIngest(status.error.error)
}
}

break
}
}
Expand Down

0 comments on commit 332f3b5

Please sign in to comment.