diff --git a/scripts/install_first_pro.py b/scripts/install_first_pro.py index 065c10bb..d15c4b6d 100644 --- a/scripts/install_first_pro.py +++ b/scripts/install_first_pro.py @@ -7,7 +7,7 @@ from redis import asyncio as aioredis -from services.pro import ProService +from services.pro import ProService, ProConst from services.pack import PackService from services.rate import RateService import config @@ -16,6 +16,13 @@ async def main(): db = await asyncpg.create_pool(database=config.DBNAME_OJ, user=config.DBUSER_OJ, password=config.DBPW_OJ, host=config.DBHOST_OJ) rs = aioredis.Redis(host=config.REDIS_HOST, port=6379, db=config.REDIS_DB) pro_service = ProService(db, rs) + + _, prolist = await pro_service.list_pro([ProConst.STATUS_ONLINE, ProConst.STATUS_CONTEST, ProConst.STATUS_HIDDEN]) + if len(prolist) != 0: + print("Skip HelloTOJ installation") + + return + pack_service = PackService(db, rs) _ = RateService(db, rs) diff --git a/scripts/runserver.sh b/scripts/runserver.sh index 27f1fbad..2161dd42 100755 --- a/scripts/runserver.sh +++ b/scripts/runserver.sh @@ -3,9 +3,9 @@ until pg_isready -h ${DB_CONTAINER_NAME} -p 5432; do sleep 2 done -should_install_first_problem=false +should_check_first_problem=false if [[ -f docker-dev || -f docker-release ]] && [ -d static-tmp ]; then - should_install_first_problem=true + should_check_first_problem=true ./scripts/docker-init.sh fi @@ -19,18 +19,18 @@ then cd .. rm -rf migration - if [ "$should_install_first_problem" = true ] ; then + if [ "$should_check_first_problem" = true ] ; then python3 scripts/install_first_pro.py fi else poetry run python3 migration.py cd .. - if [ "$should_install_first_problem" = true ] ; then + if [ "$should_check_first_problem" = true ] ; then poetry run python3 scripts/install_first_pro.py fi fi - if [ "$should_install_first_problem" = true ] ; then + if [ "$should_check_first_problem" = true ] ; then rm scripts/install_first_pro.py fi fi