Skip to content

Commit

Permalink
feat: get_functionalization_task_list获取职能化相关任务数据 TencentBlueKing#7374 (
Browse files Browse the repository at this point in the history
…TencentBlueKing#7388)

* feat: get_functionalization_task_list获取职能化相关任务数据 TencentBlueKing#7374

* fix: 修改筛选创建日期范围字段名和添加get_functionalization_task_list接口文档 TencentBlueKing#7374
  • Loading branch information
lTimej authored Mar 14, 2024
1 parent caedfac commit c6f264f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
hooks:
- id: check-merge-conflict
- repo: https://github.com/psf/black
rev: stable
rev: 22.8.0
hooks:
- id: black
language_version: python3.6
Expand Down
2 changes: 2 additions & 0 deletions docs/apidoc/en/get_functionalization_task_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Get functionalization task list, support filtering with functionalization task s
| project_id | int | NO | project id for filtering, only support sops project id, not ccid |
| limit | int | NO | pagination, the number of tasks in the task list in each result. default is 100 |
| offset | int | NO | pagination, the start index of task in the task list in each result. default is 0 |
| create_time_gte | string | No | start time, the start time of the functionalization task creation |
| create_time_lte | string | No | end time, the end time of the functionalization task creation |

### Request Parameters Example

Expand Down
2 changes: 2 additions & 0 deletions docs/apidoc/zh_hans/get_functionalization_task_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
| project_id | int || 项目id作为过滤条件,仅支持标准运维项目id,非ccid |
| limit | int || 分页,返回任务列表任务数,默认为100 |
| offset | int || 分页,返回任务列表起始任务下标,默认为0 |
| create_time_gte | string || 职能化任务创建时间起始时间 |
| create_time_lte | string || 职能化任务创建时间截止时间 |

### 请求参数示例

Expand Down
2 changes: 2 additions & 0 deletions gcloud/apigw/forms/get_functionalization_task_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class GetFunctionalizationTaskListForm(forms.Form):
task_id_in = forms.CharField(required=False)
id_in = forms.CharField(required=False)
project_id = forms.IntegerField(required=False)
create_time_lte = forms.DateTimeField(required=False)
create_time_gte = forms.DateTimeField(required=False)

def _list_field_validate(self, field_name):
field_value = self.cleaned_data.get(field_name)
Expand Down
10 changes: 6 additions & 4 deletions gcloud/apigw/views/get_functionalization_task_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""
from apigw_manager.apigw.decorators import apigw_require
from blueapps.account.decorators import login_exempt
from django.views.decorators.http import require_GET

from blueapps.account.decorators import login_exempt
from gcloud import err_code
from gcloud.apigw.decorators import mark_request_whether_is_trust, timezone_inject, return_json_response
from gcloud.apigw.decorators import mark_request_whether_is_trust, return_json_response, timezone_inject
from gcloud.apigw.forms.get_functionalization_task_list import GetFunctionalizationTaskListForm
from gcloud.contrib.function.models import FunctionTask
from gcloud.apigw.views.utils import format_function_task_list_data, paginate_list_data
from gcloud.contrib.function.models import FunctionTask
from gcloud.iam_auth.intercept import iam_intercept
from gcloud.iam_auth.view_interceptors.apigw import FunctionViewInterceptor
from apigw_manager.apigw.decorators import apigw_require


@login_exempt
Expand All @@ -39,6 +39,8 @@ def get_functionalization_task_list(request):
"task_id_in": "task_id__in",
"status": "status",
"project_id": "task__project_id",
"create_time_lte": "create_time__lte",
"create_time_gte": "create_time__gte",
}
filter_kwargs = {}
for param, filter_key in param_mappings.items():
Expand Down
4 changes: 2 additions & 2 deletions gcloud/apigw/views/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def format_task_list_data(tasks, project=None, return_id_list=False, tz=None):
return data, ids


def format_function_task_list_data(function_tasks, project=None, tz=None):
def format_function_task_list_data(function_tasks, tz=None):
data = []
for function_task in function_tasks:
task_create_time = function_task.create_time
Expand All @@ -164,7 +164,7 @@ def format_function_task_list_data(function_tasks, project=None, tz=None):
"transfer_time": format_datetime(task_transfer_time, tz) if tz else task_transfer_time,
"status": function_task.status,
}
task_item = format_task_info_data(function_task.task, project=project, tz=tz)
task_item = format_task_info_data(function_task.task, project=function_task.task.project, tz=tz)
item["task"] = task_item
data.append(item)
return data
Expand Down

0 comments on commit c6f264f

Please sign in to comment.