File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 66from fastapi_cache .backends .inmemory import InMemoryBackend
77
88from gs .backend .data .database .engine import get_db_session , setup_database
9- from gs .backend .data .resources .utils import add_main_commands
9+ from gs .backend .data .resources .utils import add_callsigns , add_main_commands
1010
1111
1212@asynccontextmanager
@@ -19,4 +19,5 @@ async def lifespan(_: FastAPI) -> AsyncGenerator[None, None]:
1919 # Otherwise, will get transaction is inactive error
2020 setup_database (get_db_session ())
2121 add_main_commands (get_db_session ())
22+ add_callsigns (get_db_session ())
2223 yield
Original file line number Diff line number Diff line change 11from sqlmodel import Session , select
22
3+ from gs .backend .data .resources .callsigns import callsigns
34from gs .backend .data .resources .main_commands import main_commands
45from gs .backend .data .tables .main_tables import MainCommand
56
@@ -10,6 +11,17 @@ def add_main_commands(session: Session) -> None:
1011 """
1112 query = select (MainCommand ).limit (1 ) # Check if the db is empty
1213 result = session .exec (query ).first ()
13- if result is None :
14+ if not result :
1415 session .add_all (main_commands ())
1516 session .commit ()
17+
18+
19+ def add_callsigns (session : Session ) -> None :
20+ """
21+ Setup the valid callsigns to the database
22+ """
23+ query = select (MainCommand ).limit (1 )
24+ result = session .exec (query ).first ()
25+ if not result :
26+ session .add_all (callsigns ())
27+ session .commit ()
You can’t perform that action at this time.
0 commit comments