Skip to content

Commit

Permalink
Fix bug on tags multiple filter condition
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Jan 5, 2024
1 parent ab3dd47 commit 55719b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions API/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@router.get("/files/")
@limiter.limit(f"{RATE_LIMIT_PER_MIN}/minute")
@version(1)
def list_s3_files(
async def list_s3_files(
request: Request,
folder: str = Query(default="/HDX"),
page: int = Query(default=1, ge=1, description="Page number"),
Expand Down Expand Up @@ -92,7 +92,7 @@ def list_s3_files(
@router.get("/get/{file_path:path}")
@limiter.limit(f"{RATE_LIMIT_PER_MIN}/minute")
@version(1)
def get_s3_file(
async def get_s3_file(
request: Request,
file_path: str = Path(..., description="The path to the file or folder in S3"),
expiry: int = Query(
Expand Down
17 changes: 8 additions & 9 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,9 +1244,9 @@ def types_to_tables(self, type_list: list):

return list(table_set)

def format_where_clause(self, where_clause):
def format_where_clause(self,where_clause):
"""
Formats the where_clause by replacing certain patterns.
Formats the where_clause by replacing the first occurrence of the pattern.
Parameters:
- where_clause (str): SQL-like condition to filter features.
Expand All @@ -1255,14 +1255,13 @@ def format_where_clause(self, where_clause):
- Formatted where_clause.
"""
pattern = r"tags\['([^']+)'\]"
match = re.search(pattern, where_clause)

if match:
for match in re.finditer(pattern, where_clause):
key = match.group(1)
replacement = f"tags['{key}'][1]"
return re.sub(pattern, replacement, where_clause)
else:
return where_clause
string_in_pattern = f"tags['{key}']"
replacement = f"{string_in_pattern}[1]"
where_clause = where_clause.replace(string_in_pattern, replacement)

return where_clause

def upload_to_s3(self, resource_path):
"""
Expand Down

0 comments on commit 55719b5

Please sign in to comment.