Skip to content

Commit

Permalink
fix: 默认1次
Browse files Browse the repository at this point in the history
  • Loading branch information
XasYer committed Dec 13, 2024
1 parent cfaf66f commit 01568f0
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions models/db/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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 })
}
}

Expand Down

0 comments on commit 01568f0

Please sign in to comment.