refactor: Rename QueryHistoryManager and OptimizedQueryHistoryManager to QueryHistoryTool and OptimizedQueryHistoryTool for consistency

This commit is contained in:
william.dias 2026-01-23 10:19:45 -03:00
parent 45034f4cbd
commit 70a7a4a12b
2 changed files with 18 additions and 18 deletions

View file

@ -21,7 +21,7 @@ _debug_mode = os.getenv("SQL_OPT_TEAM_DEBUG_MODE", "false").strip().lower() in {
db = SqliteDb(db_file=_db_path) db = SqliteDb(db_file=_db_path)
sql_optimizer_team = Team( sql_optimizer_team = Team(
name="SQL Optimization Manager", name="SQL Optimization Team",
model=base_model, model=base_model,
members=[sql_analyst_agent, sql_optimizer_agent, sql_quality_agent, conservative_analysis_agent], members=[sql_analyst_agent, sql_optimizer_agent, sql_quality_agent, conservative_analysis_agent],
markdown=True, markdown=True,
@ -35,7 +35,7 @@ sql_optimizer_team = Team(
store_member_responses=True, store_member_responses=True,
debug_mode=_debug_mode, debug_mode=_debug_mode,
description=( description=(
"Gestor responsável por receber a solicitação inicial, repartir tarefas entre especialistas, " "Time orquestrador responsável por receber a solicitação inicial, repartir tarefas entre especialistas, "
"acompanhar hand-offs e consolidar a entrega final." "acompanhar hand-offs e consolidar a entrega final."
), ),
instructions=[ instructions=[

View file

@ -53,8 +53,8 @@ def _format_sql(sql_text: str) -> str:
return formatted.strip() return formatted.strip()
class QueryHistoryManager: class QueryHistoryTool:
"""Manages history of ranked queries to avoid duplicates in rank-queries command. """Tool for managing history of ranked queries to avoid duplicates in rank-queries command.
Uses SHA256 hash of SQL text to identify unique queries. Uses SHA256 hash of SQL text to identify unique queries.
History is stored per database/instance combination. History is stored per database/instance combination.
@ -64,11 +64,11 @@ class QueryHistoryManager:
history_file: Path to the JSON file storing query history history_file: Path to the JSON file storing query history
Example: Example:
>>> manager = QueryHistoryManager() >>> tool = QueryHistoryTool()
>>> manager.is_processed("sqlserver", "nprd_2", "SELECT * FROM users") >>> tool.is_processed("sqlserver", "nprd_2", "SELECT * FROM users")
False False
>>> manager.mark_as_processed("sqlserver", "nprd_2", "SELECT * FROM users") >>> tool.mark_as_processed("sqlserver", "nprd_2", "SELECT * FROM users")
>>> manager.is_processed("sqlserver", "nprd_2", "SELECT * FROM users") >>> tool.is_processed("sqlserver", "nprd_2", "SELECT * FROM users")
True True
""" """
@ -76,7 +76,7 @@ class QueryHistoryManager:
DEFAULT_OUTPUT_DIR = "exemples" DEFAULT_OUTPUT_DIR = "exemples"
def __init__(self, history_file: str | Path | None = None) -> None: def __init__(self, history_file: str | Path | None = None) -> None:
"""Initialize the query history manager. """Initialize the query history tool.
Args: Args:
history_file: Path to history file. Uses default if not specified. history_file: Path to history file. Uses default if not specified.
@ -418,7 +418,7 @@ class QueryHistoryManager:
f"-- Total Queries: {len(sorted_entries)}", f"-- Total Queries: {len(sorted_entries)}",
"-- =============================================================================", "-- =============================================================================",
"", "",
"-- This file is auto-generated by the Query History Manager.", "-- This file is auto-generated by the Query History Tool.",
"-- It contains all queries that have been analyzed/processed.", "-- It contains all queries that have been analyzed/processed.",
"", "",
] ]
@ -484,10 +484,10 @@ class QueryHistoryManager:
return count, consolidated_path return count, consolidated_path
class OptimizedQueryHistoryManager: class OptimizedQueryHistoryTool:
"""Manages history of optimized/refactored queries from optimize-worst command. """Tool for managing history of optimized/refactored queries from optimize-worst command.
Separate from QueryHistoryManager to track only queries that were actually Separate from QueryHistoryTool to track only queries that were actually
sent through the LLM optimization process, not just listed/ranked. sent through the LLM optimization process, not just listed/ranked.
Uses SHA256 hash of SQL text to identify unique queries. Uses SHA256 hash of SQL text to identify unique queries.
@ -497,18 +497,18 @@ class OptimizedQueryHistoryManager:
history_file: Path to the JSON file storing optimization history history_file: Path to the JSON file storing optimization history
Example: Example:
>>> manager = OptimizedQueryHistoryManager() >>> tool = OptimizedQueryHistoryTool()
>>> manager.is_optimized("sqlserver", "nprd_2", "SELECT * FROM users") >>> tool.is_optimized("sqlserver", "nprd_2", "SELECT * FROM users")
False False
>>> manager.mark_as_optimized("sqlserver", "nprd_2", "SELECT * FROM users", {...}) >>> tool.mark_as_optimized("sqlserver", "nprd_2", "SELECT * FROM users", {...})
>>> manager.is_optimized("sqlserver", "nprd_2", "SELECT * FROM users") >>> tool.is_optimized("sqlserver", "nprd_2", "SELECT * FROM users")
True True
""" """
DEFAULT_HISTORY_FILE = "exemples/.optimized_queries_history.json" DEFAULT_HISTORY_FILE = "exemples/.optimized_queries_history.json"
def __init__(self, history_file: str | Path | None = None) -> None: def __init__(self, history_file: str | Path | None = None) -> None:
"""Initialize the optimized query history manager. """Initialize the optimized query history tool.
Args: Args:
history_file: Path to history file. Uses default if not specified. history_file: Path to history file. Uses default if not specified.