From 4bfa8a546027ad3f6292c9d8f69e3abf2f46c864 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 27 Aug 2024 18:42:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20insert=5Fmplogx=5Ffrom=5Fxscript=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/enm/tasks.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/apps/enm/tasks.py b/apps/enm/tasks.py index 38f28433..5cf6a811 100644 --- a/apps/enm/tasks.py +++ b/apps/enm/tasks.py @@ -40,15 +40,9 @@ def get_current_and_previous_time(): @shared_task(base=CustomTask) def insert_mplogx_from_xscript(xscript_id): xscript = Xscript.objects.get(id=xscript_id) - eval_code = """ - from apps.utils.sql import DbConnection - from apps.enm.tasks import db_insert_mplogx_batch - import datetime - from django.utils import timezone - - {code} - """.format(code=xscript.code) - exec(eval_code) + mcodes_list = Mpoint.objects.filter(enabled=True).values_list('code', flat=True) + if mcodes_list: + exec(xscript.code) def db_insert_mplogx_batch(rows):