Преглед изворни кода

Refactor risk command to use a dedicated reply method for improved message handling. Update database query execution to utilize a more efficient approach, enhancing performance and readability.

Carles Sentis пре 3 дана
родитељ
комит
1a5f8aae35
3 измењених фајлова са 4 додато и 6 уклоњено
  1. 1 1
      src/commands/info/risk.py
  2. 2 4
      src/stats/database_manager.py
  3. 1 1
      trading_bot.py

+ 1 - 1
src/commands/info/risk.py

@@ -119,7 +119,7 @@ class RiskCommands(InfoCommandsBase):
                 message += f"Average Win: {await self.formatter.format_price_with_symbol(performance_stats.get('average_win', 0))}\n"
                 message += f"Average Loss: {await self.formatter.format_price_with_symbol(performance_stats.get('average_loss', 0))}\n"
             
-            await update.message.reply_text(message, parse_mode='HTML')
+            await self._reply(update, message)
             
         except Exception as e:
             logger.error(f"Error in risk command: {e}", exc_info=True)

+ 2 - 4
src/stats/database_manager.py

@@ -62,14 +62,12 @@ class DatabaseManager:
 
     def _fetch_query(self, query: str, params: tuple = ()) -> List[Dict[str, Any]]:
         """Execute a SELECT query and fetch all results."""
-        cur = self.conn.cursor()
-        cur.execute(query, params)
+        cur = self.conn.execute(query, params)
         return cur.fetchall()
 
     def _fetchone_query(self, query: str, params: tuple = ()) -> Optional[Dict[str, Any]]:
         """Execute a SELECT query and fetch one result."""
-        cur = self.conn.cursor()
-        cur.execute(query, params)
+        cur = self.conn.execute(query, params)
         return cur.fetchone()
 
     def _create_tables(self):

+ 1 - 1
trading_bot.py

@@ -14,7 +14,7 @@ from datetime import datetime
 from pathlib import Path
 
 # Bot version
-BOT_VERSION = "2.4.238"
+BOT_VERSION = "2.4.239"
 
 # Add src directory to Python path
 sys.path.insert(0, str(Path(__file__).parent / "src"))