-
Notifications
You must be signed in to change notification settings - Fork 2
[utils]受入/検査がスキップされたタスク履歴番号を取得するメソッドを追加 #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,14 @@ | |
import datetime | ||
import logging | ||
from pathlib import Path | ||
from typing import Optional | ||
from typing import List, Optional | ||
|
||
import dateutil | ||
import dateutil.tz | ||
import requests | ||
|
||
from annofabapi.models import TaskHistory, TaskPhase | ||
|
||
|
||
def raise_for_status(response: requests.Response): | ||
""" | ||
|
@@ -131,3 +133,61 @@ def wrapped(*args, **kwargs): | |
logging.getLogger("backoff").setLevel(level=backoff_logger_level) | ||
|
||
return wrapped | ||
|
||
|
||
def get_task_history_index_skipped_acceptance(task_history_list: List[TaskHistory]) -> List[int]: | ||
""" | ||
受入がスキップされたタスク履歴のインデックス番号(0始まり)を返す。 | ||
| ||
Args: | ||
task_history_list: タスク履歴List | ||
| ||
Returns: | ||
受入フェーズがスキップされた履歴のインデックス番号(0始まり)。受入がスキップされていない場合は空リストを返す。 | ||
| ||
""" | ||
index_list = [] | ||
for index, history in enumerate(task_history_list): | ||
if not (TaskPhase(history["phase"]) == TaskPhase.ACCEPTANCE and history["account_id"] is None): | ||
continue | ||
|
||
if index + 1 < len(task_history_list): | ||
# 直後の履歴あり | ||
next_history = task_history_list[index + 1] | ||
# 直後の履歴が受入の場合、受入がスキップされた履歴(提出取り消しではない) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 個人的な感想ですが、この説明の正しさを理解するのに少し時間がかかりました。 「直後が受入であること」ではなく「直後が前段のフェーズでないこと」とした方が、確かに提出取消ならそうなるはずだ、と理解しやすいのではないでしょうか。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
「前段≠直前」で合っていますか? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
if TaskPhase(next_history["phase"]) == TaskPhase.ACCEPTANCE: | ||
index_list.append(index) | ||
else: | ||
# 直後の履歴がない | ||
index_list.append(index) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 最後の履歴が受入フェーズで担当者なしというのは、受入未着手も含まれるのでは? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 「受入フェーズで担当者なし」のタスクは、受入フェーズのタスク履歴がなかったため、問題ないかと思います。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. とはいえ、「started_datetime |
||
|
||
return index_list | ||
|
||
|
||
def get_task_history_index_skipped_inspection(task_history_list: List[TaskHistory]) -> List[int]: | ||
""" | ||
検査フェーズがスキップされたタスク履歴のインデックス番号(0始まり)を返す。 | ||
| ||
Args: | ||
task_history_list: タスク履歴List | ||
| ||
Returns: | ||
検査フェーズがスキップされた履歴のインデックス番号(0始まり)。検査がスキップされていない場合は空リストを返す。 | ||
| ||
""" | ||
index_list = [] | ||
for index, history in enumerate(task_history_list): | ||
if not (TaskPhase(history["phase"]) == TaskPhase.INSPECTION and history["account_id"] is None): | ||
continue | ||
|
||
if index + 1 < len(task_history_list): | ||
# 直後の履歴あり | ||
next_history = task_history_list[index + 1] | ||
# 直後の履歴が受入/検査の場合、検査がスキップされた履歴(提出取り消しではない) | ||
if TaskPhase(next_history["phase"]) in [TaskPhase.ACCEPTANCE, TaskPhase.INSPECTION]: | ||
index_list.append(index) | ||
else: | ||
# 直後の履歴がない | ||
index_list.append(index) | ||
|
||
return index_list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
作業時間が0であることも確認した方がよいのでは。ないと困る一例として、受入後のアノテーション一括編集とかがあります。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
メモ:受入完了状態のタスクに対してアノテーション一括編集すると、
になる