diff --git a/app/routers_v2/awards.py b/app/routers_v2/awards.py index 2e09657..774dab3 100644 --- a/app/routers_v2/awards.py +++ b/app/routers_v2/awards.py @@ -55,7 +55,7 @@ async def get_awards( all_awards = all_awards.where(Award.image == image) limit = max(0, min(limit, 500)) - total_count = all_awards.count() + total_count = all_awards.count() if not csv else 0 all_awards = all_awards.limit(limit) if csv: diff --git a/app/routers_v2/batstats.py b/app/routers_v2/batstats.py index d1f9a1a..1180f32 100644 --- a/app/routers_v2/batstats.py +++ b/app/routers_v2/batstats.py @@ -115,7 +115,7 @@ async def get_batstats( # raise HTTPException(status_code=404, detail=f'No batting stats found') limit = max(0, min(limit, 500)) - total_count = all_stats.count() + total_count = all_stats.count() if not csv else 0 all_stats = all_stats.limit(limit) if csv: diff --git a/app/routers_v2/battingcardratings.py b/app/routers_v2/battingcardratings.py index cd7ebd0..d881d04 100644 --- a/app/routers_v2/battingcardratings.py +++ b/app/routers_v2/battingcardratings.py @@ -179,7 +179,7 @@ async def get_card_ratings( ) all_ratings = all_ratings.where(BattingCardRatings.battingcard << set_cards) - total_count = all_ratings.count() + total_count = all_ratings.count() if not csv else 0 all_ratings = all_ratings.limit(max(0, min(limit, 500))) if csv: diff --git a/app/routers_v2/events.py b/app/routers_v2/events.py index 28d2915..a5f3b1f 100644 --- a/app/routers_v2/events.py +++ b/app/routers_v2/events.py @@ -40,7 +40,7 @@ async def v1_events_get( if active is not None: all_events = all_events.where(Event.active == active) - total_count = all_events.count() + total_count = all_events.count() if not csv else 0 all_events = all_events.limit(max(0, min(limit, 500))) if csv: diff --git a/app/routers_v2/gamerewards.py b/app/routers_v2/gamerewards.py index ac4fb38..86448c6 100644 --- a/app/routers_v2/gamerewards.py +++ b/app/routers_v2/gamerewards.py @@ -43,7 +43,7 @@ async def v1_gamerewards_get( all_rewards = all_rewards.where(GameRewards.money == money) limit = max(0, min(limit, 500)) - total_count = all_rewards.count() + total_count = all_rewards.count() if not csv else 0 all_rewards = all_rewards.limit(limit) if csv: diff --git a/app/routers_v2/mlbplayers.py b/app/routers_v2/mlbplayers.py index 055cc1a..37a38fc 100644 --- a/app/routers_v2/mlbplayers.py +++ b/app/routers_v2/mlbplayers.py @@ -102,7 +102,7 @@ async def get_players( if offense_col is not None: all_players = all_players.where(MlbPlayer.offense_col << offense_col) - total_count = all_players.count() + total_count = all_players.count() if not csv else 0 all_players = all_players.limit(max(0, min(limit, 500))) if csv: diff --git a/app/routers_v2/pitchingcardratings.py b/app/routers_v2/pitchingcardratings.py index 9506e83..78153b4 100644 --- a/app/routers_v2/pitchingcardratings.py +++ b/app/routers_v2/pitchingcardratings.py @@ -169,7 +169,7 @@ async def get_card_ratings( ) all_ratings = all_ratings.where(PitchingCardRatings.pitchingcard << set_cards) - total_count = all_ratings.count() + total_count = all_ratings.count() if not csv else 0 all_ratings = all_ratings.limit(max(0, min(limit, 500))) if csv: diff --git a/app/routers_v2/pitstats.py b/app/routers_v2/pitstats.py index 34ca7de..c03fc45 100644 --- a/app/routers_v2/pitstats.py +++ b/app/routers_v2/pitstats.py @@ -98,7 +98,7 @@ async def get_pit_stats( if gs is not None: all_stats = all_stats.where(PitchingStat.gs == 1 if gs else 0) - total_count = all_stats.count() + total_count = all_stats.count() if not csv else 0 all_stats = all_stats.limit(max(0, min(limit, 500))) # if all_stats.count() == 0: diff --git a/app/routers_v2/results.py b/app/routers_v2/results.py index d6fa854..2ba50e9 100644 --- a/app/routers_v2/results.py +++ b/app/routers_v2/results.py @@ -142,7 +142,7 @@ async def get_results( all_results = all_results.order_by(Result.id) limit = max(0, min(limit, 500)) - total_count = all_results.count() + total_count = all_results.count() if not csv else 0 all_results = all_results.limit(limit) # Not functional # if vs_ai is not None: diff --git a/app/routers_v2/rewards.py b/app/routers_v2/rewards.py index f28b3d7..ec63d83 100644 --- a/app/routers_v2/rewards.py +++ b/app/routers_v2/rewards.py @@ -34,9 +34,6 @@ async def get_rewards( ): all_rewards = Reward.select().order_by(Reward.id) - if all_rewards.count() == 0: - raise HTTPException(status_code=404, detail="There are no rewards to filter") - if name is not None: all_rewards = all_rewards.where(fn.Lower(Reward.name) == name.lower()) if team_id is not None: @@ -52,11 +49,11 @@ async def get_rewards( if week is not None: all_rewards = all_rewards.where(Reward.week == week) - if all_rewards.count() == 0: + total_count = all_rewards.count() + if total_count == 0: raise HTTPException(status_code=404, detail="No rewards found") limit = max(0, min(limit, 500)) - total_count = all_rewards.count() all_rewards = all_rewards.limit(limit) if csv: diff --git a/app/routers_v2/scout_claims.py b/app/routers_v2/scout_claims.py index 7cbfb2c..0751682 100644 --- a/app/routers_v2/scout_claims.py +++ b/app/routers_v2/scout_claims.py @@ -30,12 +30,10 @@ async def get_scout_claims( if claimed_by_team_id is not None: query = query.where(ScoutClaim.claimed_by_team_id == claimed_by_team_id) - if limit is not None: - limit = max(0, min(limit, 500)) - total_count = query.count() if limit is not None: + limit = max(0, min(limit, 500)) query = query.limit(limit) results = [model_to_dict(x, recurse=False) for x in query] diff --git a/app/routers_v2/scout_opportunities.py b/app/routers_v2/scout_opportunities.py index 4022588..474eff1 100644 --- a/app/routers_v2/scout_opportunities.py +++ b/app/routers_v2/scout_opportunities.py @@ -35,7 +35,7 @@ async def get_scout_opportunities( limit: Optional[int] = 100, ): - limit = max(1, min(limit, 500)) + limit = max(0, min(limit, 500)) query = ScoutOpportunity.select().order_by(ScoutOpportunity.id) if opener_team_id is not None: diff --git a/app/routers_v2/stratgame.py b/app/routers_v2/stratgame.py index 27bacea..e6492c3 100644 --- a/app/routers_v2/stratgame.py +++ b/app/routers_v2/stratgame.py @@ -78,7 +78,7 @@ async def get_games( StratGame.game_type.contains(f"gauntlet-{gauntlet_id}") ) - total_count = all_games.count() + total_count = all_games.count() if not csv else 0 all_games = all_games.limit(max(0, min(limit, 500))) if csv: