Refactoring fetcher WIP
This commit is contained in:
@@ -30,6 +30,8 @@ from src.missing_kids_status import MissingKidsStatus
|
||||
from src.url_status import UpdateErrorURLs
|
||||
from src.fetcher_status import FetcherStatus
|
||||
|
||||
from src.db_utils import DB_Handler
|
||||
|
||||
from fastapi import FastAPI, BackgroundTasks
|
||||
# import requests
|
||||
# from fastapi_utils.tasks import repeat_every
|
||||
@@ -37,11 +39,13 @@ from fastapi import FastAPI, BackgroundTasks
|
||||
# time.sleep(10)
|
||||
# import gc
|
||||
|
||||
db_handler = DB_Handler(cred.db_connect_info, cred.redis_connect_info)
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
@app.get("/")
|
||||
def hello_world():
|
||||
return {"message": "OK"}
|
||||
return {"message": "Ok"}
|
||||
|
||||
@app.get("/{fetch_type}")
|
||||
async def fetch(background_tasks: BackgroundTasks, fetch_type: str):
|
||||
@@ -49,9 +53,9 @@ async def fetch(background_tasks: BackgroundTasks, fetch_type: str):
|
||||
logger.info("Triggered fetch: {}".format(fetch_type))
|
||||
|
||||
if (fetch_type == "feeds"):
|
||||
task_run = NewsFeed(cred.db_connect_info, cred.redis_connect_info).run
|
||||
task_run = NewsFeed(db_handler).run
|
||||
elif (fetch_type == "parser"):
|
||||
task_run = NewsSiteParsing(cred.db_connect_info, cred.redis_connect_info).run
|
||||
task_run = NewsSiteParsing(db_handler).run
|
||||
elif (fetch_type == "fetch_missing_kids_reduced"):
|
||||
task_run = NewsMissingKids(cred.db_connect_info, cred.redis_connect_info, num_pages=4).run
|
||||
elif (fetch_type == "fetch_missing_kids_full"):
|
||||
|
||||
Reference in New Issue
Block a user