-
Notifications
You must be signed in to change notification settings - Fork 40
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
[DRAFT] [WIP] Add helper function to transform_simple_query_string #6363
base: develop
Are you sure you want to change the base?
Conversation
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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. |
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)