Skip to content

Commit 2d7dda7

Browse files
committed
feat: add get_chat_with_data
1 parent 0b7bf18 commit 2d7dda7

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

backend/apps/chat/curd/chat.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,26 @@ def get_chat_with_records(session: SessionDep, chart_id: int, current_user: Curr
114114
result = session.execute(stmt).all()
115115
record_list: list[ChatRecord] = []
116116
for row in result:
117-
record_list.append(
118-
ChatRecord(id=row.id, chat_id=row.chat_id, create_time=row.create_time, finish_time=row.finish_time,
119-
question=row.question, sql_answer=row.sql_answer, sql=row.sql,
120-
chart_answer=row.chart_answer, chart=row.chart,
121-
analysis=row.analysis, predict=row.predict,
122-
datasource_select_answer=row.datasource_select_answer,
123-
analysis_record_id=row.analysis_record_id, predict_record_id=row.predict_record_id,
124-
recommended_question=row.recommended_question, first_chat=row.first_chat,
125-
finish=row.finish, error=row.error))
117+
if not with_data:
118+
record_list.append(
119+
ChatRecord(id=row.id, chat_id=row.chat_id, create_time=row.create_time, finish_time=row.finish_time,
120+
question=row.question, sql_answer=row.sql_answer, sql=row.sql,
121+
chart_answer=row.chart_answer, chart=row.chart,
122+
analysis=row.analysis, predict=row.predict,
123+
datasource_select_answer=row.datasource_select_answer,
124+
analysis_record_id=row.analysis_record_id, predict_record_id=row.predict_record_id,
125+
recommended_question=row.recommended_question, first_chat=row.first_chat,
126+
finish=row.finish, error=row.error))
127+
else:
128+
record_list.append(
129+
ChatRecord(id=row.id, chat_id=row.chat_id, create_time=row.create_time, finish_time=row.finish_time,
130+
question=row.question, sql_answer=row.sql_answer, sql=row.sql,
131+
chart_answer=row.chart_answer, chart=row.chart,
132+
analysis=row.analysis, predict=row.predict,
133+
datasource_select_answer=row.datasource_select_answer,
134+
analysis_record_id=row.analysis_record_id, predict_record_id=row.predict_record_id,
135+
recommended_question=row.recommended_question, first_chat=row.first_chat,
136+
finish=row.finish, error=row.error, data=row.data, predict_data=row.predict_data))
126137

127138
result = list(map(format_record, record_list))
128139

0 commit comments

Comments
 (0)