MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / updateUserUsedQuotaAndRequestCount

Function updateUserUsedQuotaAndRequestCount

model/user.go:745–761  ·  view source on GitHub ↗
(id int, quota int, count int)

Source from the content-addressed store, hash-verified

743}
744
745func updateUserUsedQuotaAndRequestCount(id int, quota int, count int) {
746 err := DB.Model(&User{}).Where("id = ?", id).Updates(
747 map[string]interface{}{
748 "used_quota": gorm.Expr("used_quota + ?", quota),
749 "request_count": gorm.Expr("request_count + ?", count),
750 },
751 ).Error
752 if err != nil {
753 common.SysError("failed to update user used quota and request count: " + err.Error())
754 return
755 }
756
757 //// 更新缓存
758 //if err := invalidateUserCache(id); err != nil {
759 // common.SysError("failed to invalidate user cache: " + err.Error())
760 //}
761}
762
763func updateUserUsedQuota(id int, quota int) {
764 err := DB.Model(&User{}).Where("id = ?", id).Updates(

Callers 1

Calls 2

SysErrorFunction · 0.92
ErrorMethod · 0.80

Tested by

no test coverage detected