setup timer for create database.

This commit is contained in:
iamBadgers
2025-06-02 20:45:25 -07:00
parent f6fcf82eae
commit 9801ba4ba6
7 changed files with 52 additions and 48 deletions

11
loader/Dockerfile Normal file
View File

@@ -0,0 +1,11 @@
# Setup the loader
FROM python:3.12 AS loader
COPY . /loader
WORKDIR /loader
RUN python -m pip install --upgrade pip
RUN pip install -r requirements.txt
ENV REPLAY_TIME=0
CMD ["sh", "-c", "python3 createrushdatabase.py -r $REPLAY_TIME"]

View File

@@ -1,15 +0,0 @@
#!/bin/bash
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
PYTHON_VEN="$parent_path"/venv/bin/python
if [ ! -f $PYTHON_VEN ]; then
echo "Setting up new VENV"
python3 -m venv venv
echo "Installing requirements."
source ./venv/bin/activate
pip install -r requirements.txt
deactivate
fi
echo "Start DB Creation"
$parent_path/venv/bin/python createrushdatabase.py

View File

@@ -1,9 +1,18 @@
import time
import argparse
from databasesync import createDatabase
from sheetloader import downloadGamesCSV, downloadCharactersCSV
parser = argparse.ArgumentParser()
parser.add_argument("-r", "--replay_time", type=int)
args = parser.parse_args()
CHARACTER_DATA_OUT_FILE = "CharacterData.csv"
GAME_DATA_OUT_FILE = "GameData.csv"
DATABASE_NAME = "testdb.db"
def execute():
downloadCharactersCSV(CHARACTER_DATA_OUT_FILE)
@@ -11,4 +20,10 @@ def execute():
createDatabase(DATABASE_NAME, GAME_DATA_OUT_FILE, CHARACTER_DATA_OUT_FILE)
if __name__ == "__main__":
print("starting up loader.")
print("replay time: ", args.replay_time)
execute()
while args.replay_time and args.replay_time > 0:
print("re-run in ", args.replay_time, "seconds", flush=True)
time.sleep(args.replay_time)
execute()

View File

@@ -1 +0,0 @@
*/10 * * * * python3 /loader/createrushdatabase.py