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(1207): filtering string with empty space #1260

Merged
merged 1 commit into from
Jul 26, 2024

Conversation

tplevko
Copy link
Contributor

@tplevko tplevko commented Jul 24, 2024

fixes #1207

make the filter ignore empty spaces, to facilitate filtering both on spaced and unspaced strings

vokoscreenNG-2024-07-24_12-15-50.mp4

@tplevko tplevko marked this pull request as ready for review July 24, 2024 11:41
@@ -35,7 +35,7 @@ export function CustomAutoFields({
const actualFields = (fields ?? schema.getSubfields()).filter(
(field) =>
!omitFields!.includes(field) &&
(field === 'parameters' || field.toLowerCase().includes(filteredFieldText.toLowerCase())),
(field === 'parameters' || field.toLowerCase().includes(filteredFieldText.replace(/\s/g, '').toLowerCase())),
Copy link
Member

Choose a reason for hiding this comment

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

@tplevko, in this case, we're recreating the regexp on every cycle which is expensive, would be possible to create the regexp once in a shared service and then use it from there?

That being said, since we're applying it to the filteredFieldText string, perhaps we can prepare the string once before the includes, perhaps something like:

  const cleanQueryTerm = filteredFieldText.replace(/\s/g, '').toLowerCase();
  const actualFields = (fields ?? schema.getSubfields()).filter(
    (field) =>
      !omitFields!.includes(field) &&
      (field === 'parameters' || field.toLowerCase().includes(cleanQueryTerm)),
  );

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 hint. Updated according your recommendation.

Copy link
Member

@lordrip lordrip left a comment

Choose a reason for hiding this comment

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

Thanks for handling it @tplevko 💪

@lordrip lordrip merged commit a5c2d33 into KaotoIO:main Jul 26, 2024
9 checks passed
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.

Filtering string with empty space not working
2 participants