diff --git a/frontend/src/api/flow.js b/frontend/src/api/flow.js index 72acf0fd..81c9a088 100644 --- a/frontend/src/api/flow.js +++ b/frontend/src/api/flow.js @@ -15,7 +15,7 @@ export const getFlowDetailOrigin = (flowId) => { export const getFlowList = () => { return axios({ - url: '/api/flow' + url: '/api/flow?for_display=true' }) } diff --git a/lyrebird/mock/blueprints/apis/flow.py b/lyrebird/mock/blueprints/apis/flow.py index 740c3669..7d96610c 100644 --- a/lyrebird/mock/blueprints/apis/flow.py +++ b/lyrebird/mock/blueprints/apis/flow.py @@ -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 for_display == False and item['duration'] == 0: + continue + info = dict( id=item['id'], size=item['size'], @@ -92,8 +96,9 @@ class FlowList(Resource): """ def get(self): + for_display = request.args.get('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): @@ -122,7 +127,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') diff --git a/tests/test_flow_api.py b/tests/test_flow_api.py index 41d3a628..1efafe8a 100644 --- a/tests/test_flow_api.py +++ b/tests/test_flow_api.py @@ -142,7 +142,7 @@ def client(checker_server): def test_flow_list_with_get(client): - resp = client.get('/api/flow') + resp = client.get('/api/flow?for_display=true') assert len(resp.json) == 5 @@ -174,7 +174,7 @@ def test_flow_with_id(client): def test_flow_with_id_and_decode_input_encode(client): flow_id = None - flows = client.get('/api/flow').json + flows = client.get('/api/flow?for_display=true').json for flow in flows: if flow['request']['host'] == 'm.meituan.com': flow_id = flow['id'] @@ -185,7 +185,7 @@ def test_flow_with_id_and_decode_input_encode(client): def test_flow_with_id_and_decode_input_decode(client): flow_id = None - flows = client.get('/api/flow').json + flows = client.get('/api/flow?for_display=true').json for flow in flows: if flow['request']['host'] == 'i.meituan.com': flow_id = flow['id'] @@ -196,7 +196,7 @@ def test_flow_with_id_and_decode_input_decode(client): def test_flow_with_id_and_not_decode_input_encode(client): flow_id = None - flows = client.get('/api/flow').json + flows = client.get('/api/flow?for_display=true').json for flow in flows: if flow['request']['host'] == 'm.meituan.com': flow_id = flow['id'] @@ -207,7 +207,7 @@ def test_flow_with_id_and_not_decode_input_encode(client): def test_flow_with_id_and_not_decode_input_decode(client): flow_id = None - flows = client.get('/api/flow').json + flows = client.get('/api/flow?for_display=true').json for flow in flows: if flow['request']['host'] == 'i.meituan.com': flow_id = flow['id'] @@ -218,7 +218,7 @@ def test_flow_with_id_and_not_decode_input_decode(client): def test_flow_with_id_and_default_input_encode(client): flow_id = None - flows = client.get('/api/flow').json + flows = client.get('/api/flow?for_display=true').json for flow in flows: if flow['request']['host'] == 'm.meituan.com': flow_id = flow['id'] @@ -229,7 +229,7 @@ def test_flow_with_id_and_default_input_encode(client): def test_flow_with_id_and_default_input_decode(client): flow_id = None - flows = client.get('/api/flow').json + flows = client.get('/api/flow?for_display=true').json for flow in flows: if flow['request']['host'] == 'i.meituan.com': flow_id = flow['id'] @@ -240,7 +240,7 @@ def test_flow_with_id_and_default_input_decode(client): def test_flow_with_id_and_origin(client): flow_id = None - flows = client.get('/api/flow').json + flows = client.get('/api/flow?for_display=true').json for flow in flows: if flow['request']['host'] == 'm.meituan.com': flow_id = flow['id'] @@ -252,7 +252,7 @@ def test_flow_with_id_and_origin(client): def test_flow_with_id_and_not_origin(client): flow_id = None - flows = client.get('/api/flow').json + flows = client.get('/api/flow?for_display=true').json for flow in flows: if flow['request']['host'] == 'm.meituan.com': flow_id = flow['id'] @@ -265,7 +265,7 @@ def test_flow_with_id_and_not_origin(client): def test_flow_with_id_and_origin_capital(client): flow_id = None - flows = client.get('/api/flow').json + flows = client.get('/api/flow?for_display=true').json for flow in flows: if flow['request']['host'] == 'm.meituan.com': flow_id = flow['id'] @@ -277,7 +277,7 @@ def test_flow_with_id_and_origin_capital(client): def test_flow_with_id_and_not_origin_capital(client): flow_id = None - flows = client.get('/api/flow').json + flows = client.get('/api/flow?for_display=true').json for flow in flows: if flow['request']['host'] == 'm.meituan.com': flow_id = flow['id'] @@ -289,7 +289,7 @@ def test_flow_with_id_and_not_origin_capital(client): def test_flow_with_id_and_origin_and_decode(client): flow_id = None - flows = client.get('/api/flow').json + flows = client.get('/api/flow?for_display=true').json for flow in flows: if flow['request']['host'] == 'm.meituan.com': flow_id = flow['id'] @@ -302,7 +302,7 @@ def test_flow_with_id_and_origin_and_decode(client): def test_flow_with_id_and_not_origin_and_decode(client): flow_id = None - flows = client.get('/api/flow').json + flows = client.get('/api/flow?for_display=true').json for flow in flows: if flow['request']['host'] == 'm.meituan.com': flow_id = flow['id'] @@ -315,7 +315,7 @@ def test_flow_with_id_and_not_origin_and_decode(client): def test_flow_with_id_and_origin_and_not_decode(client): flow_id = None - flows = client.get('/api/flow').json + flows = client.get('/api/flow?for_display=true').json for flow in flows: if flow['request']['host'] == 'm.meituan.com': flow_id = flow['id'] @@ -328,7 +328,7 @@ def test_flow_with_id_and_origin_and_not_decode(client): def test_flow_with_id_and_not_origin_and_not_decode(client): flow_id = None - flows = client.get('/api/flow').json + flows = client.get('/api/flow?for_display=true').json for flow in flows: if flow['request']['host'] == 'm.meituan.com': flow_id = flow['id']