Skip to content

Commit

Permalink
Feat: 유효성 검증 기능 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hoon committed Mar 18, 2024
1 parent fde0b1e commit 22f7eae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
19 changes: 10 additions & 9 deletions src/app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ async def welcome():

@bp.route('/basketball/player-stats', methods=['GET'])
async def get_player_stats():
params, error = validate_request_params(request.args)
params, error, status = validate_request_params(request.args)

if error:
return jsonify(error), 400
return jsonify(error), status

query_date, player_name = params['query_date'], params.get('player')
stats_scraper = BasketballStats(client, OutputType.JSON, query_date)

Expand All @@ -29,9 +30,9 @@ async def get_player_stats():

@bp.route('/basketball/team-stats', methods=['GET'])
async def get_team_stats():
params, error = validate_request_params(request.args)
params, error, status = validate_request_params(request.args)
if error:
return jsonify(error), 400
return jsonify(error), status

query_date, team_name = params['query_date'], params.get('team')
stats_scraper = BasketballStats(client, OutputType.JSON, query_date)
Expand All @@ -44,9 +45,9 @@ async def get_team_stats():

@bp.route('/basketball/season-standings', methods=['GET'])
async def get_season_standings():
params, error = validate_request_params(request.args)
params, error, status = validate_request_params(request.args)
if error:
return jsonify(error), 400
return jsonify(error), status

query_date = params['query_date']
stats_scraper = BasketballStats(client, OutputType.JSON, query_date)
Expand All @@ -56,9 +57,9 @@ async def get_season_standings():

@bp.route('/basketball/team-season-record', methods=['GET'])
async def get_team_season_record():
params, error = validate_request_params(request.args)
params, error, status = validate_request_params(request.args)
if error:
return jsonify(error), 400
return jsonify(error), status

query_date, team_name = params['query_date'], params.get('team')
error, status = require_param(team_name, 'team')
Expand Down
4 changes: 2 additions & 2 deletions src/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ def validate_request_params(args):

query_date, error, status = validate_date(query_date_str)
if error:
return error, status
return query_date, error, status

return {"query_date": query_date, "player": player_name, "team": team_name}, None
return {"query_date": query_date, "player": player_name, "team": team_name}, None, 200

0 comments on commit 22f7eae

Please sign in to comment.