Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
07750e4
1
Parent(s):
b748b45
added suggestions & tool tip
Browse files- src/routes/code_routes.py +12 -3
src/routes/code_routes.py
CHANGED
|
@@ -542,6 +542,7 @@ async def execute_code(
|
|
| 542 |
db.commit()
|
| 543 |
else:
|
| 544 |
# Create new record
|
|
|
|
| 545 |
new_execution = CodeExecution(
|
| 546 |
message_id=message_id,
|
| 547 |
chat_id=chat_id,
|
|
@@ -559,6 +560,7 @@ async def execute_code(
|
|
| 559 |
)
|
| 560 |
db.add(new_execution)
|
| 561 |
db.commit()
|
|
|
|
| 562 |
except Exception as db_error:
|
| 563 |
db.rollback()
|
| 564 |
logger.log_message(f"Error saving code execution: {str(db_error)}", level=logging.ERROR)
|
|
@@ -785,14 +787,21 @@ async def get_latest_code(
|
|
| 785 |
db = get_session()
|
| 786 |
|
| 787 |
try:
|
| 788 |
-
# Query the database for the latest code execution record
|
|
|
|
|
|
|
| 789 |
execution_record = db.query(CodeExecution).filter(
|
| 790 |
CodeExecution.message_id == message_id
|
| 791 |
-
).first()
|
| 792 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 793 |
|
| 794 |
if execution_record:
|
| 795 |
-
logger.log_message(f"
|
| 796 |
|
| 797 |
# Return the latest code and execution status
|
| 798 |
return {
|
|
|
|
| 542 |
db.commit()
|
| 543 |
else:
|
| 544 |
# Create new record
|
| 545 |
+
logger.log_message(f"Creating new CodeExecution record for message_id: {message_id}", level=logging.INFO)
|
| 546 |
new_execution = CodeExecution(
|
| 547 |
message_id=message_id,
|
| 548 |
chat_id=chat_id,
|
|
|
|
| 560 |
)
|
| 561 |
db.add(new_execution)
|
| 562 |
db.commit()
|
| 563 |
+
logger.log_message(f"Successfully created CodeExecution record with ID: {new_execution.execution_id} for message_id: {message_id}", level=logging.INFO)
|
| 564 |
except Exception as db_error:
|
| 565 |
db.rollback()
|
| 566 |
logger.log_message(f"Error saving code execution: {str(db_error)}", level=logging.ERROR)
|
|
|
|
| 787 |
db = get_session()
|
| 788 |
|
| 789 |
try:
|
| 790 |
+
# Query the database for the latest code execution record (ordered by created_at desc)
|
| 791 |
+
logger.log_message(f"Searching for execution records with message_id: {message_id}", level=logging.INFO)
|
| 792 |
+
|
| 793 |
execution_record = db.query(CodeExecution).filter(
|
| 794 |
CodeExecution.message_id == message_id
|
| 795 |
+
).order_by(CodeExecution.created_at.desc()).first()
|
| 796 |
|
| 797 |
+
# Also log total count of records for this message_id
|
| 798 |
+
total_records = db.query(CodeExecution).filter(
|
| 799 |
+
CodeExecution.message_id == message_id
|
| 800 |
+
).count()
|
| 801 |
+
logger.log_message(f"Found {total_records} execution records for message_id: {message_id}", level=logging.INFO)
|
| 802 |
|
| 803 |
if execution_record:
|
| 804 |
+
logger.log_message(f"Latest execution record found - success: {execution_record.is_successful}, latest_code length: {len(execution_record.latest_code or '') if execution_record.latest_code else 0}", level=logging.INFO)
|
| 805 |
|
| 806 |
# Return the latest code and execution status
|
| 807 |
return {
|