Commit 03f6f0a9 authored by fabian serin's avatar fabian serin
Browse files

cleanup

parent 18fc92cb
Pipeline #60762 passed with stages
in 58 minutes and 6 seconds
...@@ -157,10 +157,8 @@ def escape_forbidden_characters_for_search(input_str: str) -> str: ...@@ -157,10 +157,8 @@ def escape_forbidden_characters_for_search(input_str: str) -> str:
return result_str return result_str
async def query_request_with_cursor(query_type: str, kind: str, ctx: Context, query: SimpleCursorQueryRequest = None, async def query_request_with_cursor(query_type: str, kind: str, ctx: Context, query: SimpleCursorQueryRequest = None):
custom_returned_fields: [str] = None): returned_fields = query_type_returned_fields(query_type)
returned_fields = query_type_returned_fields(query_type) if custom_returned_fields is None \
else custom_returned_fields
query_request = CursorQueryRequest(kind=kind, query_request = CursorQueryRequest(kind=kind,
limit=query.limit or LIMIT, limit=query.limit or LIMIT,
query=query.query, query=query.query,
...@@ -174,8 +172,7 @@ async def query_request_with_cursor(query_type: str, kind: str, ctx: Context, qu ...@@ -174,8 +172,7 @@ async def query_request_with_cursor(query_type: str, kind: str, ctx: Context, qu
async def query_request_with_offset(query_type: str, kind: str, ctx: Context, query: SimpleOffsetQueryRequest = None, async def query_request_with_offset(query_type: str, kind: str, ctx: Context, query: SimpleOffsetQueryRequest = None,
custom_returned_fields: [str] = None): custom_returned_fields: [str] = None):
returned_fields = query_type_returned_fields(query_type) if custom_returned_fields is None \ returned_fields = query_type_returned_fields(query_type)
else custom_returned_fields
query_request = QueryRequest(kind=kind, query_request = QueryRequest(kind=kind,
limit=query.limit or LIMIT, limit=query.limit or LIMIT,
...@@ -188,16 +185,15 @@ async def query_request_with_offset(query_type: str, kind: str, ctx: Context, qu ...@@ -188,16 +185,15 @@ async def query_request_with_offset(query_type: str, kind: str, ctx: Context, qu
query_request=query_request) query_request=query_request)
async def query_request(query_type: str, kind: str, ctx: Context, query: SearchQueryRequest = None, async def query_request(query_type: str, kind: str, ctx: Context, query: SearchQueryRequest = None):
custom_returned_fields: [str] = None):
# use offset if not not none else use cursor # use offset if not not none else use cursor
query_as_dict = query.dict(exclude_none=True, exclude_unset=True) query_as_dict = query.dict(exclude_none=True, exclude_unset=True)
if query.offset is not None: if query.offset is not None:
cursor_query = SimpleOffsetQueryRequest(**query_as_dict) cursor_query = SimpleOffsetQueryRequest(**query_as_dict)
return await query_request_with_offset(query_type, kind, ctx, cursor_query, custom_returned_fields) return await query_request_with_offset(query_type, kind, ctx, cursor_query)
cursor_query = SimpleCursorQueryRequest(**query_as_dict) cursor_query = SimpleCursorQueryRequest(**query_as_dict)
return await query_request_with_cursor(query_type, kind, ctx, cursor_query, custom_returned_fields) return await query_request_with_cursor(query_type, kind, ctx, cursor_query)
@router.post('/query/wellbores', summary='Query with cursor, get wellbores', @router.post('/query/wellbores', summary='Query with cursor, get wellbores',
......
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from typing import Optional, Dict, List
from fastapi import APIRouter, Depends from fastapi import APIRouter, Depends
from odes_search.models import CursorQueryResponse from odes_search.models import CursorQueryResponse
...@@ -30,7 +28,8 @@ from .search_v3 import ( ...@@ -30,7 +28,8 @@ from .search_v3 import (
added_relationships_query, added_relationships_query,
WELLBORE_RELATIONSHIP, WELLBORE_RELATIONSHIP,
get_ctx, get_ctx,
query_type, update_query_with_nested_names_based_search) query_type,
update_query_with_nested_names_based_search)
from ..common_parameters import REQUIRED_ROLES_READ from ..common_parameters import REQUIRED_ROLES_READ
router = APIRouter() router = APIRouter()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment