(request: Request, dto: AddDataSourceDto, background_tasks: BackgroundTasks)
| 93 | |
| 94 | @router.post("") |
| 95 | async def connect_data_source(request: Request, dto: AddDataSourceDto, background_tasks: BackgroundTasks) -> int: |
| 96 | logger.info(f"Adding data source {dto.name} with config {json.dumps(dto.config)}") |
| 97 | data_source = await DataSourceContext.create_data_source(name=dto.name, config=dto.config) |
| 98 | Posthog.added_data_source(uuid=request.headers.get('uuid'), name=dto.name) |
| 99 | # in main.py we have a background task that runs every 5 minutes and indexes the data source |
| 100 | # but here we want to index the data source immediately |
| 101 | background_tasks.add_task(data_source.index) |
| 102 | |
| 103 | return data_source.get_id() |
nothing calls this directly
no test coverage detected