Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
Signed-off-by: abbyhu2000 <[email protected]>
  • Loading branch information
abbyhu2000 committed Sep 19, 2024
1 parent b2cc481 commit a67c564
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export function QueryResult(props: { queryStatus: QueryStatus }) {
setPopover(!isPopoverOpen);
};

const getTime = () => {
const time = new Date().getTime() - props.queryStatus.startTime!;
const updateElapsedTime = () => {
const time = Date.now() - (props.queryStatus.startTime || 0);
if (time > BUFFER_TIME) {
setElapsedTime(time);
} else {
Expand All @@ -51,7 +51,7 @@ export function QueryResult(props: { queryStatus: QueryStatus }) {
};

useEffect(() => {
const interval = setInterval(getTime, 1000);
const interval = setInterval(updateElapsedTime, 1000);

return () => clearInterval(interval);
});
Expand All @@ -69,19 +69,30 @@ export function QueryResult(props: { queryStatus: QueryStatus }) {
isLoading
data-test-subj="queryResultLoading"
>
{`Loading ${time} s`}
{i18n.translate('data.query.languageService.queryResults.completeTime', {
defaultMessage: `Loading ${time} s`,
})}
</EuiButtonEmpty>
);
}

if (props.queryStatus.status === ResultStatus.READY) {
let message;
if (!props.queryStatus.elapsedMs) {
message = 'Completed';
message = i18n.translate('data.query.languageService.queryResults.completeTime', {
defaultMessage: `Completed`,
});
} else if (props.queryStatus.elapsedMs < 1000) {
message = `Completed in ${props.queryStatus.elapsedMs} ms`;
message = i18n.translate(
'data.query.languageService.queryResults.completeTimeInMiliseconds',
{
defaultMessage: `Completed in ${props.queryStatus.elapsedMs} ms`,
}
);
} else {
message = `Completed in ${Math.floor(props.queryStatus.elapsedMs / 1000)} s`;
message = i18n.translate('data.query.languageService.queryResults.completeTimeInSeconds', {
defaultMessage: `Completed in ${(props.queryStatus.elapsedMs / 1000).toFixed(1)} s`,
});
}

return (
Expand All @@ -108,7 +119,9 @@ export function QueryResult(props: { queryStatus: QueryStatus }) {
data-test-subj="queryResultErrorBtn"
>
<EuiText size="xs" color="subdued">
{'Error'}
{i18n.translate('data.query.languageService.queryResults.error', {
defaultMessage: `Error`,
})}
</EuiText>
</EuiButtonEmpty>
}
Expand All @@ -134,7 +147,7 @@ export function QueryResult(props: { queryStatus: QueryStatus }) {
{i18n.translate('data.query.languageService.queryResults.details', {
defaultMessage: `Details:`,
})}
</strong>{' '}
</strong>
{props.queryStatus.body.error.details}
</p>
</EuiText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const useSearch = (services: DiscoverViewServices) => {
);
}, [savedSearch, services.uiSettings, timefilter]);

const startTime = new Date().getTime();
const startTime = Date.now();
const data$ = useMemo(
() =>
new BehaviorSubject<SearchData>({
Expand Down
41 changes: 33 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1407,10 +1407,10 @@
resolved "https://registry.yarnpkg.com/@elastic/eslint-plugin-eui/-/eslint-plugin-eui-0.0.2.tgz#56b9ef03984a05cc213772ae3713ea8ef47b0314"
integrity sha512-IoxURM5zraoQ7C8f+mJb9HYSENiZGgRVcG4tLQxE61yHNNRDXtGDWTZh8N1KIHcsqN1CEPETjuzBXkJYF/fDiQ==

"@elastic/eui@npm:@opensearch-project/oui@1.12.0":
version "1.12.0"
resolved "https://registry.yarnpkg.com/@opensearch-project/oui/-/oui-1.12.0.tgz#dfb34669549fec2500e71f66e43868932178318c"
integrity sha512-0phXBR8OZneJr/TwIiqTMWL53e/2PqzEDzl/y7QYEc6xUofD+RQSNi/YZNw4OZgscogu/zTajWA5tdQdrxT2+g==
"@elastic/eui@npm:@opensearch-project/oui@1.13.0":
version "1.13.0"
resolved "https://registry.yarnpkg.com/@opensearch-project/oui/-/oui-1.13.0.tgz#830de8bfbb9d0471288b9526ddcfd5fcbd45c420"
integrity sha512-5qVqb7OiiMxIttn7ByFzMySFuIImTqP664PtrjmjDgLsiLkah0f7s1RFT5jE4Os1CrWaTFXiSXzleYpuZyA4oA==
dependencies:
"@types/chroma-js" "^2.4.0"
"@types/react-beautiful-dnd" "^13.1.3"
Expand Down Expand Up @@ -15981,7 +15981,7 @@ string-similarity@^4.0.1:
resolved "https://registry.yarnpkg.com/string-similarity/-/string-similarity-4.0.4.tgz#42d01ab0b34660ea8a018da8f56a3309bb8b2a5b"
integrity sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ==

"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -16016,6 +16016,15 @@ string-width@^3.0.0:
is-fullwidth-code-point "^2.0.0"
strip-ansi "^5.1.0"

string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^5.0.1, string-width@^5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794"
Expand Down Expand Up @@ -16094,7 +16103,7 @@ stringify-entities@^3.0.1:
character-entities-legacy "^1.0.0"
xtend "^4.0.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -16136,6 +16145,13 @@ strip-ansi@^5.1.0, strip-ansi@^5.2.0:
dependencies:
ansi-regex "^4.1.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -18279,7 +18295,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343"
integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -18305,6 +18321,15 @@ wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down Expand Up @@ -18586,4 +18611,4 @@ zip-stream@^4.1.0:
zlib@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/zlib/-/zlib-1.0.5.tgz#6e7c972fc371c645a6afb03ab14769def114fcc0"
integrity sha1-bnyXL8NxxkWmr7A6sUdp3vEU/MA=
integrity sha1-bnyXL8NxxkWmr7A6sUdp3vEU/MA=

0 comments on commit a67c564

Please sign in to comment.