Fix remaining blocking I/O calls and N+1 project query
- tab_batch_ng.py: async create_batch with to_thread save/sync - tab_raw_ng.py: async do_save with to_thread, replace deepcopy with dict comprehension for display data - main.py: async create_new with to_thread save - tab_projects_ng.py: replace per-project count_data_files with single list_projects_with_file_counts JOIN query - db.py: add list_projects_with_file_counts method Zero blocking I/O calls remain in UI callbacks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -93,6 +93,16 @@ class ProjectDB:
|
||||
).fetchall()
|
||||
return [dict(r) for r in rows]
|
||||
|
||||
def list_projects_with_file_counts(self) -> list[dict]:
|
||||
"""List projects with data file counts in a single query."""
|
||||
rows = self.conn.execute(
|
||||
"SELECT p.id, p.name, p.folder_path, p.description, p.created_at, p.updated_at, "
|
||||
"COUNT(df.id) AS file_count "
|
||||
"FROM projects p LEFT JOIN data_files df ON df.project_id = p.id "
|
||||
"GROUP BY p.id ORDER BY p.name"
|
||||
).fetchall()
|
||||
return [dict(r) for r in rows]
|
||||
|
||||
def get_project(self, name: str) -> dict | None:
|
||||
row = self.conn.execute(
|
||||
"SELECT id, name, folder_path, description, created_at, updated_at "
|
||||
|
||||
Reference in New Issue
Block a user