fix imports
This commit is contained in:
parent
fea959b237
commit
59d31704bd
@ -3,6 +3,8 @@ from fastapi_utils.cbv import cbv
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
import models
|
||||
import models.schemas
|
||||
import models.album
|
||||
|
||||
from database import get_db
|
||||
|
||||
@ -14,11 +16,11 @@ class Albums:
|
||||
session: Session = Depends(get_db)
|
||||
|
||||
# API to get the list of album info
|
||||
@router.get("/albums", response_model=models.schemas.PaginatedAlbum)
|
||||
def list_albums(self, limit: int = 10, offset: int = 0):
|
||||
@router.get("/albums", response_model=models.schemas.Albums)
|
||||
def list_albums(self):
|
||||
|
||||
albums_list = models.album.get_all_albums(self.session, limit, offset)
|
||||
response = {"limit": limit, "offset": offset, "data": albums_list}
|
||||
albums_list = models.album.get_all_albums(self.session)
|
||||
response = {"data": albums_list}
|
||||
|
||||
return response
|
||||
|
||||
|
@ -19,8 +19,8 @@ class Album(Base):
|
||||
|
||||
|
||||
# Function to get list of album info
|
||||
def get_all_albums(session: Session, limit: int, offset: int) -> List[Album]:
|
||||
return session.query(Album).offset(offset).limit(limit).all()
|
||||
def get_all_albums(session: Session) -> List[Album]:
|
||||
return session.query(Album).all()
|
||||
|
||||
|
||||
# Function to get info of a particular album
|
||||
|
@ -18,7 +18,5 @@ class Album(AlbumBase):
|
||||
|
||||
|
||||
# To support list cars API
|
||||
class PaginatedAlbum(BaseModel):
|
||||
limit: int
|
||||
offset: int
|
||||
class Albums(BaseModel):
|
||||
data: List[Album]
|
||||
|
Loading…
Reference in New Issue
Block a user