File tree Expand file tree Collapse file tree 5 files changed +337
-90
lines changed Expand file tree Collapse file tree 5 files changed +337
-90
lines changed Original file line number Diff line number Diff line change 1+ from typing import Any
2+
3+ import isodate
4+
5+ from annofabapi .pydantic_models .task_phase import TaskPhase
6+
7+
8+ def find_rejected_task_history_indices (task_history_list : list [dict [str , Any ]]) -> list [int ]:
9+ """
10+ 差し戻されたタスク履歴のインデックス番号(0始まり)を返します。
11+
12+ Args:
13+ task_history_list: `get_task_histories` APIのレスポンス
14+
15+ Returns:
16+ 差し戻されたタスク履歴のインデックス番号のリスト
17+ """
18+ index_list = []
19+ for index , history in enumerate (task_history_list ):
20+ # 検査/受入フェーズで作業が行われているか
21+ if not (
22+ history ["phase" ] in {TaskPhase .INSPECTION .value , TaskPhase .ACCEPTANCE .value }
23+ and isodate .parse_duration (history ["accumulated_labor_time_milliseconds" ]).total_seconds () > 0
24+ and history ["account_id" ] is not None
25+ and history ["started_datetime" ] is not None
26+ and history ["ended_datetime" ] is not None
27+ ):
28+ continue
29+ # 直後の履歴が教師付フェーズならば、差し戻されたとみなす
30+ next_index = index + 1
31+ if next_index >= len (task_history_list ):
32+ # 対象の履歴は最後の履歴
33+ continue
34+
35+ next_history = task_history_list [next_index ]
36+ if next_history ["phase" ] == TaskPhase .ANNOTATION .value :
37+ index_list .append (index )
38+
39+ return index_list
Original file line number Diff line number Diff line change @@ -20,6 +20,15 @@ annofabapi.util.attribute\_restrictions module
2020 :undoc-members:
2121 :show-inheritance:
2222
23+ annofabapi.util.task\_ history module
24+ ---------------------------------
25+
26+ .. automodule :: annofabapi.util.task_history
27+ :members:
28+ :undoc-members:
29+ :show-inheritance:
30+
31+
2332annofabapi.util.type\_ util module
2433---------------------------------
2534
You can’t perform that action at this time.
0 commit comments