From e025f37222a7ea90ba530db1a6559226b429a452 Mon Sep 17 00:00:00 2001 From: Steph Ponzo Date: Sun, 1 Mar 2026 17:56:32 +0100 Subject: [PATCH] fix(strategy): corrections schema DB, pool import, route signal dans gateway --- Wallette/gateway/gateway.js | 1 + Wallette/git | 0 .../server/modules/strategy/repositories/MarketDataRepo.js | 4 ++-- .../server/modules/strategy/repositories/StrategyRepo.js | 6 +++--- 4 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 Wallette/git diff --git a/Wallette/gateway/gateway.js b/Wallette/gateway/gateway.js index 9cfa0a8..3e3abd7 100644 --- a/Wallette/gateway/gateway.js +++ b/Wallette/gateway/gateway.js @@ -55,6 +55,7 @@ const ROUTES = [ { prefix: '/api/price', upstream: SERVICE_BASE_URLS.price, name: 'price-service' }, { prefix: '/api/pairs', upstream: SERVICE_BASE_URLS.price, name: 'price-service' }, { prefix: '/api/strategy', upstream: SERVICE_BASE_URLS.strategy, name: 'strategy-service' }, + { prefix: '/api/signal', upstream: SERVICE_BASE_URLS.strategy, name: 'strategy-service' }, ].sort((a, b) => b.prefix.length - a.prefix.length); const PROXY_TIMEOUT_MS = 5000; diff --git a/Wallette/git b/Wallette/git new file mode 100644 index 0000000..e69de29 diff --git a/Wallette/server/modules/strategy/repositories/MarketDataRepo.js b/Wallette/server/modules/strategy/repositories/MarketDataRepo.js index 1012ec8..c887508 100644 --- a/Wallette/server/modules/strategy/repositories/MarketDataRepo.js +++ b/Wallette/server/modules/strategy/repositories/MarketDataRepo.js @@ -11,7 +11,7 @@ class MarketDataRepo { */ async getLastCandles(pairId, limit = 100) { const sql = ` - SELECT + SELECT timestamp_ms, open_price, high_price, @@ -39,4 +39,4 @@ class MarketDataRepo { } const marketDataRepo = new MarketDataRepo(); -export default marketDataRepo; \ No newline at end of file +export default marketDataRepo; diff --git a/Wallette/server/modules/strategy/repositories/StrategyRepo.js b/Wallette/server/modules/strategy/repositories/StrategyRepo.js index 3432d54..1e87aad 100644 --- a/Wallette/server/modules/strategy/repositories/StrategyRepo.js +++ b/Wallette/server/modules/strategy/repositories/StrategyRepo.js @@ -41,7 +41,7 @@ class StrategyRepo { // On vérifie si l'utilisateur a déjà une configuration pour cette paire const checkSql = `SELECT user_strategy_id FROM user_strategies WHERE user_id = ? AND pair_id = ?`; - const [rows] = await db.query(checkSql, [userId, pairId]); // ⚠️ Remplace 'db' par le nom de ta variable de connexion (souvent 'pool' ou 'db') + const [rows] = await pool.query(checkSql, [userId, pairId]); // ⚠️ Remplace 'db' par le nom de ta variable de connexion (souvent 'pool' ou 'db') if (rows.length > 0) { // MISE À JOUR : La stratégie existe, on l'écrase avec le nouveau mode @@ -50,7 +50,7 @@ class StrategyRepo { SET mode = ?, params = ?, strategy_key = ?, is_active = 1, updated_at_ms = ? WHERE user_id = ? AND pair_id = ? `; - await db.query(updateSql, [mode, params, strategyKey, now, userId, pairId]); + await pool.query(updateSql, [mode, params, strategyKey, now, userId, pairId]); return { action: 'updated', user_id: userId, pair_id: pairId, mode }; } else { // CRÉATION : C'est la première fois qu'il configure cette paire @@ -59,7 +59,7 @@ class StrategyRepo { (user_strategy_id, user_id, pair_id, strategy_key, mode, params, is_active, created_at_ms, updated_at_ms) VALUES (UUID(), ?, ?, ?, ?, ?, 1, ?, ?) `; - await db.query(insertSql, [userId, pairId, strategyKey, mode, params, now, now]); + await pool.query(insertSql, [userId, pairId, strategyKey, mode, params, now, now]); return { action: 'created', user_id: userId, pair_id: pairId, mode }; } } -- 2.50.1