Skip to content

Commit

Permalink
Revert "feat: add estimated time for query execution (pinterest#1158)" (
Browse files Browse the repository at this point in the history
pinterest#1166)

This reverts commit 7a25679.
  • Loading branch information
czgu authored and rohan-sh1 committed Apr 11, 2023
1 parent 95c8e4d commit be0fa1b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@
.statement-execution-progress-wrapper {
margin-bottom: 10px;

.ProgressBar {
flex: 1;
}
.progress-text {
flex: 1;
progress {
width: 40%;
display: inline-block;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import moment from 'moment';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';

Expand All @@ -9,7 +8,6 @@ import {
import { StatementExecutionDefaultResultSize } from 'const/queryResultLimit';
import { useToggleState } from 'hooks/useToggleState';
import { sanitizeAndExtraMarkdown } from 'lib/markdown';
import { formatDuration } from 'lib/utils/datetime';
import { fetchResult } from 'redux/queryExecutions/action';
import { IStoreState } from 'redux/store/types';
import { Icon } from 'ui/Icon/Icon';
Expand Down Expand Up @@ -135,51 +133,21 @@ export const DataDocStatementExecution: React.FC<IProps> = ({
<span className="statement-status-label">Initializing</span>
);
} else if (status === StatementExecutionStatus.RUNNING) {
const { created_at: createdAt } = statementExecution;
const percentComplete = statementExecution.percent_complete ?? 0;

const statusLabel = (
<span className="statement-status-label">Running</span>
);

const estimatedTimeText = (() => {
let progressMessage = `${Math.floor(percentComplete || 0)}%`;

if (
percentComplete == null ||
percentComplete === 0 ||
percentComplete === 100
) {
return progressMessage;
}

const secondsPassedSinceStart =
new Date().getTime() / 1000 - createdAt;
const secondsRemainToComplete =
secondsPassedSinceStart / (percentComplete / 100) -
secondsPassedSinceStart;
const durationToComplete = formatDuration(
moment.duration(secondsRemainToComplete, 'seconds')
);

progressMessage += ` (${durationToComplete} Remaining)`;

return progressMessage;
})();

const progressBar = (
<div className="statement-execution-progress-wrapper flex-row">
const percentComplete = statementExecution.percent_complete;
const statusLabel =
status === StatementExecutionStatus.RUNNING ? (
<span className="statement-status-label">Running</span>
) : null;
const progressBar = status === StatementExecutionStatus.RUNNING && (
<div className="statement-execution-progress-wrapper">
<ProgressBar
value={percentComplete}
showValue
isSmall
type="success"
/>
<AccentText className="progress-text">
{estimatedTimeText}
</AccentText>
</div>
);

contentDOM = (
<div className="statement-execution-text-container">
<div className="statement-execution-text-title">
Expand Down

0 comments on commit be0fa1b

Please sign in to comment.