MCPcopy Index your code
hub / github.com/AutoForgeAI/autoforge / count_passing_tests

Function count_passing_tests

progress.py:65–112  ·  view source on GitHub ↗

Count passing, in_progress, and total tests via direct database access. Args: project_dir: Directory containing the project Returns: (passing_count, in_progress_count, total_count)

(project_dir: Path)

Source from the content-addressed store, hash-verified

63
64
65def count_passing_tests(project_dir: Path) -> tuple[int, int, int]:
66 """
67 Count passing, in_progress, and total tests via direct database access.
68
69 Args:
70 project_dir: Directory containing the project
71
72 Returns:
73 (passing_count, in_progress_count, total_count)
74 """
75 from autoforge_paths import get_features_db_path
76 db_file = get_features_db_path(project_dir)
77 if not db_file.exists():
78 return 0, 0, 0
79
80 try:
81 with closing(_get_connection(db_file)) as conn:
82 cursor = conn.cursor()
83 # Single aggregate query instead of 3 separate COUNT queries
84 # Handle case where in_progress column doesn't exist yet (legacy DBs)
85 try:
86 cursor.execute("""
87 SELECT
88 COUNT(*) as total,
89 SUM(CASE WHEN passes = 1 THEN 1 ELSE 0 END) as passing,
90 SUM(CASE WHEN in_progress = 1 THEN 1 ELSE 0 END) as in_progress
91 FROM features
92 """)
93 row = cursor.fetchone()
94 total = row[0] or 0
95 passing = row[1] or 0
96 in_progress = row[2] or 0
97 except sqlite3.OperationalError:
98 # Fallback for databases without in_progress column
99 cursor.execute("""
100 SELECT
101 COUNT(*) as total,
102 SUM(CASE WHEN passes = 1 THEN 1 ELSE 0 END) as passing
103 FROM features
104 """)
105 row = cursor.fetchone()
106 total = row[0] or 0
107 passing = row[1] or 0
108 in_progress = 0
109 return passing, in_progress, total
110 except Exception as e:
111 print(f"[Database error in count_passing_tests: {e}]")
112 return 0, 0, 0
113
114
115def get_all_passing_features(project_dir: Path) -> list[dict]:

Callers 4

run_autonomous_agentFunction · 0.90
poll_progressFunction · 0.90
project_websocketFunction · 0.90
print_progress_summaryFunction · 0.85

Calls 2

get_features_db_pathFunction · 0.90
_get_connectionFunction · 0.85

Tested by

no test coverage detected