From 902cfbe89f0320b0b87c74f4763ad6a24ee080f9 Mon Sep 17 00:00:00 2001 From: vapao Date: Tue, 6 Jul 2021 00:31:16 +0800 Subject: [PATCH] fix issues --- spug_api/apps/monitor/executors.py | 2 +- spug_api/apps/monitor/models.py | 4 ++-- spug_api/apps/monitor/views.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spug_api/apps/monitor/executors.py b/spug_api/apps/monitor/executors.py index d40946b..e9172a8 100644 --- a/spug_api/apps/monitor/executors.py +++ b/spug_api/apps/monitor/executors.py @@ -18,7 +18,7 @@ logging.captureWarnings(True) def site_check(url, limit): try: - res = requests.get(url, timeout=10, verify=False) + res = requests.get(url, timeout=10) if limit: duration = int(res.elapsed.total_seconds() * 1000) if duration > int(limit): diff --git a/spug_api/apps/monitor/models.py b/spug_api/apps/monitor/models.py index afc4579..e9bee44 100644 --- a/spug_api/apps/monitor/models.py +++ b/spug_api/apps/monitor/models.py @@ -39,8 +39,8 @@ class Detection(models.Model, ModelMixin): updated_at = models.CharField(max_length=20, null=True) updated_by = models.ForeignKey(User, models.PROTECT, related_name='+', null=True) - def to_dict(self, *args, **kwargs): - tmp = super().to_dict(*args, **kwargs) + def to_view(self): + tmp = self.to_dict() tmp['type_alias'] = self.get_type_display() tmp['notify_mode'] = json.loads(self.notify_mode) tmp['notify_grp'] = json.loads(self.notify_grp) diff --git a/spug_api/apps/monitor/views.py b/spug_api/apps/monitor/views.py index 3f9674c..5db6a91 100644 --- a/spug_api/apps/monitor/views.py +++ b/spug_api/apps/monitor/views.py @@ -14,7 +14,7 @@ class DetectionView(View): def get(self, request): detections = Detection.objects.all() groups = [x['group'] for x in detections.order_by('group').values('group').distinct()] - return json_response({'groups': groups, 'detections': [x.to_dict() for x in detections]}) + return json_response({'groups': groups, 'detections': [x.to_view() for x in detections]}) def post(self, request): form, error = JsonParser( @@ -64,7 +64,7 @@ class DetectionView(View): if form.is_active: task = Detection.objects.filter(pk=form.id).first() message = {'id': form.id, 'action': 'add'} - message.update(task.to_dict(selects=('targets', 'extra', 'rate', 'type'))) + message.update(task.to_dict(selects=('targets', 'extra', 'rate', 'type', 'threshold', 'quiet'))) else: message = {'id': form.id, 'action': 'remove'} rds_cli = get_redis_connection()