From 9ac6e1b7964e8f79ee87d5d65e2f7010f6ed694e Mon Sep 17 00:00:00 2001 From: Xevion Date: Sun, 23 Apr 2023 14:31:54 -0500 Subject: [PATCH] Setup main.py logging, seed.main call, add util.py --- main.py | 9 ++++++++- src/util.py | 13 +++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/util.py diff --git a/main.py b/main.py index 81dbe2e..71d52e3 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,15 @@ from psycopg2 import connect from src.seed import main +import logging + +logger = logging.getLogger(__name__) +logging.basicConfig(level=logging.ERROR) +logger.setLevel(logging.DEBUG) + if __name__ == '__main__': conn = connect(dbname='railway', user='postgres', password='8h9hxh5YeBwfqTCrxQQb', host='containers-us-west-174.railway.app', port='7238') + logger.info('Connected to database.') - main(conn) + main(conn, 250, 1000, 500) diff --git a/src/util.py b/src/util.py new file mode 100644 index 0000000..de1e5a2 --- /dev/null +++ b/src/util.py @@ -0,0 +1,13 @@ +import random +from datetime import datetime, timedelta + + +def logarithmic_randint(min: int, max: int) -> int: + """Return a random integer between min and max, inclusive, with a logarithmic distribution.""" + # TODO: Implement + return 0 + + +def get_relative_date(min: int, max: int) -> datetime: + """Return a random date between min and max days ago, inclusive.""" + return datetime.now() - timedelta(days=random.randint(min, max))