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

[DRAFT] [WIP] Add helper function to transform_simple_query_string #6363

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

patphongs
Copy link
Member

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:

branch PR
fix/other_pr link
feature/other_pr link

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)

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
Copy link
Member Author

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.

@patphongs patphongs changed the title [DRAFT] Add helper function to transform_simple_query_string [DRAFT] [WIP] Add helper function to transform_simple_query_string Jul 3, 2024
Copy link

codecov bot commented Jul 3, 2024

Codecov Report

Attention: Patch coverage is 80.76923% with 5 lines in your changes missing coverage. Please review.

Project coverage is 77.82%. Comparing base (1cf33dc) to head (b04b484).
Report is 3 commits behind head on develop.

Files Patch % Lines
fec/legal/views.py 76.19% 5 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Update bool operator syntax for Elasticsearch simple_query_string and excludes
1 participant