From d30cbefef633914fbe6feb6c49b1f7bdbbefc8a0 Mon Sep 17 00:00:00 2001 From: raja <1647193241@qq.com> Date: Wed, 23 Oct 2024 10:24:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A7=81=E6=9C=89=E5=8C=96=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=20--story=3D119894675?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 去除后台任务不补充通用字段 2. 系统初始化时主动创建或更新采集入库 (cherry picked from commit 2fbc6abe0a9c3ff8a0ecef9cdf31a8f7b9d6e912) --- src/backend/core/models.py | 16 ---------------- src/backend/services/web/entry/init/base.py | 8 ++++++++ 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/backend/core/models.py b/src/backend/core/models.py index 57c3179a..6e391b8c 100644 --- a/src/backend/core/models.py +++ b/src/backend/core/models.py @@ -60,10 +60,6 @@ def update(self, **kwargs): 重写ORM 更新方法 """ - # 后台任务不处理 - if is_backend(): - return super().update(**kwargs) - # 是否跳过更新时间或更新人,某些特殊场景下使用 if kwargs.pop("skip_update_time", False): kwargs.pop("updated_at", None) @@ -92,10 +88,6 @@ def get_queryset(self): def create(self, *args, **kwargs): """创建数据 自动填写通用字段""" - # 后台任务不处理 - if is_backend(): - return super().create(*args, **kwargs) - kwargs.update( { "created_at": kwargs.get("created_at") or timezone.now(), @@ -109,10 +101,6 @@ def create(self, *args, **kwargs): def bulk_create(self, objs, *args, **kwargs): """创建数据 自动填写通用字段""" - # 后台任务不处理 - if is_backend(): - return super().bulk_create(objs, *args, **kwargs) - for obj in objs: obj.created_at = obj.created_at or timezone.now() obj.created_by = obj.created_by or get_request_username() @@ -123,10 +111,6 @@ def bulk_create(self, objs, *args, **kwargs): def bulk_update(self, objs, *args, **kwargs): """更新数据 自动填写通用字段""" - # 后台任务不处理 - if is_backend(): - return super().bulk_update(objs, *args, **kwargs) - for obj in objs: obj.created_at = obj.created_at or timezone.now() obj.created_by = obj.created_by or get_request_username() diff --git a/src/backend/services/web/entry/init/base.py b/src/backend/services/web/entry/init/base.py index 06e4ef1d..d4d4260e 100644 --- a/src/backend/services/web/entry/init/base.py +++ b/src/backend/services/web/entry/init/base.py @@ -31,6 +31,7 @@ CreateRedisRequestSerializer, StorageCreateRequestSerializer, ) +from services.web.databus.tasks import create_or_update_plugin_etl from services.web.entry.constants import ( INIT_ES_FISHED_KEY, INIT_FIELDS_FINISHED_KEY, @@ -80,6 +81,7 @@ def init(self): self.init_redis() self.init_snapshot() self.init_event() + self.create_or_update_plugin_etl() print("[Main] Init Finished") def pre_init(self): @@ -158,3 +160,9 @@ def init_event(self): print("[InitEvent] Start") EventHandler().update_or_create_rt() print("[InitEvent] Stop") + + def create_or_update_plugin_etl(self): + """创建或更新采集入库""" + print("[CreateOrUpdatePluginEtl] Start") + create_or_update_plugin_etl() + print("[CreateOrUpdatePluginEtl] Stop")