Skip to content

ui: proper handle of unset app name#83008

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
maryliag:fix-unset
Jun 24, 2022
Merged

ui: proper handle of unset app name#83008
craig[bot] merged 1 commit intocockroachdb:masterfrom
maryliag:fix-unset

Conversation

@maryliag
Copy link
Copy Markdown
Contributor

@maryliag maryliag commented Jun 16, 2022

Previously, if a filter for unset app name
was selected on Statement page, the Statement Details
page was not finding the correct values.
Now if no filter is selected, no search params is
passed to the Details page. If there is an empty value
for the appNames on request, is looking for unset.

This commit also creates a constant for the unset value
and replaces all places to use the constant instead.

Fixes #83002

https://www.loom.com/share/2bcb83ef35714fc4b90be8d513017eab

Release note (bug fix): Statement Details now find the stats
when the unset app filter is selected.

@maryliag maryliag requested review from a team and removed request for a team June 16, 2022 19:08
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor

@xinhaoz xinhaoz left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @maryliag)


pkg/server/combined_statement_stats.go line 431 at r1 (raw file):

			buffer.WriteString(" AND (")
			for i, app := range req.AppNames {
				if app == "(unset)" {

What do we think about providing the 'empty string app name' in the request itself? Not sure how likely it is we'll be changing it in the client side, I assume it won't be very often but at least we won't have to change the code here if it does.

Copy link
Copy Markdown
Contributor Author

@maryliag maryliag left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @xinhaoz)


pkg/server/combined_statement_stats.go line 431 at r1 (raw file):

Previously, xinhaoz (Xin Hao Zhang) wrote…

What do we think about providing the 'empty string app name' in the request itself? Not sure how likely it is we'll be changing it in the client side, I assume it won't be very often but at least we won't have to change the code here if it does.

the issue is how are you gonna differentiate the cases where you didn't pass any filter vs you want the filter with app name unset, because if we pass empty on unset both cases would have appNames= on the request, and those should have different results

so this way if there is no filter, we don't add the where on the select, but if there is a value (unset) we know we want to filter for specific statement with no app name

@xinhaoz
Copy link
Copy Markdown
Contributor

xinhaoz commented Jun 16, 2022

My comment was a little unclear -- I meant providing what app name would constitute looking for app_name='' in the server, in addition to providing the app names from the uri as we currenlty are.
So for now it would be something like emptyAppName: (unset), and we don't have to hardcode this value in the server.

@maryliag maryliag changed the title server: proper handle of unset app name ui: proper handle of unset app name Jun 16, 2022
Copy link
Copy Markdown
Contributor Author

@maryliag maryliag left a comment

Choose a reason for hiding this comment

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

Changed my approach. Now we only add the search param to the request if any filter was selected, so if there is a search param for appNames and the value is empty string, we know that is the value to look for. Also created the constant to make it easier in case we want to change the value in the future.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @xinhaoz)

Copy link
Copy Markdown
Contributor

@xinhaoz xinhaoz left a comment

Choose a reason for hiding this comment

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

Nice, even better :lgtm_strong:

Reviewed all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @xinhaoz)

@nathanstilwell
Copy link
Copy Markdown
Contributor

pkg/ui/workspaces/cluster-ui/src/statementsTable/statementsTableContent.tsx line 186 at r2 (raw file):

  let searchParams = "";

  if (!(props.appNames.length == 1 && props.appNames[0] == "")) {

Threequals (strict equality) please. This feels very nitpicky, but comparisons in JavaScript should always use === instead of ==. Especially with 1 and empty string. For example,

const a = 1;
const b = "";

// ALL of these will return true
a == 1;
a == "1";
a == true;
b == "";
b == 0;
b == false;

// on the other hand,
a === 1;       // true
a === "1";   // false
a === true; // false

Copy link
Copy Markdown
Contributor Author

@maryliag maryliag left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @nathanstilwell and @xinhaoz)


pkg/ui/workspaces/cluster-ui/src/statementsTable/statementsTableContent.tsx line 186 at r2 (raw file):

Previously, nathanstilwell (Nathan Stilwell) wrote…

Threequals (strict equality) please. This feels very nitpicky, but comparisons in JavaScript should always use === instead of ==. Especially with 1 and empty string. For example,

const a = 1;
const b = "";

// ALL of these will return true
a == 1;
a == "1";
a == true;
b == "";
b == 0;
b == false;

// on the other hand,
a === 1;       // true
a === "1";   // false
a === true; // false

Done.

Previously, if a filter for `unset` app name
was selected on Statement page, the Stament Details
page was not finding the correct values.
Now if no filter is selected, no search params is
passed to the Details page. If there is an empty value
for the appNames on request, is looking for unset.

This commit also creates a constant for the unset value
and replaces all places to use the constant instead.

Fixes cockroachdb#83002

Release note (bug fix): Statement Details now find the stats
when the `unset` app filter is selected.
@maryliag
Copy link
Copy Markdown
Contributor Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jun 23, 2022

This PR was included in a batch that was canceled, it will be automatically retried

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jun 23, 2022

Build failed (retrying...):

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jun 24, 2022

Build succeeded:

@craig craig bot merged commit 7af6c0d into cockroachdb:master Jun 24, 2022
@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Jun 24, 2022

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from e16c7be to blathers/backport-release-22.1-83008: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.1.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

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.

ui: statement details page incorrectly sets appNames as (unset) in the stmt details request

4 participants