fix initial run
This commit is contained in:
@@ -17,7 +17,8 @@ from starlette.middleware import Middleware
|
||||
from starlette_context import context, plugins
|
||||
from starlette_context.middleware import RawContextMiddleware
|
||||
|
||||
if os.path.isfile("first_run"):
|
||||
if os.path.isfile("first_run") and os.environ.get("RELOAD_ON_FIRST_RUN"):
|
||||
print("First run ... load data")
|
||||
with SessionLocal() as db:
|
||||
asyncio.run(admin.create_upload_file(include_non_singable=True, db=db))
|
||||
os.remove("first_run")
|
||||
|
||||
@@ -68,10 +68,13 @@ def get_spotify_id(url):
|
||||
@router.post("/load_list")
|
||||
async def create_upload_file(include_non_singable: bool = False, db: Session = Depends(get_db)):
|
||||
|
||||
print("load list")
|
||||
Base.metadata.drop_all(engine)
|
||||
Base.metadata.create_all(engine)
|
||||
|
||||
song_list = pd.read_excel(os.environ['LIST_URL'])
|
||||
|
||||
print(song_list)
|
||||
song_list = song_list.replace({np.nan: None})
|
||||
song_list = song_list.replace({"n/a": None})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user