From e11f77dca4263d0257f5b4653d217b5b3d030089 Mon Sep 17 00:00:00 2001 From: Dung Nguyen <> Date: Thu, 3 Mar 2022 23:41:11 +0700 Subject: [PATCH] =?UTF-8?q?Th=C3=AAm=20th=E1=BB=91ng=20k=C3=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/index.js b/index.js index e06e342..20cfab9 100644 --- a/index.js +++ b/index.js @@ -37,6 +37,8 @@ let lastResult = null; let currentSessionID = null; let d = null; // Ví tiền user let dInWeb = null; // Ví tiền theo web +let currentColorCandle = -1; // Nến hiện tại +let totalColorCandle = 0; /** * Tất cả config ở đây @@ -388,6 +390,21 @@ function roleEnterOrder(sessionID, lastResult) { } CONFIG.historys.push({ sessionID, lastResult }); + // Thêm dữ liệu vào thống kê + if (currentColorCandle === -1) { + currentColorCandle = lastResult; + totalColorCandle += 1; + } else { + if (currentColorCandle === lastResult) { + // Nếu phiên tiếp theo trùng màu với phiên trước đó thì tăng số lượng nến trùng lên + totalColorCandle += 1; + } else { + db.query(`INSERT INTO analytics (trend, date, count) VALUES(${currentColorCandle}, '${new Date().toLocaleString('vi-VN')}', ${totalColorCandle})`); + totalColorCandle = 1; + currentColorCandle = lastResult; + } + } + /** * PHIÊN ĐÃ VÀO LỆNH SẼ CHECK * sessionID - 1 = enterOrder.sessionID