Skip to content

Commit

Permalink
removed the offset and limit from method parameters for get_all_players
Browse files Browse the repository at this point in the history
  • Loading branch information
btambara committed Apr 20, 2024
1 parent 86e1bbd commit c1b9666
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
18 changes: 6 additions & 12 deletions api/src/player/crud/player_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ def get_player(db: Session, id: int) -> Optional[Player]:
return db.query(Player).filter(Player.id == id).first() # type: ignore[no-any-return]


def get_all_players(
db: Session, position: str | None = None, skip: int = 0, limit: int = 100
) -> List[Player]:
all_players = db.query(Player).offset(skip).limit(limit).all()
def get_all_players(db: Session, position: str | None = None) -> List[Player]:
all_players = db.query(Player).all()

if len(all_players) == 0 and settings.environment != "TEST":
for team in statsapi.get("teams", {"sportId": 1})[
Expand All @@ -41,19 +39,15 @@ def get_all_players(
)
create_player(db, player_create)

all_players = (
db.query(Player).offset(skip).limit(limit).all()
) # pragma: no cover (This will call MLB api, so for now I'm not testing this)
all_players = db.query(
Player
).all() # pragma: no cover (This will call MLB api, so for now I'm not testing this)

if not position:
return all_players # type: ignore[no-any-return]
else:
return ( # type: ignore[no-any-return]
db.query(Player)
.filter(Player.primary_position_code == position)
.offset(skip)
.limit(limit)
.all()
db.query(Player).filter(Player.primary_position_code == position).all()
)


Expand Down
4 changes: 1 addition & 3 deletions api/src/player/routers/players_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,8 @@ async def read_all_players(
*,
db: Session = Depends(get_db),
position: str | None = None,
skip: int = 0,
limit: int = 100,
) -> List[Player]:
"""
Get all players.
"""
return player_crud.get_all_players(db=db, position=position, skip=skip, limit=limit)
return player_crud.get_all_players(db=db, position=position)

1 comment on commit c1b9666

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytest Coverage

Coverage Report
FileStmtsMissCoverMissing
api/src
   main.py40100% 
api/src/api
   __init__.py00100% 
   deps.py100100% 
api/src/api/api_v1
   __init__.py00100% 
   api.py90100% 
api/src/auth_token
   __init__.py00100% 
   token_model.py80100% 
api/src/db
   __init__.py00100% 
   database.py180100% 
api/src/player
   __init__.py00100% 
api/src/player/crud
   __init__.py00100% 
   celery_crud.py30100% 
   pitches_crud.py340100% 
   player_crud.py410100% 
   stats_crud.py320100% 
api/src/player/models
   __init__.py00100% 
   player.py430100% 
api/src/player/routers
   __init__.py00100% 
   celery_endpoints.py70100% 
   pitches_endpoints.py380100% 
   players_endpoints.py540100% 
   stats_endpoints.py360100% 
api/src/player/schemas
   __init__.py00100% 
   pitches_schemas.py240100% 
   player_schemas.py160100% 
   stats_schemas.py240100% 
api/src/proj
   __init__.py00100% 
   celery.py20100% 
   tasks.py90100% 
api/src/security
   __init__.py00100% 
   helpers.py45687%26, 40, 65, 67–68, 71
   oauth2.py20100% 
api/src/settings
   __init__.py00100% 
   config.py190100% 
api/src/tests
   __init__.py00100% 
   conftest.py400100% 
   test_pitches_endpoints.py590100% 
   test_player_endpoints.py1080100% 
   test_stats_endpoints.py590100% 
   test_user_endpoints.py630100% 
api/src/user
   __init__.py00100% 
   user_crud.py340100% 
   user_endpoints.py510100% 
   user_model.py90100% 
   user_schemas.py110100% 
TOTAL912699% 

Tests Skipped Failures Errors Time
41 0 💤 0 ❌ 0 🔥 9.928s ⏱️

Please sign in to comment.