From d165963f94610735b83a4130bd3fcbbbb9ccdcac Mon Sep 17 00:00:00 2001 From: Anderson T Date: Tue, 29 Oct 2024 23:47:21 -0700 Subject: [PATCH 1/5] add g++ which is needed for playwright --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index db10c00..2dea3cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM python:3-slim as build +RUN apt-get update && apt-get install -y g++ + # install requirements COPY requirements.txt requirements.txt RUN pip3 install -r requirements.txt --no-cache-dir option @@ -13,4 +15,4 @@ COPY main.py main.py COPY api.py api.py # run code -CMD ["python3", "-u", "main.py"] \ No newline at end of file +CMD ["python3", "-u", "main.py"] From 33042ba541d8dd8f0967bc865d34e53e2801d066 Mon Sep 17 00:00:00 2001 From: Anderson T Date: Wed, 30 Oct 2024 15:15:02 -0700 Subject: [PATCH 2/5] run daily() on startup --- api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api.py b/api.py index 276b152..4563eeb 100644 --- a/api.py +++ b/api.py @@ -75,7 +75,7 @@ def daily(use_cache: bool = False): # have to run our scraping in a separate thread def thread_task(): # hourly() - # daily() + daily() while True: run_pending() time.sleep(1) @@ -409,4 +409,4 @@ async def allCourses( # if API_KEY == os.getenv("API_KEY") or os.getenv("DEBUG") == True: # controller.buildDatabase() # else: -# return False \ No newline at end of file +# return False From b050bad25276d6481ae125fceef418d4d8e730a2 Mon Sep 17 00:00:00 2001 From: Anderson T Date: Wed, 30 Oct 2024 16:57:58 -0700 Subject: [PATCH 3/5] Update Controller.py --- Controller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Controller.py b/Controller.py index 27f3622..5b13f39 100644 --- a/Controller.py +++ b/Controller.py @@ -81,7 +81,7 @@ def checkIfNextSemesterExistsAndUpdate(self): latestSemester = Controller.getLatestSemester(self.engine) year = latestSemester[0] term = latestSemester[1] - year, term = self.incrementTerm(year, term) + year, term = Controller.incrementTerm(year, term) termHTML = fetchTermFromWeb(year, term, use_cache=False) if termHTML == None: @@ -657,4 +657,4 @@ def _generatePreBuilds(self) -> None: # nonce = "7c0c2d0f29" transfers = getTransferInformation(use_cache=False) - # c.updateLatestSemester() \ No newline at end of file + # c.updateLatestSemester() From 2c9ca196a097272ee17ea92a9e16c2e8c687ab82 Mon Sep 17 00:00:00 2001 From: Anderson T Date: Wed, 30 Oct 2024 16:59:34 -0700 Subject: [PATCH 4/5] Update api.py --- api.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api.py b/api.py index 4563eeb..b7fa18d 100644 --- a/api.py +++ b/api.py @@ -75,11 +75,11 @@ def daily(use_cache: bool = False): # have to run our scraping in a separate thread def thread_task(): # hourly() - daily() + # daily() while True: run_pending() time.sleep(1) - + thread = Thread(target=thread_task) thread.start() @@ -113,6 +113,7 @@ async def lifespan(app: FastAPI): print("Database found.") controller.create_db_and_tables() hourly(use_cache=True) + controller.checkIfNextSemesterExistsAndUpdate() else: print("Database not found. Building database from scratch.") # save results to cache if cache doesn't exist From 914ca79067a5f834708fa583e62be1748451343f Mon Sep 17 00:00:00 2001 From: Anderson T Date: Wed, 30 Oct 2024 17:34:23 -0700 Subject: [PATCH 5/5] Update api.py --- api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api.py b/api.py index b7fa18d..c97f73b 100644 --- a/api.py +++ b/api.py @@ -112,8 +112,8 @@ async def lifespan(app: FastAPI): if (os.path.exists(DB_LOCATION)): print("Database found.") controller.create_db_and_tables() - hourly(use_cache=True) controller.checkIfNextSemesterExistsAndUpdate() + hourly(use_cache=True) else: print("Database not found. Building database from scratch.") # save results to cache if cache doesn't exist