Skip to content

Commit

Permalink
Import fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Bas-Korver committed Jun 19, 2024
1 parent f00ff0e commit bf27083
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
6 changes: 4 additions & 2 deletions src/api/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
SQLAlchemyAsyncConfig,
SQLAlchemyPlugin,
)

from sqlalchemy import URL
from models.country import Country
from models.animal import Animal
from models.stream import Stream

from core import settings
from db.connector import redis_connection, postgres_connection
Expand Down Expand Up @@ -75,7 +79,6 @@ def create_app() -> Litestar:
SQLAlchemyPlugin(config=db_config),
],
lifespan=[
# postgres_connection,
redis_connection,
],
on_startup=[
Expand Down Expand Up @@ -119,7 +122,6 @@ def create_app_private() -> Litestar:
app = create_app()
app_private = create_app_private()


if __name__ == "__main__":
# Run the API (for debugging)
# uvicorn.run("main:app", reload=True, reload_dirs="./", port=8002)
Expand Down
2 changes: 1 addition & 1 deletion src/api/api/models/stream.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List
from typing import List, TYPE_CHECKING
from sqlalchemy import Double, String, ForeignKey
from sqlalchemy.orm import (
Mapped,
Expand Down
11 changes: 4 additions & 7 deletions src/api/api/routers/v1/internal.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
from dataclasses import dataclass
from typing import Annotated
from litestar import Controller, get, Request, post, Response, MediaType
from litestar.exceptions import *
from litestar.enums import RequestEncodingType

from litestar import Controller, post, Response, MediaType
from litestar.params import Body
from sqlalchemy import select
from sqlalchemy.dialects.postgresql import insert
from sqlalchemy.ext.asyncio import AsyncSession

from sqlalchemy.dialects.postgresql import insert
from sqlalchemy import select
from models.country import Country
from models.animal import Animal
from models.stream import Stream
from litestar.datastructures import State
from models.streams_animals import streams_animals


Expand Down
11 changes: 6 additions & 5 deletions src/api/api/routers/v1/internal_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

from sqlalchemy.dialects.postgresql import insert
from sqlalchemy import select
from models.country import Country


from models.animal import Animal
from models.stream import Stream
from litestar.datastructures import State
Expand All @@ -34,13 +35,13 @@ class internalStreamsController(Controller):
dependencies = {"streams_repository": Provide(provide_streams_repository)}

@get("/streams")
async def get_streams(self, stream_repository: StreamRepository) -> list[Stream]:
return await stream_repository.list()
async def get_streams(self, streams_repository: StreamRepository) -> list[Stream]:
return await streams_repository.list()

@get("/streams/{stream_id:int}")
async def get_stream(
self, stream_repository: StreamRepository, stream_id: int
self, streams_repository: StreamRepository, stream_id: int
) -> Stream:
return await stream_repository.get(
return await streams_repository.get(
item_id=stream_id, load=[Stream.tag, Stream.country, Stream.animals]
)

0 comments on commit bf27083

Please sign in to comment.