import django_rq from django.http import JsonResponse from .tasks import background_task import os from .src.logger import get_logger logger = get_logger() # TODO: Queues with priorities, process_raw_urls, process_error_urls least priority due to slowdown logic def trigger_task(request, task): """View that enqueues a task.""" """ if ("fetch_" in task): priority = "low" job_timeout="30m" elif ("process_" in task): priority = "medium" job_timeout="30m" """ queue = django_rq.get_queue('default') # Get the default queue job = queue.enqueue(background_task, task, job_timeout="30m") return JsonResponse({"message": "Task has been enqueued!", "job_id": job.id}) def link_list(request): prefix = "http://localhost:8000/api" links = ["fetch_feeds", "fetch_parser", "fetch_search", "process_raw_urls_50", "process_error_urls_50", "process_missing_kids_urls_50", "process_missing_kids_urls_500000"] db_links = ["http://localhost:8080/?pgsql=matitos_db&username=supermatitos&db=matitos&ns=public&select=urls&order%5B0%5D=id&limit=500"] return JsonResponse({"links": db_links + [os.path.join(prefix, l) for l in links]})