Skip to content

Commit

Permalink
feat: 私有化部署 --story=119894675
Browse files Browse the repository at this point in the history
1. 修复获取 data id 接口异常
  • Loading branch information
0RAJA committed Oct 29, 2024
2 parents 7087c70 + d30cbef commit 77c8d55
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 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
2 changes: 1 addition & 1 deletion src/backend/services/web/databus/collector/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class DataIdInfoSerializer(serializers.Serializer):
bk_biz_id = serializers.IntegerField(label=gettext_lazy("业务ID"))
raw_data_name = serializers.CharField(label=gettext_lazy("数据源名称"))
raw_data_alias = serializers.CharField(label=gettext_lazy("数据源别名"))
custom_type = serializers.CharField(label=gettext_lazy("接入场景"))
custom_type = serializers.CharField(label=gettext_lazy("接入场景"), allow_null=True)

def to_internal_value(self, data: dict) -> dict:
data["bk_data_id"] = data.pop("id", None)
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 77c8d55

Please sign in to comment.