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

Avoid not needed search creation on default and stream search page #11372

Merged
merged 4 commits into from Nov 17, 2021

Conversation

linuspahl
Copy link
Contributor

@linuspahl linuspahl commented Sep 29, 2021

Description

Motivation and Context

Before this change we we created two searches, when opening the default or stream search page via a URL with search query params like: ?q=http_method:GET&rangetype=relative&relative=300. This was not the case when opening a saved search. This problem occurred because we were creating a search with the default search query first and another one with the search settings provided by the URL query params.

Please note, this bug still exists when the URL query params contain a stream filter. Fixing this bug will require more complex changes, which we should implement in a follow-up PR.

@linuspahl linuspahl force-pushed the avoid-not-needed-search-creation branch 2 times, most recently from fcba5c7 to 51cded7 Compare October 7, 2021 15:02
@linuspahl linuspahl marked this pull request as ready for review October 8, 2021 11:00
@linuspahl linuspahl force-pushed the avoid-not-needed-search-creation branch from 51cded7 to 9fa9514 Compare October 21, 2021 14:39
Copy link
Member

@dennisoelkers dennisoelkers left a comment

Choose a reason for hiding this comment

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

Looks good so far! Added just one minor remark.

timezone: range.timezone,
} as KeywordTimeRange : undefined;
default:
// @ts-ignore
Copy link
Member

Choose a reason for hiding this comment

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

To avoid using @ts-ignore here, we can do two things:

  • Using the complete range to generate the Error in the next line (TS is complaining because range.rangetype is supposed to be never at this point), which could also help for debugging.
  • Using @ts-expect-error instead. This is doing the same as @ts-ignore (suppressing an error), but in addition it is raising an error if no error is suppressed. This way, we are also being notified when a new possible value for rangetype is introduced but it is not handled in a case-clause.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the tip, I really like the typing related advantages of @ts-expect-error.

Copy link
Member

@dennisoelkers dennisoelkers left a comment

Choose a reason for hiding this comment

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

LGTM and fixes the issue!

@dennisoelkers dennisoelkers merged commit f82cf3d into master Nov 17, 2021
@dennisoelkers dennisoelkers deleted the avoid-not-needed-search-creation branch November 17, 2021 09:02
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.

None yet

2 participants