MCPcopy Index your code
hub / github.com/FloatTech/ZeroBot-Plugin / InsertOrUpdateSignInCountByUID

Method InsertOrUpdateSignInCountByUID

plugin/score/model.go:112–132  ·  view source on GitHub ↗

InsertOrUpdateSignInCountByUID 插入或更新签到次数

(uid int64, count int)

Source from the content-addressed store, hash-verified

110
111// InsertOrUpdateSignInCountByUID 插入或更新签到次数
112func (sdb *scoredb) InsertOrUpdateSignInCountByUID(uid int64, count int) (err error) {
113 sdb.scoremu.Lock()
114 defer sdb.scoremu.Unlock()
115 db := sdb.db
116 si := signintable{
117 UID: uid,
118 Count: count,
119 }
120 if err = db.Model(&signintable{}).First(&si, "uid = ? ", uid).Error; err != nil {
121 // error handling...
122 if gorm.IsRecordNotFoundError(err) {
123 err = db.Model(&signintable{}).Create(&si).Error // newUser not user
124 }
125 } else {
126 err = db.Model(&signintable{}).Where("uid = ? ", uid).Update(
127 map[string]any{
128 "count": count,
129 }).Error
130 }
131 return
132}
133
134func (sdb *scoredb) GetScoreRankByTopN(n int) (st []scoretable, err error) {
135 sdb.scoremu.Lock()

Callers 1

initFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected