MCPcopy
hub / github.com/cft0808/edict / handle_archive_task

Function handle_archive_task

dashboard/server.py:249–272  ·  view source on GitHub ↗

Archive or unarchive a task, or batch-archive all Done/Cancelled tasks.

(task_id, archived, archive_all_done=False)

Source from the content-addressed store, hash-verified

247
248
249def handle_archive_task(task_id, archived, archive_all_done=False):
250 """Archive or unarchive a task, or batch-archive all Done/Cancelled tasks."""
251 tasks = load_tasks()
252 if archive_all_done:
253 count = 0
254 for t in tasks:
255 if t.get('state') in ('Done', 'Cancelled') and not t.get('archived'):
256 t['archived'] = True
257 t['archivedAt'] = now_iso()
258 count += 1
259 save_tasks(tasks)
260 return {'ok': True, 'message': f'{count} 道旨意已归档', 'count': count}
261 task = next((t for t in tasks if t.get('id') == task_id), None)
262 if not task:
263 return {'ok': False, 'error': f'任务 {task_id} 不存在'}
264 task['archived'] = archived
265 if archived:
266 task['archivedAt'] = now_iso()
267 else:
268 task.pop('archivedAt', None)
269 task['updatedAt'] = now_iso()
270 save_tasks(tasks)
271 label = '已归档' if archived else '已取消归档'
272 return {'ok': True, 'message': f'{task_id} {label}'}
273
274
275def update_task_todos(task_id, todos):

Callers 1

do_POSTMethod · 0.85

Calls 3

now_isoFunction · 0.90
load_tasksFunction · 0.85
save_tasksFunction · 0.85

Tested by

no test coverage detected