diff --git a/src/backend/core/models.py b/src/backend/core/models.py index 57c3179..6e391b8 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 06e4ef1..d4d4260 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")