mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-24 23:41:10 +02:00
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:
commit
b51743bb3a
2 changed files with 8 additions and 11 deletions
|
|
@ -138,7 +138,8 @@ class Config:
|
||||||
# CORS Configuration
|
# CORS Configuration
|
||||||
# Comma-separated list of allowed origins, defaults to frontend URL
|
# Comma-separated list of allowed origins, defaults to frontend URL
|
||||||
# Note: Wildcard "*" is not allowed when allow_credentials=True
|
# 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()]
|
CORS_ORIGINS = [origin.strip() for origin in _cors_origins_str.split(",") if origin.strip()]
|
||||||
|
|
||||||
# Google OAuth
|
# Google OAuth
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,12 @@ from app.schemas import (
|
||||||
)
|
)
|
||||||
from app.users import current_active_user
|
from app.users import current_active_user
|
||||||
from app.utils.check_ownership import check_ownership
|
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:
|
try:
|
||||||
asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy())
|
asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy())
|
||||||
|
|
@ -34,8 +39,6 @@ except RuntimeError as e:
|
||||||
print("Error setting event loop policy", e)
|
print("Error setting event loop policy", e)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
os.environ["UNSTRUCTURED_HAS_PATCHED_LOOP"] = "1"
|
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)
|
await check_ownership(session, SearchSpace, request.search_space_id, user)
|
||||||
|
|
||||||
if request.document_type == DocumentType.EXTENSION:
|
if request.document_type == DocumentType.EXTENSION:
|
||||||
from app.tasks.celery_tasks.document_tasks import (
|
|
||||||
process_extension_document_task,
|
|
||||||
)
|
|
||||||
|
|
||||||
for individual_document in request.content:
|
for individual_document in request.content:
|
||||||
# Convert document to dict for Celery serialization
|
# Convert document to dict for Celery serialization
|
||||||
document_dict = {
|
document_dict = {
|
||||||
|
|
@ -70,14 +69,11 @@ async def create_documents(
|
||||||
document_dict, request.search_space_id, str(user.id)
|
document_dict, request.search_space_id, str(user.id)
|
||||||
)
|
)
|
||||||
elif request.document_type == DocumentType.CRAWLED_URL:
|
elif request.document_type == DocumentType.CRAWLED_URL:
|
||||||
from app.tasks.celery_tasks.document_tasks import process_crawled_url_task
|
|
||||||
|
|
||||||
for url in request.content:
|
for url in request.content:
|
||||||
process_crawled_url_task.delay(
|
process_crawled_url_task.delay(
|
||||||
url, request.search_space_id, str(user.id)
|
url, request.search_space_id, str(user.id)
|
||||||
)
|
)
|
||||||
elif request.document_type == DocumentType.YOUTUBE_VIDEO:
|
elif request.document_type == DocumentType.YOUTUBE_VIDEO:
|
||||||
from app.tasks.celery_tasks.document_tasks import process_youtube_video_task
|
|
||||||
|
|
||||||
for url in request.content:
|
for url in request.content:
|
||||||
process_youtube_video_task.delay(
|
process_youtube_video_task.delay(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue