Skip to content

Commit

Permalink
fix: 在多个群开启统计时只会统计一个群
Browse files Browse the repository at this point in the history
  • Loading branch information
XasYer committed Dec 14, 2024
1 parent 01568f0 commit bd8ad0c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions models/db/stats.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { logger } from '#lib'
import { sequelize, DataTypes, fn, col } from './base.js'

/**
Expand Down Expand Up @@ -88,8 +89,7 @@ const UserStatsTable = sequelize.define('userStats', {
},
steamId: {
type: DataTypes.STRING,
allowNull: false,
unique: true
allowNull: false
},
playTotal: {
type: DataTypes.INTEGER,
Expand Down Expand Up @@ -118,6 +118,22 @@ const UserStatsTable = sequelize.define('userStats', {
await UserStatsTable.sync()
await GameStatsTable.sync()

// 移除userStats表的列steamId的unique属性 忘记多群了
// 七天后移除 2024年12月14日09:29:42
try {
const queryInterface = sequelize.getQueryInterface()
const UserStatsTableDescription = await queryInterface.describeTable('userStats')
if (UserStatsTableDescription.steamId.unique) {
await queryInterface.changeColumn('userStats', 'steamId', {
type: DataTypes.STRING,
allowNull: false,
unique: false
})
}
} catch (error) {
logger.error('更新userStats表的列steamId的unique属性失败, 可能会导致不能多群统计', error)
}

/**
* 更新游玩统计
* @param {string} userId
Expand Down

0 comments on commit bd8ad0c

Please sign in to comment.