Skip to content

Commit 0a293b5

Browse files
authored
labor関係の関数を非推奨にする (#369)
* labor関係のwebapiを非推奨にする * udpate * update README * travis_retry を追加
1 parent 83ddadd commit 0a293b5

File tree

6 files changed

+32
-15
lines changed

6 files changed

+32
-15
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ python:
77
- "3.9"
88
install:
99
- pip install poetry
10-
- poetry install
10+
- travis_retry poetry install
1111
script:
1212
- make lint
1313
- pytest tests/test_local*.py

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030
### 2022-01-01 以降
3131
* Python3.6のサポートを停止し、対応するPythonバージョンを3.7以上にします。
3232

33+
### 2022-02-01 以降
34+
* 以下の関数を非推奨にします。WebAPIが将来的に廃止されるためです。
35+
* AnnofabApi.get_labor_control
36+
* Wrapper.get_labor_control_worktime
37+
* Wrapper.get_labor_control_availability
38+
39+
3340
# Features
3441
cURLやPostmanなどよりも簡単にAnnoFab Web APIにアクセスできます。
3542

annofabapi/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.48.3"
1+
__version__ = "0.49.0"

annofabapi/api.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import logging
3+
import warnings
34
from typing import Any, Dict, Optional, Tuple
45

56
import requests
@@ -314,6 +315,7 @@ def refresh_token(self) -> Optional[Tuple[Dict[str, Any], requests.Response]]:
314315
def get_labor_control(self, query_params: Optional[Dict[str, Any]] = None) -> Tuple[Any, requests.Response]:
315316
"""労務管理関連データを一括で取得します。
316317
318+
.. deprecated:: 2022-02-01 以降に削除する予定です
317319
318320
Args:
319321
query_params: Query Parameters
@@ -323,6 +325,8 @@ def get_labor_control(self, query_params: Optional[Dict[str, Any]] = None) -> Tu
323325
324326
325327
"""
328+
warnings.warn("deprecated", FutureWarning)
329+
326330
url_path = "/labor-control"
327331
http_method = "GET"
328332
keyword_params: Dict[str, Any] = {

annofabapi/wrapper.py

+18-12
Original file line numberDiff line numberDiff line change
@@ -2054,28 +2054,28 @@ def wait_until_job_is_executable(
20542054
# Public Method : Labor Control
20552055
#########################################
20562056
@staticmethod
2057-
def _get_actual_worktime_hour_from_labor(labor: Dict[str, Any]) -> Optional[float]:
2057+
def _get_actual_worktime_hour_from_labor(labor: Dict[str, Any]) -> float:
20582058
working_time_by_user = labor["values"]["working_time_by_user"]
20592059
if working_time_by_user is None:
2060-
return None
2060+
return 0
20612061

20622062
actual_worktime = working_time_by_user.get("results")
20632063
if actual_worktime is None:
2064-
return None
2064+
return 0
20652065
else:
20662066
return actual_worktime / 3600 / 1000
20672067

20682068
@staticmethod
2069-
def _get_plan_worktime_hour_from_labor(labor: Dict[str, Any]) -> Optional[float]:
2069+
def _get_plan_worktime_hour_from_labor(labor: Dict[str, Any]) -> float:
20702070
working_time_by_user = labor["values"]["working_time_by_user"]
20712071
if working_time_by_user is None:
2072-
return None
2072+
return 0
20732073

2074-
actual_worktime = working_time_by_user.get("plans")
2075-
if actual_worktime is None:
2076-
return None
2074+
plan_worktime = working_time_by_user.get("plans")
2075+
if plan_worktime is None:
2076+
return 0
20772077
else:
2078-
return actual_worktime / 3600 / 1000
2078+
return plan_worktime / 3600 / 1000
20792079

20802080
@staticmethod
20812081
def _get_working_description_from_labor(labor: Dict[str, Any]) -> Optional[str]:
@@ -2097,6 +2097,8 @@ def get_labor_control_worktime(
20972097
実績作業時間(actual_worktime)と予定作業時間(plan_worktime)を扱いやすいフォーマットで取得する。
20982098
ただし、organization_id または project_id のいずれかを指定する必要がある。
20992099
2100+
.. deprecated:: 2022-02-01 以降に削除する予定です
2101+
21002102
Args:
21012103
organization_id: 絞り込み対象の組織ID
21022104
project_id: 絞り込み対象のプロジェクトID
@@ -2112,8 +2114,9 @@ def get_labor_control_worktime(
21122114
* date
21132115
* actual_worktime:実績作業時間[hour]
21142116
* plan_worktime:予定作業時間[hour]
2115-
* working_description:実績に関するコメント
2117+
* working_description:実績に関するコメント(optional)
21162118
"""
2119+
warnings.warn("deprecated", FutureWarning)
21172120

21182121
def _to_new_data(labor: Dict[str, Any]) -> Dict[str, Any]:
21192122
labor["actual_worktime"] = self._get_actual_worktime_hour_from_labor(labor)
@@ -2134,7 +2137,7 @@ def _to_new_data(labor: Dict[str, Any]) -> Dict[str, Any]:
21342137
}
21352138
try:
21362139
labor_list, _ = self.api.get_labor_control(query_params)
2137-
return [_to_new_data(e) for e in labor_list]
2140+
return [_to_new_data(elm) for elm in labor_list if elm["account_id"] is not None]
21382141
except requests.HTTPError as e:
21392142
# "502 Server Error"が発生するときは、取得するレスポンスが大きすぎる可能性があるので、取得期間を分割する。
21402143
# ただし、取得する期間が指定されている場合のみ
@@ -2180,6 +2183,8 @@ def get_labor_control_availability(
21802183
"""
21812184
労務管理の予定稼働時間を取得する。
21822185
2186+
.. deprecated:: 2022-02-01 以降に削除する予定です
2187+
21832188
Args:
21842189
account_id: 絞り込み対象のアカウントID
21852190
from_date: 絞り込み対象の開始日(YYYY-MM-DD)
@@ -2191,6 +2196,7 @@ def get_labor_control_availability(
21912196
* date
21922197
* availability:予定稼働時間[hour]
21932198
"""
2199+
warnings.warn("deprecated", FutureWarning)
21942200

21952201
def _to_new_data(labor: Dict[str, Any]) -> Dict[str, Any]:
21962202
labor["availability"] = self._get_plan_worktime_hour_from_labor(labor)
@@ -2204,7 +2210,7 @@ def _to_new_data(labor: Dict[str, Any]) -> Dict[str, Any]:
22042210
"to": to_date,
22052211
}
22062212
labor_list, _ = self.api.get_labor_control(query_params)
2207-
return [_to_new_data(e) for e in labor_list]
2213+
return [_to_new_data(e) for e in labor_list if e["account_id"] is not None]
22082214

22092215
def put_labor_control_actual_worktime(
22102216
self,

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "annofabapi"
3-
version = "0.48.3"
3+
version = "0.49.0"
44
description = "Python Clinet Library of AnnoFab WebAPI (https://annofab.com/docs/api/)"
55
authors = ["yuji38kwmt"]
66
license = "MIT"

0 commit comments

Comments
 (0)