mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-13 17:52:38 +02:00
feat: added meta-scheduler for running periodic tasks
This commit is contained in:
parent
a90767a478
commit
8706df6716
3 changed files with 20 additions and 13 deletions
|
|
@ -151,7 +151,10 @@ async def create_search_source_connector(
|
||||||
await session.refresh(db_connector)
|
await session.refresh(db_connector)
|
||||||
|
|
||||||
# Create periodic schedule if periodic indexing is enabled
|
# Create periodic schedule if periodic indexing is enabled
|
||||||
if db_connector.periodic_indexing_enabled and db_connector.indexing_frequency_minutes:
|
if (
|
||||||
|
db_connector.periodic_indexing_enabled
|
||||||
|
and db_connector.indexing_frequency_minutes
|
||||||
|
):
|
||||||
success = create_periodic_schedule(
|
success = create_periodic_schedule(
|
||||||
connector_id=db_connector.id,
|
connector_id=db_connector.id,
|
||||||
search_space_id=search_space_id,
|
search_space_id=search_space_id,
|
||||||
|
|
@ -370,8 +373,14 @@ async def update_search_source_connector(
|
||||||
await session.refresh(db_connector)
|
await session.refresh(db_connector)
|
||||||
|
|
||||||
# Handle periodic schedule updates
|
# Handle periodic schedule updates
|
||||||
if "periodic_indexing_enabled" in update_data or "indexing_frequency_minutes" in update_data:
|
if (
|
||||||
if db_connector.periodic_indexing_enabled and db_connector.indexing_frequency_minutes:
|
"periodic_indexing_enabled" in update_data
|
||||||
|
or "indexing_frequency_minutes" in update_data
|
||||||
|
):
|
||||||
|
if (
|
||||||
|
db_connector.periodic_indexing_enabled
|
||||||
|
and db_connector.indexing_frequency_minutes
|
||||||
|
):
|
||||||
# Create or update the periodic schedule
|
# Create or update the periodic schedule
|
||||||
success = update_periodic_schedule(
|
success = update_periodic_schedule(
|
||||||
connector_id=db_connector.id,
|
connector_id=db_connector.id,
|
||||||
|
|
|
||||||
|
|
@ -127,4 +127,3 @@ async def _check_and_trigger_schedules():
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error checking periodic schedules: {e!s}", exc_info=True)
|
logger.error(f"Error checking periodic schedules: {e!s}", exc_info=True)
|
||||||
await session.rollback()
|
await session.rollback()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -169,4 +169,3 @@ def update_periodic_schedule(
|
||||||
# Uncomment the line below if you want immediate execution on schedule update
|
# Uncomment the line below if you want immediate execution on schedule update
|
||||||
# return create_periodic_schedule(connector_id, search_space_id, user_id, connector_type, frequency_minutes)
|
# return create_periodic_schedule(connector_id, search_space_id, user_id, connector_type, frequency_minutes)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue