Skip to content

Commit

Permalink
feat: 私有化部署 --story=119894675
Browse files Browse the repository at this point in the history
1. 去除后台任务不补充通用字段
2. 系统初始化时主动创建或更新采集入库

(cherry picked from commit 2fbc6ab)
  • Loading branch information
0RAJA committed Oct 25, 2024
1 parent 7087c70 commit d30cbef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
16 changes: 0 additions & 16 deletions src/backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(),
Expand All @@ -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()
Expand All @@ -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()
Expand Down
8 changes: 8 additions & 0 deletions src/backend/services/web/entry/init/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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")

0 comments on commit d30cbef

Please sign in to comment.