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

Function _task_source_score

dashboard/server.py:101–114  ·  view source on GitHub ↗

给任务源打分:优先非 demo 任务,其次任务数,再按文件更新时间。

(task_file: pathlib.Path)

Source from the content-addressed store, hash-verified

99
100
101def _task_source_score(task_file: pathlib.Path):
102 """给任务源打分:优先非 demo 任务,其次任务数,再按文件更新时间。"""
103 try:
104 tasks = atomic_json_read(task_file, [])
105 except Exception:
106 tasks = []
107 if not isinstance(tasks, list):
108 tasks = []
109 non_demo = sum(1 for t in tasks if str((t or {}).get('id', '')) and not str((t or {}).get('id', '')).startswith('JJC-DEMO'))
110 try:
111 mtime = task_file.stat().st_mtime
112 except Exception:
113 mtime = 0
114 return (1 if non_demo > 0 else 0, non_demo, len(tasks), mtime)
115
116
117def get_task_data_dir():

Callers 1

get_task_data_dirFunction · 0.85

Calls 1

atomic_json_readFunction · 0.90

Tested by

no test coverage detected