[DRAFT] [WIP] Add helper function to transform_simple_query_string#6363
Draft
[DRAFT] [WIP] Add helper function to transform_simple_query_string#6363
Conversation
patphongs
commented
Jul 3, 2024
Comment on lines
+188
to
+205
| # API simple_query_string transformation: | ||
| # ((coordinated|communications)|(in\-kind +contributions)| | ||
| # ("independent expenditure")) +(-authorization) | ||
|
|
||
| def transform_simple_query_string(query_string): | ||
|
|
||
| # Define the replacements for simple query string | ||
| replacements = [ | ||
| (r' OR ', '|'), # Replace OR with | | ||
| (r' AND ', ' +'), # Replace AND with + | ||
| (r'(\b\w+)-(\w+\b)', r'\1\\-\2'), # Escape hyphens in words | ||
| ] | ||
|
|
||
| # Apply replacements sequentially | ||
| for pattern, replacement in replacements: | ||
| query_string = re.sub(pattern, replacement, query_string) | ||
|
|
||
| return query_string |
Member
Author
There was a problem hiding this comment.
@cnlucas Here's the new helper function to transform the simple query string to the updated syntax for boolean operators. Please take a look and let me know if any adjustments should be made.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #6363 +/- ##
===========================================
- Coverage 77.83% 77.82% -0.01%
===========================================
Files 291 291
Lines 9486 9502 +16
Branches 687 687
===========================================
+ Hits 7383 7395 +12
- Misses 2103 2107 +4 ☔ View full report in Codecov by Sentry. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary (required)
Adds transform_simple_query_string helper function to solve different syntax when using new simple_query_string.
Required reviewers
1 backend
1 frontend
Impacted areas of the application
General components of the application that this PR will affect:
Screenshots
(Include a screenshot of the new/updated features in context (“in the wild”). If it is an interface change, include both before and after screenshots)
Related PRs
Related PRs against other branches:
How to test
(Include any information that may be helpful to the reviewer(s). This might include links to sample pages to test or any local environmental setup that is unusual such as environment variable (never credentials), API version to point to, etc)
System architecture updates (if applicable)
(If this pull request changes our current system diagram, include a description of those changes here and create a new ticket to update the system diagram)