给任务源打分:优先非 demo 任务,其次任务数,再按文件更新时间。
(task_file: pathlib.Path)
| 99 | |
| 100 | |
| 101 | def _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 | |
| 117 | def get_task_data_dir(): |
no test coverage detected