Fix coverage filename→name, fix TasksProxy auto-save for multi-worker
This commit is contained in:
Binary file not shown.
22
app.py.final
22
app.py.final
@@ -52,10 +52,13 @@ class TasksProxy:
|
|||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
with _task_lock:
|
with _task_lock:
|
||||||
tasks = _load_tasks()
|
tasks = _load_tasks()
|
||||||
tasks[key] = value
|
if isinstance(value, dict):
|
||||||
|
tasks[key] = value
|
||||||
|
else:
|
||||||
|
tasks[key] = value
|
||||||
_save_tasks(tasks)
|
_save_tasks(tasks)
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
return _load_tasks()[key]
|
return _TaskDict(key)
|
||||||
def __contains__(self, key):
|
def __contains__(self, key):
|
||||||
return key in _load_tasks()
|
return key in _load_tasks()
|
||||||
def pop(self, key, *args):
|
def pop(self, key, *args):
|
||||||
@@ -65,6 +68,21 @@ class TasksProxy:
|
|||||||
_save_tasks(tasks)
|
_save_tasks(tasks)
|
||||||
return result
|
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()
|
TASKS = TasksProxy()
|
||||||
|
|
||||||
# ========== UTILITY FUNCTIONS ==========
|
# ========== UTILITY FUNCTIONS ==========
|
||||||
|
|||||||
@@ -2198,9 +2198,9 @@ function renderCoverage() {
|
|||||||
const x1 = ml + ((seg.startDate.getTime() - tMin) / tRange) * pw;
|
const x1 = ml + ((seg.startDate.getTime() - tMin) / tRange) * pw;
|
||||||
const w = Math.max(2, ((seg.duration_sec || 0) / (tRange / 1000)) * pw);
|
const w = Math.max(2, ((seg.duration_sec || 0) / (tRange / 1000)) * pw);
|
||||||
const color = lineColorMap[seg.line] || '#666';
|
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 += `<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>`;
|
svg += `</rect>`;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user