mirror of
https://github.com/hyperdxio/hyperdx
synced 2026-04-21 13:37:15 +00:00
fix(app): negative duration in search (#28)
Co-authored-by: Warren <5959690+wrn14897@users.noreply.github.com> Co-authored-by: Mike Shi <mike@deploysentinel.com>
This commit is contained in:
parent
911c02a443
commit
8b103f3f57
2 changed files with 25 additions and 1 deletions
10
.changeset/shiny-needles-cross.md
Normal file
10
.changeset/shiny-needles-cross.md
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
'@hyperdx/app': patch
|
||||
---
|
||||
|
||||
fix(app): negative duration in search
|
||||
|
||||
Duration column in the search interface displayed negative numbers when only a
|
||||
timestamp was present. This fix changes the behavior to display "N/A" for such
|
||||
cases, clarifying that the duration is not applicable rather than displaying a
|
||||
misleading negative number.
|
||||
|
|
@ -13,6 +13,7 @@ import cx from 'classnames';
|
|||
import { Button, Modal } from 'react-bootstrap';
|
||||
import stripAnsi from 'strip-ansi';
|
||||
import { CSVLink } from 'react-csv';
|
||||
import curry from 'lodash/curry';
|
||||
|
||||
import Checkbox from './Checkbox';
|
||||
import FieldMultiSelect from './FieldMultiSelect';
|
||||
|
|
@ -23,6 +24,19 @@ import { usePrevious, useWindowSize } from './utils';
|
|||
import { useSearchEventStream } from './search';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
|
||||
type Row = Record<string, any> & { duration: number };
|
||||
type AccessorFn = (row: Row, column: string) => any;
|
||||
|
||||
const ACCESSOR_MAP: Record<string, AccessorFn> = {
|
||||
duration: row => (row.duration >= 0 ? row.duration : 'N/A'),
|
||||
default: (row, column) => row[column],
|
||||
};
|
||||
|
||||
function retrieveColumnValue(column: string, row: Row): any {
|
||||
const accessor = ACCESSOR_MAP[column] ?? ACCESSOR_MAP.default;
|
||||
return accessor(row, column);
|
||||
}
|
||||
|
||||
function DownloadCSVButton({
|
||||
config: { where, dateRange },
|
||||
extraFields,
|
||||
|
|
@ -351,7 +365,7 @@ export const RawLogTable = memo(
|
|||
size: isSmallScreen ? 70 : 100,
|
||||
},
|
||||
...(displayedColumns.map(column => ({
|
||||
accessorFn: row => row[column], // Columns can contain '.' and will not work with accessorKey
|
||||
accessorFn: curry(retrieveColumnValue)(column), // Columns can contain '.' and will not work with accessorKey
|
||||
header: column,
|
||||
cell: info => (
|
||||
<span
|
||||
|
|
|
|||
Loading…
Reference in a new issue