Skip to content

Commit

Permalink
query flowlist with extra parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
echoyang7 committed Oct 25, 2024
1 parent e7c8d92 commit 61f050f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion frontend/src/api/flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const getFlowDetailOrigin = (flowId) => {

export const getFlowList = () => {
return axios({
url: '/api/flow'
url: '/api/flow?for_display=true'
})
}

Expand Down
12 changes: 8 additions & 4 deletions lyrebird/mock/blueprints/apis/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ def get(self, id):
return application.make_fail_response(f'Request {id} not found')


def get_flow_list_by_filter(filter_obj):
def get_flow_list_by_filter(filter_obj, for_display):
all_items = context.application.cache.items()[::-1]
req_list = []
target_items = Filter.get_items_after_filtration(all_items, filter_obj)
for item in target_items:
# If the response is not fully processed, do not return.
if not for_display and (not item.get('response') or not item.get('response', {}).get('headers', {}).get('lyrebird')):
continue

info = dict(
id=item['id'],
size=item['size'],
Expand Down Expand Up @@ -91,9 +95,9 @@ class FlowList(Resource):
当前请求列表
"""

def get(self):
def get(self, for_display=False):
default_filter = context.application.selected_filter
req_list = get_flow_list_by_filter(default_filter)
req_list = get_flow_list_by_filter(default_filter, for_display)
return Response(json.dumps(req_list, ensure_ascii=False), mimetype='application/json', status=200)

def delete(self):
Expand Down Expand Up @@ -122,7 +126,7 @@ def post(self, action):
elif action == 'search':
filter_name = request.json.get('selectedFilter')
filter_obj = context.application.get_and_update_selected_filter_by_name(filter_name)
req_list = get_flow_list_by_filter(filter_obj)
req_list = get_flow_list_by_filter(filter_obj, True)
return Response(json.dumps(req_list, ensure_ascii=False), mimetype='application/json', status=200)
else:
return application.make_fail_response(f'action: {action} is not supported')
2 changes: 1 addition & 1 deletion lyrebird/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
IVERSION = (3, 0, 6)
IVERSION = (3, 0, 7)
VERSION = ".".join(str(i) for i in IVERSION)
LYREBIRD = "Lyrebird " + VERSION

0 comments on commit 61f050f

Please sign in to comment.