diff --git a/django_code/stash_management/apps.py b/django_code/stash_management/apps.py index 88f91ba..74d430d 100644 --- a/django_code/stash_management/apps.py +++ b/django_code/stash_management/apps.py @@ -4,7 +4,7 @@ from django.shortcuts import render from django.shortcuts import redirect from django.core.files import File from kubernetes import client, config -from celery import shared_task,group +from celery import shared_task from lxml import html import requests @@ -18,15 +18,8 @@ import yaml from urllib import request as urlrequest from urllib import parse as urlparse -BASE_URL="https://prowlarr.tryton.geeraert.eu" -API_KEY="c5655e0b915d46dbb68d80f40a2daae4" -APP_PROFILE_ID = 1 # The ID you want to inject -headers = { - "accept": "application/json", - "X-Api-Key": API_KEY -} proxy_url = 'http://gluetun-svc.gluetun.svc:8888' @@ -279,37 +272,4 @@ def handle_survey_form(request): -@shared_task(bind=True, max_retries=3, rate_limit='10/s') -def process_indexer_task(self, indexer, app_profile_id): - """Processes a single indexer POST request.""" - indexer['appProfileId'] = app_profile_id - headers = {"accept": "application/json", "X-Api-Key": API_KEY} - - try: - response = requests.post(f"{BASE_URL}/api/v1/indexer", headers=headers, json=indexer) - response.raise_for_status() - return f"Successfully added {indexer.get('name')}" - except requests.exceptions.RequestException as exc: - # Retry individual failure without affecting other 599 tasks - raise self.retry(exc=exc, countdown=60) - -@shared_task -def run_bulk_indexer_import(app_profile_id=1): - """Orchestrates the bulk import of all available indexers.""" - headers = {"accept": "application/json", "X-Api-Key": API_KEY} - response = requests.get(f"{BASE_URL}/api/v1/indexer/schema", headers=headers) - - if response.status_code == 200: - available_indexers = response.json() - - # Create a group of individual tasks - job = group( - process_indexer_task.s(indexer, app_profile_id) - for indexer in available_indexers - ) - job.apply_async() - - - -