(refactor:upload) simplify call to /api/remote

This commit is contained in:
ManishMadan2882
2025-02-06 20:16:07 +05:30
parent 1f1e710a6d
commit 72556b37f5
2 changed files with 14 additions and 26 deletions

View File

@@ -3,6 +3,7 @@ import math
import os
import shutil
import uuid
import json
from bson.binary import Binary, UuidRepresentation
from bson.dbref import DBRef
@@ -420,18 +421,22 @@ class UploadRemote(Resource):
return missing_fields
try:
if "repo_url" in data:
source_data = data["repo_url"]
loader = "github"
else:
source_data = data["data"]
loader = data["source"]
config = json.loads(data["data"])
source_data = None
task = ingest_remote.delay(
if data["source"] == "github":
source_data = config.get("repo_url")
elif data["source"] in ["crawler", "url"]:
source_data = config.get("url")
elif data["source"] == "reddit":
source_data = config
task = ingest_remote.delay(
source_data=source_data,
job_name=data["name"],
user=data["user"],
loader=loader,
loader=data["source"]
)
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)