fix: replace raise HTTPException(status_code=200) with return statements (#16) #47

Closed
cal wants to merge 1 commits from ai/paper-dynasty-database#16 into next-release
16 changed files with 22 additions and 22 deletions

View File

@ -136,7 +136,7 @@ async def delete_award(award_id, token: str = Depends(oauth2_scheme)):
count = this_award.delete_instance()
if count == 1:
raise HTTPException(status_code=200, detail=f'Award {award_id} has been deleted')
return {"detail": f'Award {award_id} has been deleted'}
else:
raise HTTPException(status_code=500, detail=f'Award {award_id} was not deleted')

View File

@ -223,7 +223,7 @@ async def post_batstats(stats: BattingStatModel, token: str = Depends(oauth2_sch
with db.atomic():
BattingStat.bulk_create(new_stats, batch_size=15)
raise HTTPException(status_code=200, detail=f'{len(new_stats)} batting lines have been added')
return {"detail": f'{len(new_stats)} batting lines have been added'}
@router.delete('/{stat_id}', include_in_schema=PRIVATE_IN_SCHEMA)
@ -242,7 +242,7 @@ async def delete_batstat(stat_id, token: str = Depends(oauth2_scheme)):
count = this_stat.delete_instance()
if count == 1:
raise HTTPException(status_code=200, detail=f'Stat {stat_id} has been deleted')
return {"detail": f'Stat {stat_id} has been deleted'}
else:
raise HTTPException(status_code=500, detail=f'Stat {stat_id} was not deleted')

View File

@ -181,7 +181,7 @@ async def v1_cards_post(cards: CardModel, token: str = Depends(oauth2_scheme)):
cost_query.execute()
# sheets.post_new_cards(SHEETS_AUTH, lc_id)
raise HTTPException(status_code=200, detail=f'{len(new_cards)} cards have been added')
return {"detail": f'{len(new_cards)} cards have been added'}
# @router.post('/ai-update')
@ -195,7 +195,7 @@ async def v1_cards_post(cards: CardModel, token: str = Depends(oauth2_scheme)):
# )
#
# sheets.send_ai_cards(SHEETS_AUTH)
# raise HTTPException(status_code=200, detail=f'Just sent AI cards to sheets')
# return {"detail": f'Just sent AI cards to sheets'}
@router.post('/legal-check/{rarity_name}')
@ -241,7 +241,7 @@ async def v1_cards_post_update(starting_id: int, token: str = Depends(oauth2_sch
)
# sheets.post_new_cards(SHEETS_AUTH, starting_id)
raise HTTPException(status_code=200, detail=f'Just sent cards to sheets starting at ID {starting_id}')
return {"detail": f'Just sent cards to sheets starting at ID {starting_id}'}
@router.post('/post-delete')
@ -338,6 +338,6 @@ async def v1_cards_delete(card_id, token: str = Depends(oauth2_scheme)):
count = this_card.delete_instance()
if count == 1:
raise HTTPException(status_code=200, detail=f'Card {card_id} has been deleted')
return {"detail": f'Card {card_id} has been deleted'}
else:
raise HTTPException(status_code=500, detail=f'Card {card_id} was not deleted')

View File

@ -247,7 +247,7 @@ async def delete_cardsets(cardset_id, token: str = Depends(oauth2_scheme)):
count = this_cardset.delete_instance()
if count == 1:
raise HTTPException(status_code=200, detail=f'Cardset {cardset_id} has been deleted')
return {"detail": f'Cardset {cardset_id} has been deleted'}
else:
raise HTTPException(status_code=500, detail=f'Cardset {cardset_id} was not deleted')

View File

@ -142,6 +142,6 @@ async def delete_current(current_id, token: str = Depends(oauth2_scheme)):
count = this_curr.delete_instance()
if count == 1:
raise HTTPException(status_code=200, detail=f'Current {current_id} has been deleted')
return {"detail": f'Current {current_id} has been deleted'}
else:
raise HTTPException(status_code=500, detail=f'Current {current_id} was not deleted')

View File

@ -169,6 +169,6 @@ async def v1_events_delete(event_id, token: str = Depends(oauth2_scheme)):
count = this_event.delete_instance()
if count == 1:
raise HTTPException(status_code=200, detail=f'Event {event_id} has been deleted')
return {"detail": f'Event {event_id} has been deleted'}
else:
raise HTTPException(status_code=500, detail=f'Event {event_id} was not deleted')

View File

@ -167,7 +167,7 @@ async def v1_gamerewards_delete(gamereward_id, token: str = Depends(oauth2_schem
count = this_award.delete_instance()
if count == 1:
raise HTTPException(status_code=200, detail=f'Game Reward {gamereward_id} has been deleted')
return {"detail": f'Game Reward {gamereward_id} has been deleted'}
else:
raise HTTPException(status_code=500, detail=f'Game Reward {gamereward_id} was not deleted')

View File

@ -179,6 +179,6 @@ async def delete_notif(notif_id, token: str = Depends(oauth2_scheme)):
count = this_notif.delete_instance()
if count == 1:
raise HTTPException(status_code=200, detail=f'Notification {notif_id} has been deleted')
return {"detail": f'Notification {notif_id} has been deleted'}
else:
raise HTTPException(status_code=500, detail=f'Notification {notif_id} was not deleted')

View File

@ -148,7 +148,7 @@ async def post_pack(packs: PackModel, token: str = Depends(oauth2_scheme)):
with db.atomic():
Pack.bulk_create(new_packs, batch_size=15)
raise HTTPException(status_code=200, detail=f'{len(new_packs)} packs have been added')
return {"detail": f'{len(new_packs)} packs have been added'}
@router.post('/one')
@ -240,6 +240,6 @@ async def delete_pack(pack_id, token: str = Depends(oauth2_scheme)):
count = this_pack.delete_instance()
if count == 1:
raise HTTPException(status_code=200, detail=f'Pack {pack_id} has been deleted')
return {"detail": f'Pack {pack_id} has been deleted'}
else:
raise HTTPException(status_code=500, detail=f'Pack {pack_id} was not deleted')

View File

@ -169,6 +169,6 @@ async def delete_packtype(packtype_id, token: str = Depends(oauth2_scheme)):
count = this_packtype.delete_instance()
if count == 1:
raise HTTPException(status_code=200, detail=f'Packtype {packtype_id} has been deleted')
return {"detail": f'Packtype {packtype_id} has been deleted'}
else:
raise HTTPException(status_code=500, detail=f'Packtype {packtype_id} was not deleted')

View File

@ -171,7 +171,7 @@ async def delete_paperdex(paperdex_id, token: str = Depends(oauth2_scheme)):
count = this_dex.delete_instance()
if count == 1:
raise HTTPException(status_code=200, detail=f'Paperdex {this_dex} has been deleted')
return {"detail": f'Paperdex {this_dex} has been deleted'}
else:
raise HTTPException(status_code=500, detail=f'Paperdex {this_dex} was not deleted')

View File

@ -157,7 +157,7 @@ async def post_pitstat(stats: PitchingStatModel, token: str = Depends(oauth2_sch
with db.atomic():
PitchingStat.bulk_create(new_stats, batch_size=15)
raise HTTPException(status_code=200, detail=f'{len(new_stats)} pitching lines have been added')
return {"detail": f'{len(new_stats)} pitching lines have been added'}
@router.delete('/{stat_id}')
@ -176,6 +176,6 @@ async def delete_pitstat(stat_id, token: str = Depends(oauth2_scheme)):
count = this_stat.delete_instance()
if count == 1:
raise HTTPException(status_code=200, detail=f'Stat {stat_id} has been deleted')
return {"detail": f'Stat {stat_id} has been deleted'}
else:
raise HTTPException(status_code=500, detail=f'Stat {stat_id} was not deleted')

View File

@ -161,6 +161,6 @@ async def v1_rarities_delete(rarity_id, token: str = Depends(oauth2_scheme)):
count = this_rarity.delete_instance()
if count == 1:
raise HTTPException(status_code=200, detail=f'Rarity {rarity_id} has been deleted')
return {"detail": f'Rarity {rarity_id} has been deleted'}
else:
raise HTTPException(status_code=500, detail=f'Rarity {rarity_id} was not deleted')

View File

@ -397,7 +397,7 @@ async def delete_result(result_id, token: str = Depends(oauth2_scheme)):
count = this_result.delete_instance()
if count == 1:
raise HTTPException(status_code=200, detail=f'Result {result_id} has been deleted')
return {"detail": f'Result {result_id} has been deleted'}
else:
raise HTTPException(status_code=500, detail=f'Result {result_id} was not deleted')

View File

@ -167,7 +167,7 @@ async def delete_reward(reward_id, token: str = Depends(oauth2_scheme)):
count = this_reward.delete_instance()
if count == 1:
raise HTTPException(status_code=200, detail=f'Reward {reward_id} has been deleted')
return {"detail": f'Reward {reward_id} has been deleted'}
else:
raise HTTPException(status_code=500, detail=f'Reward {reward_id} was not deleted')

View File

@ -1506,6 +1506,6 @@ async def delete_team(team_id, token: str = Depends(oauth2_scheme)):
count = this_team.delete_instance()
if count == 1:
raise HTTPException(status_code=200, detail=f"Team {team_id} has been deleted")
return {"message": f"Team {team_id} has been deleted"}
else:
raise HTTPException(status_code=500, detail=f"Team {team_id} was not deleted")