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

If keyword is numeric query by order_number #176

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions run_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SCRIPT_PATH=$PWD/setup
if [ "$PATH" != *"$SCRIPT_PATH" ];then
echo Setting path
PATH=$PATH:$SCRIPT_PATH
fi
source start.sh
File renamed without changes.
7 changes: 5 additions & 2 deletions src/order/order_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ def create(
@classmethod
def get_orders(cls, query_params: OrderQueryParams = OrderQueryParams()):
query = OrderModel.home_office_code == OrderModel.home_office_code
keyword = query_params.keyword

if keyword and keyword.isnumeric():
query = query & (OrderModel.order_number == keyword)
if query_params.order_number:
query = query & (OrderModel.order_number ==
query_params.order_number)
Expand All @@ -78,9 +81,9 @@ def get_orders(cls, query_params: OrderQueryParams = OrderQueryParams()):

orders = OrderModel.query.filter(query)
order_array = [order for order in orders]
if query_params.keyword:
if keyword and not keyword.isnumeric():
filter_obj = filter(
lambda order: query_params.keyword.upper()
lambda order: keyword.upper()
in json.dumps(table_record_to_json(order)).upper(),
order_array,
)
Expand Down