Merge pull request #13 from okapteinis/claude/code-quality-fixes-01WNkTGGrYURxe9JATA3gX6y

Improve code quality per PR #11 and #12 review feedback
This commit is contained in:
Ojārs Kapteinis 2025-11-19 00:47:22 +02:00 committed by GitHub
commit b51743bb3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 11 deletions

View file

@ -138,7 +138,8 @@ class Config:
# CORS Configuration
# Comma-separated list of allowed origins, defaults to frontend URL
# Note: Wildcard "*" is not allowed when allow_credentials=True
_cors_origins_str = os.getenv("CORS_ORIGINS", os.getenv("NEXT_FRONTEND_URL", "http://localhost:3000"))
_default_cors_origin = os.getenv("NEXT_FRONTEND_URL", "http://localhost:3000")
_cors_origins_str = os.getenv("CORS_ORIGINS", _default_cors_origin)
CORS_ORIGINS = [origin.strip() for origin in _cors_origins_str.split(",") if origin.strip()]
# Google OAuth

View file

@ -26,7 +26,12 @@ from app.schemas import (
)
from app.users import current_active_user
from app.utils.check_ownership import check_ownership
from app.tasks.celery_tasks.document_tasks import process_file_upload_task
from app.tasks.celery_tasks.document_tasks import (
process_crawled_url_task,
process_extension_document_task,
process_file_upload_task,
process_youtube_video_task,
)
try:
asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy())
@ -34,8 +39,6 @@ except RuntimeError as e:
print("Error setting event loop policy", e)
pass
import os
os.environ["UNSTRUCTURED_HAS_PATCHED_LOOP"] = "1"
@ -53,10 +56,6 @@ async def create_documents(
await check_ownership(session, SearchSpace, request.search_space_id, user)
if request.document_type == DocumentType.EXTENSION:
from app.tasks.celery_tasks.document_tasks import (
process_extension_document_task,
)
for individual_document in request.content:
# Convert document to dict for Celery serialization
document_dict = {
@ -70,14 +69,11 @@ async def create_documents(
document_dict, request.search_space_id, str(user.id)
)
elif request.document_type == DocumentType.CRAWLED_URL:
from app.tasks.celery_tasks.document_tasks import process_crawled_url_task
for url in request.content:
process_crawled_url_task.delay(
url, request.search_space_id, str(user.id)
)
elif request.document_type == DocumentType.YOUTUBE_VIDEO:
from app.tasks.celery_tasks.document_tasks import process_youtube_video_task
for url in request.content:
process_youtube_video_task.delay(