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

Fix dynamically display columns #103

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

KishoreKicha14
Copy link
Contributor

@KishoreKicha14 KishoreKicha14 commented Feb 7, 2025

Screenshot 2025-02-19 at 5 40 48 PM Screenshot 2025-02-19 at 10 50 36 PM Screenshot 2025-02-19 at 10 50 44 PM Screenshot 2025-02-19 at 10 50 51 PM Screenshot 2025-02-19 at 10 50 59 PM Screenshot 2025-02-19 at 10 51 37 PM Screenshot 2025-02-19 at 10 51 48 PM

Description

Problem:
The Top N queries table can display:

Only queries
Only groups
Combination of queries/groups
Some columns are applicable to only queries (eg: indices) and others to only groups (eg: query count).

Table should dynamically display the applicable columns based on the data in the table and only display the applicable columns.

This PR ensures that even when no selection is made and all query types are groups, the applicable columns are dynamically displayed.

Issues Resolved

Closes: [#45]

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Kishore Kumaar Natarajan added 2 commits February 7, 2025 01:47
Signed-off-by: Kishore Kumaar Natarajan <kkamazonn@amazon.com>
Signed-off-by: Kishore Kumaar Natarajan <kkamazonn@amazon.com>
Signed-off-by: Kishore Kumaar Natarajan <kkamazonn@amazon.com>
@deshsidd
Copy link
Collaborator

deshsidd commented Feb 7, 2025

Why are the latency, cpu and memory columns displayed twice in each screenshot? @KishoreKicha14

@deshsidd
Copy link
Collaborator

deshsidd commented Feb 7, 2025

If it’s not too big a change, we can debate about changing the column names to average latency, average cpu…… and so on for only groups? What do others think about this?

Copy link
Member

@ansjcy ansjcy left a comment

Choose a reason for hiding this comment

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

Other than the issues @deshsidd mentioned above, the rest of the logic looks good to me!
@KishoreKicha14 Thanks for the change, could you also add unit tests and cypress tests in this PR as well?

@@ -259,6 +275,15 @@ const QueryInsights = ({
truncateText: true,
},
];
const columnsToShow = selectedFilter === 'SIMILARITY' ? groupColumns : queryColumns;
const filteredQueries = queries.filter((query) => {
Copy link
Member

Choose a reason for hiding this comment

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

How about

const filteredQueries = queries.filter(query => 
  !selectedFilter || query.group_by === selectedFilter
);

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@KishoreKicha14
Copy link
Contributor Author

KishoreKicha14 commented Feb 7, 2025

@deshsidd @ansjcy Updated the screenshots.

Kishore Kumaar Natarajan added 2 commits February 12, 2025 10:26
Signed-off-by: Kishore Kumaar Natarajan <kkamazonn@amazon.com>
Signed-off-by: Kishore Kumaar Natarajan <kkamazonn@amazon.com>
@@ -22,7 +22,7 @@ const clearAll = () => {
};

describe('Query Insights Dashboard', () => {
// Setup before each test
// // Setup before each test
Copy link
Member

Choose a reason for hiding this comment

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

please remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

cy.contains('.euiTableHeaderCell', header).should('exist');
});
});
beforeEach(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need beforeEach here? this looks identical to

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

cy.get('.euiFilterSelectItem').contains('group').click();

// Wait for table update
cy.get('.euiTableHeaderCell').should('have.length.lessThan', 20);
Copy link
Member

Choose a reason for hiding this comment

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

Why dont we assert a fixed length here? The number of headers in each scenarios should be deterministic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to fixed length

];

// Wait for the table to load by checking if headers are visible
cy.get('.euiTableHeaderCell').should('have.length.greaterThan', 6);
Copy link
Member

Choose a reason for hiding this comment

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

why greater then instead of equals?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to fixed length


await waitFor(() => expect(screen.getByRole('table')).toBeInTheDocument());
const headers = await waitFor(() => screen.getAllByRole('columnheader', { hidden: false }));
console.log(
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the console log.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

const expectedHeaders = ['ID', 'Type', 'Query Count', 'Latency', 'CPU Time', 'Memory Usage'];
expectedHeaders.forEach((header) => {
expect(
headers.some((h) => h.textContent?.trim().toLowerCase() === header.toLowerCase())
Copy link
Member

Choose a reason for hiding this comment

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

why headers.some?
we should also compare the actual value without ignoring the case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

modified

renderQueryInsights();
await waitFor(() => expect(screen.getByRole('table')).toBeInTheDocument());
const typeElements = screen.getAllByText('Type');
const typeFilterButton = typeElements.find((el) => el.closest('button')); // Ensure it's a button
Copy link
Member

Choose a reason for hiding this comment

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

It is a button. why use closest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed


await waitFor(() => {
expectedHeaders.forEach(async (header) => {
expect(await screen.findByText(header)).toBeInTheDocument();
Copy link
Member

Choose a reason for hiding this comment

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

instead of finding on the whole screen and assert to be in document, could you narrow down the test to that specific table?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

modified

];

await waitFor(() => {
expectedHeaders.forEach(async (header) => {
Copy link
Member

Choose a reason for hiding this comment

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

Also, the sequence matters here. let's also test the header sequence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

modified checking sequence as well


// Verify each expected header exists
expectedHeaders.forEach((header) => {
cy.contains('.euiTableHeaderCell', header).should('exist');
Copy link
Member

Choose a reason for hiding this comment

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

The sequence matters here. let's also test the header sequence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

modified checking sequence as well

kishore.nat98@gmail.com added 4 commits February 18, 2025 16:51
Signed-off-by: kishore.nat98@gmail.com <kkamazonn@amazon.com>
Signed-off-by: kishore.nat98@gmail.com <kkamazonn@amazon.com>
Signed-off-by: kishore.nat98@gmail.com <kkamazonn@amazon.com>
Signed-off-by: kishore.nat98@gmail.com <kkamazonn@amazon.com>
@deshsidd
Copy link
Collaborator

deshsidd commented Feb 19, 2025

Cypress tests failing, please take a look
(Retried and looks like it was a transient issue on windows)

@deshsidd
Copy link
Collaborator

deshsidd commented Feb 19, 2025

If it’s not too big a change, we can debate about changing the column names to average latency, average cpu…… and so on for only groups? What do others think about this?

@KishoreKicha14 Looks like this change might not be addressed? Please update the screenshots based on the latest code if these have been addressed. Thanks

@KishoreKicha14
Copy link
Contributor Author

If it’s not too big a change, we can debate about changing the column names to average latency, average cpu…… and so on for only groups? What do others think about this?

@KishoreKicha14 Looks like this change might not be addressed? Please update the screenshots based on the latest code if these have been addressed. Thanks

Should we have separate columns for average latency and average CPU, or should the column names dynamically change? The challenge arises when both group and query are selected. How should we handle this?

@deshsidd
Copy link
Collaborator

If it’s not too big a change, we can debate about changing the column names to average latency, average cpu…… and so on for only groups? What do others think about this?

@KishoreKicha14 Looks like this change might not be addressed? Please update the screenshots based on the latest code if these have been addressed. Thanks

Should we have separate columns for average latency and average CPU, or should the column names dynamically change? The challenge arises when both group and query are selected. How should we handle this?

column names can dynamically change when only groups data is in the table.

@KishoreKicha14
Copy link
Contributor Author

If it’s not too big a change, we can debate about changing the column names to average latency, average cpu…… and so on for only groups? What do others think about this?

@KishoreKicha14 Looks like this change might not be addressed? Please update the screenshots based on the latest code if these have been addressed. Thanks

Should we have separate columns for average latency and average CPU, or should the column names dynamically change? The challenge arises when both group and query are selected. How should we handle this?

column names can dynamically change when only groups data is in the table.

discussed this with @ansjcy , and he mentioned regarding column naming:

Only groups selected → Show averaged column names (e.g., "Average Latency," "Average CPU").
Only queries selected → Show raw column names (e.g., "Latency," "CPU Usage") and remove the query count.
Both groups and queries selected → Use combined column names like "Latency / Avg Latency" and include the query count.
@deshsidd Any thoughts on this approach?

@deshsidd
Copy link
Collaborator

Only groups selected → Show averaged column names (e.g., "Average Latency," "Average CPU"). Only queries selected → Show raw column names (e.g., "Latency," "CPU Usage") and remove the query count. Both groups and queries selected → Use combined column names like "Latency / Avg Latency" and include the query count. @deshsidd Any thoughts on this approach?

For both can use the same approach we have today, i.e Latency, etc.

kishore.nat98@gmail.com added 2 commits February 20, 2025 00:41
Signed-off-by: kishore.nat98@gmail.com <kkamazonn@amazon.com>
Signed-off-by: kishore.nat98@gmail.com <kkamazonn@amazon.com>
@KishoreKicha14
Copy link
Contributor Author

Discussed with UX offline, we agreed to use:
Only groups are selected → Shows averaged value for metric (ie column name : Average Latency) and include query count
Only queries are selected → Shows raw value for metric (ie column name : Latency) and exclude the query count
Both groups and queries are selected → Shows averaged and non averaged values for metric ( ie column name: Avg Latency/ Latency) and include query count

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants