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