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

[ML] Explain Log Rate Spikes: improve the display of large groups #145609

Merged
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const NARROW_COLUMN_WIDTH = '120px';
const EXPAND_COLUMN_WIDTH = '40px';
const ACTIONS_COLUMN_WIDTH = '60px';
const NOT_AVAILABLE = '--';
const MAX_GROUP_BADGES = 10;

const PAGINATION_SIZE_OPTIONS = [5, 10, 20, 50];
const DEFAULT_SORT_FIELD = 'pValue';
Expand Down Expand Up @@ -250,8 +251,11 @@ export const SpikeAnalysisGroupsTable: FC<SpikeAnalysisTableProps> = ({
),
render: (_, { group, repeatedValues }) => {
const valuesBadges = [];
const hasExtraBadges = Object.keys(group).length > MAX_GROUP_BADGES;

for (const fieldName in group) {
if (group.hasOwnProperty(fieldName)) {
if (valuesBadges.length === MAX_GROUP_BADGES) break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: If you move that line with the break below the .push() it should break after the last necessary push instead of triggering one more loop

valuesBadges.push(
<>
<EuiBadge
Expand All @@ -269,19 +273,33 @@ export const SpikeAnalysisGroupsTable: FC<SpikeAnalysisTableProps> = ({
);
}
}
if (Object.keys(repeatedValues).length > 0) {
if (Object.keys(repeatedValues).length > 0 || hasExtraBadges) {
valuesBadges.push(
<>
<EuiBadge
key={`$more-id`}
data-test-subj="aiopsSpikeAnalysisGroupsTableColumnGroupBadge"
color="hollow"
>
+{Object.keys(repeatedValues).length}{' '}
<FormattedMessage
id="xpack.aiops.explainLogRateSpikes.spikeAnalysisTableGroups.moreLabel"
defaultMessage="more field/value pairs also appearing in other groups"
/>
{hasExtraBadges ? (
peteharverson marked this conversation as resolved.
Show resolved Hide resolved
<>
+{Object.keys(group).length - MAX_GROUP_BADGES}{' '}
<FormattedMessage
id="xpack.aiops.explainLogRateSpikes.spikeAnalysisTableGroups.moreLabel"
defaultMessage="more field/value pairs"
/>
<br />
</>
) : null}
{Object.keys(repeatedValues).length > 0 ? (
<>
+{Object.keys(repeatedValues).length}{' '}
<FormattedMessage
id="xpack.aiops.explainLogRateSpikes.spikeAnalysisTableGroups.moreRepeatedLabel"
defaultMessage="more field/value pairs also appearing in other groups"
/>
</>
) : null}
</EuiBadge>
<EuiSpacer size="xs" />
</>
Expand Down