From c6f264f4d741db320060be54a06e84ab8d6230ed Mon Sep 17 00:00:00 2001 From: lTimej <65690352+lTimej@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:52:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20get=5Ffunctionalization=5Ftask=5Flist?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E8=81=8C=E8=83=BD=E5=8C=96=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=95=B0=E6=8D=AE=20#7374=20(#7388)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: get_functionalization_task_list获取职能化相关任务数据 #7374 * fix: 修改筛选创建日期范围字段名和添加get_functionalization_task_list接口文档 #7374 --- .pre-commit-config.yaml | 2 +- docs/apidoc/en/get_functionalization_task_list.md | 2 ++ docs/apidoc/zh_hans/get_functionalization_task_list.md | 2 ++ gcloud/apigw/forms/get_functionalization_task_list.py | 2 ++ gcloud/apigw/views/get_functionalization_task_list.py | 10 ++++++---- gcloud/apigw/views/utils.py | 4 ++-- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e599933bae..196ed9ed72 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/docs/apidoc/en/get_functionalization_task_list.md b/docs/apidoc/en/get_functionalization_task_list.md index b9e63bfa20..01c5d380f8 100644 --- a/docs/apidoc/en/get_functionalization_task_list.md +++ b/docs/apidoc/en/get_functionalization_task_list.md @@ -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 diff --git a/docs/apidoc/zh_hans/get_functionalization_task_list.md b/docs/apidoc/zh_hans/get_functionalization_task_list.md index 020f61125c..12cbe81f0e 100644 --- a/docs/apidoc/zh_hans/get_functionalization_task_list.md +++ b/docs/apidoc/zh_hans/get_functionalization_task_list.md @@ -13,6 +13,8 @@ | project_id | int | 否 | 项目id作为过滤条件,仅支持标准运维项目id,非ccid | | limit | int | 否 | 分页,返回任务列表任务数,默认为100 | | offset | int | 否 | 分页,返回任务列表起始任务下标,默认为0 | +| create_time_gte | string | 否 | 职能化任务创建时间起始时间 | +| create_time_lte | string | 否 | 职能化任务创建时间截止时间 | ### 请求参数示例 diff --git a/gcloud/apigw/forms/get_functionalization_task_list.py b/gcloud/apigw/forms/get_functionalization_task_list.py index 358e195cbc..affb836167 100644 --- a/gcloud/apigw/forms/get_functionalization_task_list.py +++ b/gcloud/apigw/forms/get_functionalization_task_list.py @@ -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) diff --git a/gcloud/apigw/views/get_functionalization_task_list.py b/gcloud/apigw/views/get_functionalization_task_list.py index bdc20a343f..a7d53c2027 100644 --- a/gcloud/apigw/views/get_functionalization_task_list.py +++ b/gcloud/apigw/views/get_functionalization_task_list.py @@ -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 @@ -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(): diff --git a/gcloud/apigw/views/utils.py b/gcloud/apigw/views/utils.py index 6bf6b71f22..f87fecdfe5 100644 --- a/gcloud/apigw/views/utils.py +++ b/gcloud/apigw/views/utils.py @@ -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 @@ -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