From 01568f0aed8a8f6e24016d9fa706bfb8a2bf3945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=8F=B6?= <1936472877@qq.com> Date: Fri, 13 Dec 2024 19:06:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=BB=98=E8=AE=A41=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/db/stats.js | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/models/db/stats.js b/models/db/stats.js index e522f44..cb9683b 100644 --- a/models/db/stats.js +++ b/models/db/stats.js @@ -156,19 +156,23 @@ export async function StatsTableUpdate (userId, groupId, botId, steamId, appid, }) if (UserUpdateRows === 0) { - await UserStatsTable.create({ + const data = { userId, groupId, botId, steamId, - ...{ - playTotal: 1, - playTime: 0, - onlineTotal: 1, - onlineTime: 0, - [field]: value - } - }, { transaction }) + playTotal: 0, + playTime: 0, + onlineTotal: 0, + onlineTime: 0, + [field]: value + } + if (field === 'onlineTime') { + data.onlineTotal = 1 + } else if (field === 'playTime') { + data.playTotal = 1 + } + await UserStatsTable.create(data, { transaction }) } if (['playTotal', 'playTime'].includes(field)) { @@ -187,19 +191,21 @@ export async function StatsTableUpdate (userId, groupId, botId, steamId, appid, }) if (GameUpdateRows === 0) { - await GameStatsTable.create({ + const data = { userId, groupId, botId, steamId, appid, name, - ...{ - playTotal: 1, - playTime: 0, - [field]: value - } - }, { transaction }) + playTotal: 0, + playTime: 0, + [field]: value + } + if (field === 'playTime') { + data.playTotal = 1 + } + await GameStatsTable.create(data, { transaction }) } }