Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion scripts/install_first_pro.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
10 changes: 5 additions & 5 deletions scripts/runserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
Loading