Skip to content

Commit 9c53f04

Browse files
committed
Merge branch 'main' of https://github.com/dataease/SQLBot
2 parents 5dedcec + ab11a20 commit 9c53f04

File tree

7 files changed

+36
-5
lines changed

7 files changed

+36
-5
lines changed

backend/template.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@ template:
77
根据表结构和问题生成符合{engine}数据库引擎规范的sql语句,以及sql中所用到的表名(不要包含schema和database,用数组返回)。
88
你必须遵守以下规则:
99
- 生成的SQL必须符合{engine}的规范。
10+
- 提问中如果有涉及数据源名称或数据源描述的内容,则忽略数据源的信息,直接根据剩余内容生成SQL
1011
- 根据表结构生成SQL语句,需给每个表名生成一个别名(不要加AS)。
1112
- SQL查询中不能使用星号(*),必须明确指定字段名.
1213
- SQL查询的字段名不要自动翻译,别名必须为英文。
1314
- 计算占比,百分比类型字段,保留两位小数,以%结尾。
14-
- 生成SQL时,必须避免关键字冲突:
15+
- 生成SQL时,必须避免关键字冲突
1516
- 如数据库引擎是 PostgreSQL、Oracle,则在schema、表名、字段名、别名外层加双引号;
1617
- 如数据库引擎是 MySQL,则在表名、字段名、别名外层加反引号;
1718
- 如数据库引擎是 Microsoft SQL Server,则在schema、表名、字段名、别名外层加方括号。
19+
- 以PostgreSQL为例,查询Schema为TEST表TABLE下所有数据,则生成的SQL为:
20+
SELECT * FROM "TEST"."TABLE"
21+
- 注意在表名外双引号的位置,千万不要生成为:
22+
SELECT * FROM "TEST.TABLE"
1823
- 如果生成SQL的字段内有时间格式的字段(重要):
1924
- 若提问中没有指定查询顺序,则默认按时间升序排序
2025
- 若提问是时间,且没有指定具体格式,则格式化为yyyy-MM-dd HH:mm:ss的格式

frontend/src/views/chat/chat-block/ChartBlock.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,9 @@ function showSql() {
192192
}
193193
194194
function addToDashboard() {
195+
const viewInfo = chartRef.value?.getViewInfo()
195196
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
196-
addViewRef.value?.optInit()
197+
addViewRef.value?.optInit(viewInfo)
197198
}
198199
199200
function copy() {

frontend/src/views/chat/component/DisplayChartBlock.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,22 @@ function onTypeChange() {
5454
chartRef.value?.renderChart()
5555
})
5656
}
57-
57+
function getViewInfo() {
58+
return {
59+
chart: {
60+
columns: chartObject.value?.columns,
61+
type: props.chartType,
62+
xAxis: xAxis.value,
63+
yAxis: yAxis.value,
64+
series: series.value,
65+
title: chartObject.value.title,
66+
},
67+
data: { data: props.data },
68+
}
69+
}
5870
defineExpose({
5971
onTypeChange,
72+
getViewInfo,
6073
})
6174
</script>
6275

frontend/src/views/chat/component/charts/Bar.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ export class Bar extends BaseG2Chart {
113113
}
114114
return `${value}${_data.isPercent ? '%' : ''}`
115115
},
116+
position: (data: any) => {
117+
if (data[y[0].value] < 0) {
118+
return 'left'
119+
}
120+
return 'right'
121+
},
116122
transform: [
117123
{ type: 'contrastReverse' },
118124
{ type: 'exceedAdjust' },

frontend/src/views/chat/component/charts/Column.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ export class Column extends BaseG2Chart {
102102
}
103103
return `${value}${_data.isPercent ? '%' : ''}`
104104
},
105-
position: 'top',
105+
position: (data: any) => {
106+
if (data[y[0].value] < 0) {
107+
return 'bottom'
108+
}
109+
return 'top'
110+
},
106111
transform: [
107112
{ type: 'contrastReverse' },
108113
{ type: 'exceedAdjust' },

frontend/src/views/chat/index.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ function onChatCreatedQuick(chat: ChatInfo) {
485485
chatList.value.unshift(chat)
486486
currentChatId.value = chat.id
487487
currentChat.value = chat
488-
console.log(chat)
489488
onChatCreated(chat)
490489
}
491490

frontend/src/views/dashboard/common/AddViewDashboard.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ const saveResourcePrepare = () => {
8686
component['id'] = newComponentId
8787
component['y'] = bottomPosition + 1
8888
canvasDataResult.push(component)
89+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
90+
state.viewInfo.chart['id'] = newComponentId
8991
canvasViewInfoPreview[newComponentId] = state.viewInfo
9092
const commonParams = {
9193
componentData: canvasDataResult,

0 commit comments

Comments
 (0)