From 6f8c7c056724138dad3ad0c8e561f434030e58b0 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Sat, 20 Jan 2024 23:30:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20mlog=20validate=E6=97=B6=E8=AE=A1?= =?UTF-8?q?=E7=AE=97count=5Fnotok?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/serializers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/wpm/serializers.py b/apps/wpm/serializers.py index 210e9376..925f87ff 100644 --- a/apps/wpm/serializers.py +++ b/apps/wpm/serializers.py @@ -289,6 +289,11 @@ class MlogSerializer(CustomModelSerializer): def validate(self, attrs): mtask = attrs.get('mtask', None) + count_notok = 0 + for i in attrs: + if 'count_n_' in i: + count_notok = count_notok + attrs[i] + attrs['count_notok'] = count_notok if mtask: if mtask.start_date == mtask.end_date: attrs['handle_date'] = mtask.start_date From e193a663c6d9934d412e3bf60900ed5d7f0e8429 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Sun, 21 Jan 2024 00:06:19 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E5=8F=96=E6=B6=88dataset=20exec=20?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95=E5=8F=8A=E5=8F=AF=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E6=8A=9B=E5=87=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/bi/serializers.py | 1 + apps/bi/views.py | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/bi/serializers.py b/apps/bi/serializers.py index 74338540..69f7a030 100644 --- a/apps/bi/serializers.py +++ b/apps/bi/serializers.py @@ -34,3 +34,4 @@ class DataExecSerializer(serializers.Serializer): query = serializers.JSONField( label="查询字典参数", required=False, allow_null=True) is_test = serializers.BooleanField(label='是否测试', default=False) + raise_exception = serializers.BooleanField(label='是否直接报错', default=False) diff --git a/apps/bi/views.py b/apps/bi/views.py index ed814e84..64193e33 100644 --- a/apps/bi/views.py +++ b/apps/bi/views.py @@ -54,7 +54,7 @@ class DatasetViewSet(CustomModelViewSet): return obj - @action(methods=['post'], detail=True, perms_map={'post': 'dataset.exec'}, serializer_class=DataExecSerializer, cache_seconds=0) + @action(methods=['post'], detail=True, perms_map={'post': 'dataset.exec'}, serializer_class=DataExecSerializer, cache_seconds=0, logging_methods=[]) def exec(self, request, pk=None): """执行sql查询 @@ -64,6 +64,7 @@ class DatasetViewSet(CustomModelViewSet): rdata = DatasetSerializer(instance=dt).data query = request.data.get('query', {}) is_test = request.data.get('is_test', False) + raise_exception = request.data.get('raise_exception', False) query['r_user'] = request.user.id query['r_dept'] = request.user.belong_dept.id if request.user.belong_dept else '' results = {} @@ -104,8 +105,11 @@ class DatasetViewSet(CustomModelViewSet): results[name], results2[name] = format_sqldata( res[0], res[1]) except Exception as e: - results[name] = 'error: ' + str(e) - can_cache = False + if raise_exception: + raise + else: + results[name] = 'error: ' + str(e) + can_cache = False rdata['data'] = results rdata['data2'] = results2 if rdata['echart_options'] and not rdata['echart_options'].startswith('function'): From 6827b722317b907e98fa776aff3ecf91c22c110e Mon Sep 17 00:00:00 2001 From: caoqianming Date: Sun, 21 Jan 2024 00:23:49 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20base=20=E5=A2=9E=E5=8A=A0=E6=9C=80?= =?UTF-8?q?=E5=A4=A7=E8=8E=B7=E5=8F=96=E5=88=97=E8=A1=A8=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/utils/pagination.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/utils/pagination.py b/apps/utils/pagination.py index d437e4b3..cd1b1a0e 100755 --- a/apps/utils/pagination.py +++ b/apps/utils/pagination.py @@ -11,7 +11,7 @@ class MyPagination(PageNumberPagination): def paginate_queryset(self, queryset, request, view=None): if request.query_params.get('pageoff', None) or request.query_params.get('page', None) == '0': - if queryset.count() < 800: + if queryset.count() < 3000: return None raise ParseError('单次请求数据量大,请分页获取') return super().paginate_queryset(queryset, request, view=view)