Skip to content

Annofab v0.93.0 対応 #187

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

Merged
merged 5 commits into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion annofabapi/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.37.0"
__version__ = "0.38.0"
93 changes: 87 additions & 6 deletions annofabapi/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from dataclasses import dataclass
from typing import Any, Callable, Dict, List, Optional

import requests

from annofabapi import AnnofabApi
from annofabapi.exceptions import AnnofabApiException
from annofabapi.models import (
Expand Down Expand Up @@ -623,19 +625,17 @@ def put_input_data_from_file(
#########################################
# Public Method : Statistics
#########################################
def get_worktime_statistics(self, project_id: str) -> List[Any]:
def _request_location_header_url(self, response: requests.Response) -> Any:
"""
タスク作業時間集計取得.
Location Headerに記載されたURLのレスポンスをJSON形式で返す。
Location headerに記載されているURLの中身を返す。

Args:
project_id: プロジェクトID
response:

Returns:
タスク作業時間集計
Location headerに記載されているURLの中身

"""
_, response = self.api.get_worktime_statistics(project_id)
url = response.headers["Location"]

response = self.api.session.get(url)
Expand All @@ -646,6 +646,87 @@ def get_worktime_statistics(self, project_id: str) -> List[Any]:
content = self.api._response_to_content(response)
return content

def get_task_statistics(self, project_id: str) -> List[Any]:
"""
getTaskStatistics APIのLocation headerの中身を返す。

Args:
project_id: プロジェクトID

Returns:


"""
_, response = self.api.get_task_statistics(project_id)
return self._request_location_header_url(response)

def get_account_statistics(self, project_id: str) -> List[Any]:
"""
getAccountStatistics APIのLocation headerの中身を返す。

Args:
project_id:

Returns:

"""
_, response = self.api.get_account_statistics(project_id)
return self._request_location_header_url(response)

def get_inspection_statistics(self, project_id: str) -> List[Any]:
"""
getInspectionStatistics APIのLocation headerの中身を返す。

Args:
project_id:

Returns:

"""
_, response = self.api.get_inspection_statistics(project_id)
return self._request_location_header_url(response)

def get_task_phase_statistics(self, project_id: str) -> List[Any]:
"""
getTaskPhaseStatistics APIのLocation headerの中身を返す。

Args:
project_id:

Returns:

"""
_, response = self.api.get_task_phase_statistics(project_id)
return self._request_location_header_url(response)

def get_label_statistics(self, project_id: str) -> List[Any]:
"""
getLabelStatistics APIのLocation headerの中身を返す。

Args:
project_id:

Returns:

"""
_, response = self.api.get_label_statistics(project_id)
return self._request_location_header_url(response)

def get_worktime_statistics(self, project_id: str) -> List[Any]:
"""
タスク作業時間集計取得.
Location Headerに記載されたURLのレスポンスをJSON形式で返す。

Args:
project_id: プロジェクトID

Returns:
タスク作業時間集計

"""
_, response = self.api.get_worktime_statistics(project_id)
return self._request_location_header_url(response)

#########################################
# Public Method : Supplementary
#########################################
Expand Down
37 changes: 36 additions & 1 deletion generate/swagger/swagger.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ info:

上記例 `account_id_count` は、タスクのフィールド `account_id` でタスクを分類したところ「`account_id` が `c5eee002` であるタスクが9件、`9f110e48` であるタスクが5件、`b25dfeb3` であるタスクが1件」だったという結果を表しています。

version: 0.91.0
version: 0.93.0
title: AnnoFab Web API
x-logo:
url: "https://annofab.com/images/logo_landscape.png"
Expand Down Expand Up @@ -387,6 +387,12 @@ paths:
responses:
"200":
description: 正常
headers:
Location:
description: 認証済み一時URL
required: true
schema:
type: string
content:
application/json:
schema:
Expand Down Expand Up @@ -429,6 +435,12 @@ paths:
responses:
"200":
description: 正常
headers:
Location:
description: 認証済み一時URL
required: true
schema:
type: string
content:
application/json:
schema:
Expand Down Expand Up @@ -471,6 +483,12 @@ paths:
responses:
"200":
description: 正常
headers:
Location:
description: 認証済み一時URL
required: true
schema:
type: string
content:
application/json:
schema:
Expand Down Expand Up @@ -513,6 +531,12 @@ paths:
responses:
"200":
description: 正常
headers:
Location:
description: 認証済み一時URL
required: true
schema:
type: string
content:
application/json:
schema:
Expand Down Expand Up @@ -555,6 +579,12 @@ paths:
responses:
"200":
description: 正常
headers:
Location:
description: 認証済み一時URL
required: true
schema:
type: string
content:
application/json:
schema:
Expand Down Expand Up @@ -598,6 +628,11 @@ paths:
responses:
"200":
description: 正常
headers:
Location:
description: 認証済み一時URL
schema:
type: string
content:
application/json:
schema:
Expand Down
32 changes: 31 additions & 1 deletion generate/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ info:
上記例 `account_id_count` は、タスクのフィールド `account_id` でタスクを分類したところ「`account_id` が `c5eee002` であるタスクが9件、`9f110e48` であるタスクが5件、`b25dfeb3` であるタスクが1件」だったという結果を表しています。
また、AggregationResultの集約の件数は、合計で10000件以下に制限されており、それを超える件数がある場合は上位10000件が取得されます。もし、省略された部分を取得したい場合は、検索条件を縛って結果に上る集約の数を減らしてください。

version: 0.91.0
version: 0.93.0
title: AnnoFab Web API
x-logo:
url: "https://annofab.com/images/logo_landscape.png"
Expand Down Expand Up @@ -2394,6 +2394,12 @@ paths:
responses:
"200":
description: 正常
headers:
Location:
description: 認証済み一時URL
required: true
schema:
type: string
content:
application/json:
schema:
Expand Down Expand Up @@ -2429,6 +2435,12 @@ paths:
responses:
"200":
description: 正常
headers:
Location:
description: 認証済み一時URL
required: true
schema:
type: string
content:
application/json:
schema:
Expand Down Expand Up @@ -2461,6 +2473,12 @@ paths:
responses:
"200":
description: 正常
headers:
Location:
description: 認証済み一時URL
required: true
schema:
type: string
content:
application/json:
schema:
Expand Down Expand Up @@ -2494,6 +2512,12 @@ paths:
responses:
"200":
description: 正常
headers:
Location:
description: 認証済み一時URL
required: true
schema:
type: string
content:
application/json:
schema:
Expand Down Expand Up @@ -2528,6 +2552,12 @@ paths:
responses:
"200":
description: 正常
headers:
Location:
description: 認証済み一時URL
required: true
schema:
type: string
content:
application/json:
schema:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "annofabapi"
version = "0.37.0"
version = "0.38.0"
description = "Python Clinet Library of AnnoFab WebAPI (https://annofab.com/docs/api/)"
authors = ["yuji38kwmt <[email protected]>"]
maintainers = ["yuji38kwmt <[email protected]>"]
Expand Down
28 changes: 17 additions & 11 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,23 +299,29 @@ def test_wrapper_copy_project_member(self):


class TestStatistics:
def test_statistics(self):
assert type(api.get_task_statistics(project_id)[0]) == list
def test_wrapper_statistics(self):
actual = wrapper.get_task_statistics(project_id)
assert type(actual) == list

def test_get_account_statistics(self):
assert type(api.get_account_statistics(project_id)[0]) == list
def test_wrapper_get_account_statistics(self):
actual = wrapper.get_account_statistics(project_id)
assert type(actual) == list

def test_get_inspection_statistics(self):
assert type(api.get_inspection_statistics(project_id)[0]) == list
def test_wrapper_get_inspection_statistics(self):
actual = wrapper.get_inspection_statistics(project_id)
assert type(actual) == list

def test_get_task_phase_statistics(self):
assert type(api.get_task_phase_statistics(project_id)[0]) == list
def test_wrapper_get_task_phase_statistics(self):
actual = wrapper.get_task_phase_statistics(project_id)
assert type(actual) == list

def test_get_label_statistics(self):
assert type(api.get_label_statistics(project_id)[0]) == list
def test_wrapper_get_label_statistics(self):
actual = wrapper.get_label_statistics(project_id)
assert type(actual) == list

def test_wrapper_get_worktime_statistics(self):
assert type(wrapper.get_worktime_statistics(project_id)) == list
actual = wrapper.get_worktime_statistics(project_id)
assert type(actual) == list

def test_graph_marker(self):
print("get_markers")
Expand Down
10 changes: 5 additions & 5 deletions tests/test_dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,27 +162,27 @@ def test_project_member(self):

class TestStatistics:
def test_statistics_get_task_statistics(self):
stat_list, _ = service.api.get_task_statistics(project_id)
stat_list = service.wrapper.get_task_statistics(project_id)
stat = ProjectTaskStatisticsHistory.from_dict(stat_list[0])
assert type(stat) == ProjectTaskStatisticsHistory

def test_statistics_get_account_statistics(self):
stat_list, _ = service.api.get_account_statistics(project_id)
stat_list = service.wrapper.get_account_statistics(project_id)
stat = ProjectAccountStatistics.from_dict(stat_list[0])
assert type(stat) == ProjectAccountStatistics

def test_statistics_get_inspection_statistics(self):
stat_list, _ = service.api.get_inspection_statistics(project_id)
stat_list = service.wrapper.get_inspection_statistics(project_id)
stat = InspectionStatistics.from_dict(stat_list[0])
assert type(stat) == InspectionStatistics

def test_statistics_get_task_phase_statistics(self):
stat_list, _ = service.api.get_task_phase_statistics(project_id)
stat_list = service.wrapper.get_task_phase_statistics(project_id)
stat = TaskPhaseStatistics.from_dict(stat_list[0])
assert type(stat) == TaskPhaseStatistics

def test_statistics_get_label_statistics(self):
stat_list, _ = service.api.get_label_statistics(project_id)
stat_list = service.wrapper.get_label_statistics(project_id)
stat = LabelStatistics.from_dict(stat_list[0])
assert type(stat) == LabelStatistics

Expand Down