Fix coverage filename→name, fix TasksProxy auto-save for multi-worker
This commit is contained in:
Binary file not shown.
20
app.py.final
20
app.py.final
@@ -52,10 +52,13 @@ class TasksProxy:
|
||||
def __setitem__(self, key, value):
|
||||
with _task_lock:
|
||||
tasks = _load_tasks()
|
||||
if isinstance(value, dict):
|
||||
tasks[key] = value
|
||||
else:
|
||||
tasks[key] = value
|
||||
_save_tasks(tasks)
|
||||
def __getitem__(self, key):
|
||||
return _load_tasks()[key]
|
||||
return _TaskDict(key)
|
||||
def __contains__(self, key):
|
||||
return key in _load_tasks()
|
||||
def pop(self, key, *args):
|
||||
@@ -65,6 +68,21 @@ class TasksProxy:
|
||||
_save_tasks(tasks)
|
||||
return result
|
||||
|
||||
class _TaskDict(dict):
|
||||
"""Auto-saving dict wrapper for a single task."""
|
||||
def __init__(self, task_id):
|
||||
self._task_id = task_id
|
||||
tasks = _load_tasks()
|
||||
super().__init__(tasks.get(task_id, {}))
|
||||
def __setitem__(self, key, value):
|
||||
super().__setitem__(key, value)
|
||||
with _task_lock:
|
||||
tasks = _load_tasks()
|
||||
if self._task_id not in tasks:
|
||||
tasks[self._task_id] = {}
|
||||
tasks[self._task_id][key] = value
|
||||
_save_tasks(tasks)
|
||||
|
||||
TASKS = TasksProxy()
|
||||
|
||||
# ========== UTILITY FUNCTIONS ==========
|
||||
|
||||
@@ -2198,9 +2198,9 @@ function renderCoverage() {
|
||||
const x1 = ml + ((seg.startDate.getTime() - tMin) / tRange) * pw;
|
||||
const w = Math.max(2, ((seg.duration_sec || 0) / (tRange / 1000)) * pw);
|
||||
const color = lineColorMap[seg.line] || '#666';
|
||||
const escapedFn = seg.filename.replace(/'/g, "\\'");
|
||||
const escapedFn = (seg.filename||seg.name).replace(/'/g, "\\'");
|
||||
svg += `<rect x="${x1}" y="${y + 1}" width="${w}" height="${rowH - 2}" fill="${color}" rx="2" opacity="0.8" style="cursor:pointer" onclick="coverageClickFile('${escapedFn}')">`;
|
||||
svg += `<title>${seg.filename}\nBoard: ${seg.board_id || '?'}\nLine: ${seg.line || '?'} Point: ${seg.point || '?'}\nDuration: ${((seg.duration_sec || 0) / 3600).toFixed(1)}h\nStart: ${seg.date_str}</title>`;
|
||||
svg += `<title>${(seg.filename||seg.name)}\nBoard: ${seg.board_id || '?'}\nLine: ${seg.line || '?'} Point: ${seg.point || '?'}\nDuration: ${((seg.duration_sec || 0) / 3600).toFixed(1)}h\nStart: ${seg.date_str}</title>`;
|
||||
svg += `</rect>`;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user