Skip to content

Commit 6ad151d

Browse files
committed
fix: check ds status
1 parent 2fc9e41 commit 6ad151d

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

backend/apps/datasource/api/datasource.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async def get_datasource(session: SessionDep, id: int):
3030

3131
@router.post("/check")
3232
async def check(session: SessionDep, ds: CoreDatasource):
33-
return check_status(session, ds)
33+
return check_status(session, ds, True)
3434

3535

3636
@router.post("/add", response_model=CoreDatasource)

backend/apps/datasource/crud/datasource.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@ def get_ds(session: SessionDep, id: int):
3535
return datasource
3636

3737

38-
def check_status(session: SessionDep, ds: CoreDatasource):
38+
def check_status(session: SessionDep, ds: CoreDatasource, is_raise: bool = False):
3939
conn = get_engine(ds)
4040
try:
4141
with conn.connect() as connection:
4242
print("success")
4343
return True
4444
except Exception as e:
45-
raise HTTPException(status_code=500, detail=e.args)
45+
if is_raise:
46+
raise HTTPException(status_code=500, detail=f'Connect Failed: {e.args}')
4647
print("Fail:", e)
4748
return False
4849

backend/apps/db/db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def get_tables(ds: CoreDatasource):
126126
LEFT JOIN
127127
pg_description d ON d.objoid = c.oid AND d.objsubid = 0
128128
WHERE n.nspname = current_schema()
129-
AND c.relkind IN ('r', 'v')
129+
AND c.relkind IN ('r', 'v', 'p')
130130
AND c.relname NOT LIKE 'pg_%'
131131
AND c.relname NOT LIKE 'sql_%'
132132
ORDER BY c.relname \

frontend/src/views/ds/Datasource.vue

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,16 @@ const handleEditDatasource = (res: any) => {
9595
})
9696
}
9797
98-
const handleQuestion = (id: string) => {
99-
router.push({
100-
path: '/chat/index',
101-
query: {
102-
start_chat: id,
103-
},
98+
const handleQuestion = (ele: any) => {
99+
datasourceApi.check(ele).then((res: any) => {
100+
if (res) {
101+
router.push({
102+
path: '/chat/index',
103+
query: {
104+
start_chat: ele.id,
105+
},
106+
})
107+
}
104108
})
105109
}
106110
@@ -290,7 +294,7 @@ const back = () => {
290294
:type-name="ele.type_name"
291295
:num="ele.num"
292296
:description="ele.description"
293-
@question="handleQuestion"
297+
@question="handleQuestion(ele)"
294298
@edit="handleEditDatasource(ele)"
295299
@del="deleteHandler(ele)"
296300
@data-table-detail="dataTableDetail(ele)"

0 commit comments

Comments
 (0)