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:
2026-03-18 23:40:32 +01:00
parent 37e9e1001e
commit 589c84fd95
5 changed files with 26 additions and 18 deletions
+2 -2
View File
@@ -476,7 +476,7 @@ def render_sidebar(state: AppState, dual_pane: dict):
with ui.expansion('Create New JSON'):
new_fn_input = ui.input('Filename', placeholder='my_prompt_vace').classes('w-full')
def create_new():
async def create_new():
fn = new_fn_input.value
if not fn:
return
@@ -485,7 +485,7 @@ def render_sidebar(state: AppState, dual_pane: dict):
path = state.current_dir / fn
first_item = copy.deepcopy(DEFAULTS)
first_item[KEY_SEQUENCE_NUMBER] = 1
save_json(path, {KEY_BATCH_DATA: [first_item]})
await asyncio.to_thread(save_json, path, {KEY_BATCH_DATA: [first_item]})
new_fn_input.set_value('')
render_file_list.refresh()