Skip to content

Commit

Permalink
Bugfix/query flowlist with extra parameter (#876)
Browse files Browse the repository at this point in the history
* fix,inspector request miss data

* query flowlist with extra parameter

* update

* update

* update
  • Loading branch information
echoyang7 authored Oct 25, 2024
1 parent 3646880 commit 86f949a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 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
11 changes: 8 additions & 3 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 for_display == False and item['duration'] == 0:
continue

info = dict(
id=item['id'],
size=item['size'],
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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')
30 changes: 15 additions & 15 deletions tests/test_flow_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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']
Expand All @@ -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']
Expand All @@ -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']
Expand All @@ -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']
Expand All @@ -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']
Expand All @@ -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']
Expand All @@ -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']
Expand All @@ -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']
Expand All @@ -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']
Expand All @@ -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']
Expand All @@ -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']
Expand All @@ -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']
Expand All @@ -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']
Expand All @@ -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']
Expand Down

0 comments on commit 86f949a

Please sign in to comment.