mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-08 20:25:19 +02:00
feat(celery): add Google Drive indexing Celery task
- Create async task for Google Drive folder indexing - Accept folder_id and folder_name parameters - Call indexing wrapper to avoid circular imports
This commit is contained in:
parent
358abdf02f
commit
1c83327fc7
1 changed files with 52 additions and 0 deletions
|
|
@ -473,6 +473,58 @@ async def _index_google_gmail_messages(
|
|||
)
|
||||
|
||||
|
||||
@celery_app.task(name="index_google_drive_files", bind=True)
|
||||
def index_google_drive_files_task(
|
||||
self,
|
||||
connector_id: int,
|
||||
search_space_id: int,
|
||||
user_id: str,
|
||||
folder_id: str,
|
||||
folder_name: str,
|
||||
):
|
||||
"""Celery task to index Google Drive files."""
|
||||
import asyncio
|
||||
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
|
||||
try:
|
||||
loop.run_until_complete(
|
||||
_index_google_drive_files(
|
||||
connector_id,
|
||||
search_space_id,
|
||||
user_id,
|
||||
folder_id,
|
||||
folder_name,
|
||||
)
|
||||
)
|
||||
finally:
|
||||
loop.close()
|
||||
|
||||
|
||||
async def _index_google_drive_files(
|
||||
connector_id: int,
|
||||
search_space_id: int,
|
||||
user_id: str,
|
||||
folder_id: str,
|
||||
folder_name: str,
|
||||
):
|
||||
"""Index Google Drive files with new session."""
|
||||
from app.routes.search_source_connectors_routes import (
|
||||
run_google_drive_indexing,
|
||||
)
|
||||
|
||||
async with get_celery_session_maker()() as session:
|
||||
await run_google_drive_indexing(
|
||||
session,
|
||||
connector_id,
|
||||
search_space_id,
|
||||
user_id,
|
||||
folder_id,
|
||||
folder_name,
|
||||
)
|
||||
|
||||
|
||||
@celery_app.task(name="index_discord_messages", bind=True)
|
||||
def index_discord_messages_task(
|
||||
self,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue