Integration Operations

Integration operations between bot and agent systems.

async shared.database.operations.integration.complete_task_processing(task_id, success=True, error_message=None)[source]

Complete task processing and update status.

Parameters:
  • task_id (int) – Task ID

  • success (bool) – Whether task completed successfully

  • error_message (Optional[str]) – Error message if task failed

Return type:

bool

Returns:

True if successfully completed

async shared.database.operations.integration.create_research_topic_for_user_task(user_task)[source]

Create a ResearchTopic from UserTask for agent compatibility.

This bridges the new UserTask system with the legacy ResearchTopic system that the agent pipeline expects.

Parameters:

user_task (UserTask) – UserTask instance

Return type:

Optional[ResearchTopic]

Returns:

ResearchTopic instance or None if user not found

async shared.database.operations.integration.create_user_task(user_id, description)[source]

Create a user task (legacy function for compatibility).

Parameters:
  • user_id (int) – Telegram user ID (will be converted to internal user ID)

  • description (str) – Task description

Return type:

UserTask

Returns:

UserTask instance

async shared.database.operations.integration.get_next_queued_task()[source]

Get next task from queue for agent processing.

This function bridges the new UserTask/TaskQueue system with the agent.

Return type:

Optional[UserTask]

Returns:

Next UserTask ready for processing or None if queue is empty

async shared.database.operations.integration.get_user_task_results(task_id)[source]

Get analysis results for a user task.

Parameters:

task_id (int) – UserTask ID

Return type:

List[Tuple[PaperAnalysis, ArxivPaper]]

Returns:

List of (PaperAnalysis, ArxivPaper) tuples

Link a paper analysis to a user task for proper result tracking.

Creates a Finding record that connects the analysis to the user’s task.

Parameters:
Return type:

None

async shared.database.operations.integration.start_task_processing(task_id)[source]

Start processing a queued task.

Updates task status to PROCESSING and records start time.

Parameters:

task_id (int) – Task ID

Return type:

bool

Returns:

True if successfully started, False if task not found or already processing