Skip to content

Commit

Permalink
Merge pull request #27 from TencentBlueKing/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
OrenZhang authored Nov 2, 2023
2 parents ee4a89b + 9d29a4e commit d2cd782
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/backend/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
V1.6.1
V1.6.2
2 changes: 1 addition & 1 deletion src/backend/services/web/analyze/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class FlowSQLNodeType(TextChoices):
def get_sql_node_type(cls, node_type: str) -> str:
if node_type == FlowDataSourceNodeType.REALTIME.value:
return cls.REALTIME.value
elif node_type == FlowDataSourceNodeType.BATCH.value:
elif node_type in [FlowDataSourceNodeType.BATCH.value, FlowDataSourceNodeType.BATCH_REAL.value]:
return cls.BATCH_V2.value
else:
raise KeyError("NodeType [%s] Not Exists" % node_type)
Expand Down
33 changes: 23 additions & 10 deletions src/backend/services/web/analyze/controls/aiops.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,8 @@ def _build_data_source_node(self) -> dict:
data_source = self.strategy.configs["data_source"]
source_type = data_source["source_type"]

# check batch / batch_join
if source_type == FlowDataSourceNodeType.BATCH:
result_table = api.bk_base.get_result_table(result_table_id=data_source["result_table_id"])
if (
result_table["processing_type"] == ResultTableType.CDC
or result_table["result_table_type"] == ResultTableType.STATIC
):
source_type = FlowDataSourceNodeType.BATCH
else:
source_type = FlowDataSourceNodeType.BATCH_REAL
source_type = self.check_source_type(result_table_id=data_source["result_table_id"])

return {
"node_type": source_type,
Expand All @@ -312,16 +304,35 @@ def _build_data_source_node(self) -> dict:
"name": data_source["result_table_id"],
}

def check_source_type(self, result_table_id: str) -> str:
"""
check batch / batch_join
"""

result_table = api.bk_base.get_result_table(result_table_id=result_table_id)
if (
result_table["processing_type"] == ResultTableType.CDC
or result_table["result_table_type"] == ResultTableType.STATIC
):
return FlowDataSourceNodeType.BATCH
else:
return FlowDataSourceNodeType.BATCH_REAL

def _build_sql_node(self, bk_biz_id: int, raw_table_name: str) -> dict:
"""
build sql node
"""

# init params
data_source = self.strategy.configs["data_source"]
source_type = data_source["source_type"]
plan_config = data_source.get("plan_config", {})
aiops_config = self.strategy.configs.get("aiops_config", {})

# check source type
if source_type == FlowDataSourceNodeType.BATCH:
source_type = self.check_source_type(result_table_id=data_source["result_table_id"])

# init sql node
sql_node_type = FlowSQLNodeType.get_sql_node_type(data_source["source_type"])
sql_node_params = {
Expand Down Expand Up @@ -386,7 +397,9 @@ def _build_sql_node(self, bk_biz_id: int, raw_table_name: str) -> dict:
"dependency_rule": plan_config.get("window_offset_unit", WindowDependencyRule.NO_FAILED),
"accumulate_start_time": datetime.datetime.now().strftime(api_settings.DATETIME_FORMAT),
"result_table_id": sql_node_params["from_result_table_ids"][0],
"window_type": WindowType.WHOLE,
"window_type": WindowType.WHOLE
if source_type == FlowDataSourceNodeType.BATCH
else WindowType.SCROLL,
"color": BKBASE_DEFAULT_WINDOW_COLOR,
}
],
Expand Down
11 changes: 11 additions & 0 deletions src/backend/version_md/V1.6.2_20231102_en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## V1.6.2 Release Note

---

### Feature

- [ Feature ] Support for hyperlink of instance schema

### Bugfix

- [ Bugfix ] Fix invalid window type of batch data
11 changes: 11 additions & 0 deletions src/backend/version_md/V1.6.2_20231102_zh-cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## V1.6.2 版本更新日志

---

### 新增

- [ 新增 ] 支持超链接类型的实例数据字段

### 修复

- [ 修复 ] 修复离线流水表计算时的数据窗口异常
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!--
TencentBlueKing is pleased to support the open source community by making
蓝鲸智云 - 审计中心 (BlueKing - Audit Center) available.
Copyright (C) 2023 THL A29 Limited,
a Tencent company. All rights reserved.
Licensed under the MIT License (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://opensource.org/licenses/MIT
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the
specific language governing permissions and limitations under the License.
We undertake not to change the open source license (MIT license) applicable
to the current version of the project delivered to anyone in the future.
-->
<template>
<a
:href="data"
target="_blank">
{{ data }}
</a>
</template>
<script setup lang="ts">
interface Props{
data: string
}
defineProps<Props>();
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@
{{ item.key }}
</td>
<td class="hover-table-value">
<multiple-line-clamp
:data="item.value" />
<!-- <multiple-line-clamp
:data="item.value" /> -->
<component
:is="comMap[item.type as keyof typeof comMap]"
:data="item.value"
target="_blank"
:to="item.value" />
</td>
<template v-if="length>4">
<template v-if="colDataRight[index]">
Expand All @@ -47,8 +52,13 @@
<td
class="hover-table-value border-bottom"
style="width: 36%;word-break: break-all;">
<multiple-line-clamp
:data="colDataRight[index].value " />
<!-- <multiple-line-clamp
:data="colDataRight[index].value" /> -->
<component
:is="comMap[colDataRight[index].type as keyof typeof comMap]"
:data="colDataRight[index].value"
target="_blank"
:to="colDataRight[index].value" />
</td>
</template>
</template>
Expand All @@ -73,6 +83,7 @@
import MultipleLineClamp from '@components/multiple-line-clamp/index.vue';

import DescPopover from './components/desc-popover.vue';
import RenderRouterLink from './components/field-link.vue';
import RenderFieldText from './components/field-text.vue';

interface Props{
Expand All @@ -83,6 +94,7 @@
interface IResults {
key:string;
value:string;
type: string;
}
// const { t } = useI18n();

Expand All @@ -93,6 +105,11 @@
const poverWidth = ref(325);
const updateAfterValues = ref();

const comMap = {
url: RenderRouterLink,
other: MultipleLineClamp,
};

/**
* 从接口获取中文字段名称
*/
Expand All @@ -107,24 +124,31 @@
},
defaultValue: [],
onSuccess: (data) => {
const tmpSchemaResult = data.reduce((result, item) => ({
// eslint-disable-next-line no-param-reassign
...result,
[item.id]: item,
}), {} as Record<string, ResourceTypeSchemaModel>);

colDataLeft.value = colDataLeft.value.map((item:IResults) => ({
key: (tmpSchemaResult[item.key] && tmpSchemaResult[item.key].description) || item.key,
value: updateAfterValues.value[item.key],
}));

colDataRight.value = colDataRight.value.map((item: IResults) => ({
key: (tmpSchemaResult[item.key] && tmpSchemaResult[item.key].description) || item.key,
value: updateAfterValues.value[item.key],
}));
if (data.length > 0) {
const tmpSchemaResult = data.reduce((result, item) => ({
// eslint-disable-next-line no-param-reassign
...result,
[item.id]: item,
}), {} as Record<string, ResourceTypeSchemaModel>);
colDataLeft.value = colDataLeft.value.map((item: IResults, index) => updateItem(item, index, 'left', tmpSchemaResult));
colDataRight.value = colDataRight.value.map((item: IResults, index) => updateItem(item, index, 'right', tmpSchemaResult));
}
},
});

const updateItem = (item: IResults, index: number, type: 'left' | 'right', tmpSchemaResult: Record<string, any>) => {
const key = (tmpSchemaResult[item.key] && tmpSchemaResult[item.key].description) || item.key;
const value = updateAfterValues.value[item.key];
const itemType = tmpSchemaResult[item.key] && tmpSchemaResult[item.key].type;
const typeResult = itemType === 'url' ? 'url' : 'other';

return {
key,
value,
type: typeResult,
};
};

const handleAfterShow = async () => {
/**
* 弹框展示后处理数据
Expand All @@ -134,8 +158,8 @@
const data = (updateFields as Array<string>).map((item: string) => ({
key: item,
value: updateAfterValues.value[item],
type: 'other',
}));

/**
* 当有超过四条数据一行展示两个数据
*/
Expand Down

0 comments on commit d2cd782

Please sign in to comment.