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

ui/cluster-ui: fix transaction details stmts table pagination #83191

Merged
merged 1 commit into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -207,16 +207,26 @@ export class TransactionDetails extends React.Component<
const statementFingerprintIds =
transaction?.stats_data?.statement_fingerprint_ids;

return (
(statementFingerprintIds &&
getStatementsByFingerprintId(statementFingerprintIds, statements)) ||
[]
if (!statementFingerprintIds) {
return [];
}

// Get all the stmts matching the transaction's fingerprint ID. Then we filter
// by those statements actually associated with the current transaction.
const stmts = getStatementsByFingerprintId(
statementFingerprintIds,
statements,
).filter(
s =>
s.key.key_data.transaction_fingerprint_id.toString() ===
this.props.transactionFingerprintId,
);

return stmts;
};

render(): React.ReactElement {
const { error, nodeRegions, transaction, transactionFingerprintId } =
this.props;
const { error, nodeRegions, transaction } = this.props;
const { latestTransactionText } = this.state;
const statementsForTransaction = this.getStatementsForTransaction();
const transactionStats = transaction?.stats_data?.stats;
Expand Down Expand Up @@ -275,12 +285,10 @@ export class TransactionDetails extends React.Component<

const { isTenant, hasViewActivityRedactedRole } = this.props;
const { sortSetting, pagination } = this.state;
const txnScopedStmts = statementsForTransaction.filter(
s =>
s.key.key_data.transaction_fingerprint_id.toString() ===
transactionFingerprintId,

const aggregatedStatements = aggregateStatements(
statementsForTransaction,
);
const aggregatedStatements = aggregateStatements(txnScopedStmts);
populateRegionNodeForStatements(
aggregatedStatements,
nodeRegions,
Expand Down Expand Up @@ -424,7 +432,7 @@ export class TransactionDetails extends React.Component<
</Row>
<TableStatistics
pagination={pagination}
totalCount={statementsForTransaction.length}
totalCount={aggregatedStatements.length}
arrayItemName={
"statement fingerprints for this transaction"
}
Expand All @@ -451,7 +459,7 @@ export class TransactionDetails extends React.Component<
<Pagination
pageSize={pagination.pageSize}
current={pagination.current}
total={statementsForTransaction.length}
total={aggregatedStatements.length}
onChange={this.onChangePage}
/>
</React.Fragment>
Expand Down
5 changes: 3 additions & 2 deletions pkg/ui/workspaces/cluster-ui/src/transactionsPage/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ export const getStatementsByFingerprintId = (
statementFingerprintIds: Long[],
statements: Statement[],
): Statement[] => {
return statements?.filter(s =>
statementFingerprintIds.some(id => id.eq(s.id)),
return (
statements?.filter(s => statementFingerprintIds.some(id => id.eq(s.id))) ||
[]
);
};

Expand Down