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

Function decreaseTokenQuota

model/token.go:338–347  ·  view source on GitHub ↗
(id int, quota int)

Source from the content-addressed store, hash-verified

336}
337
338func decreaseTokenQuota(id int, quota int) (err error) {
339 err = DB.Model(&Token{}).Where("id = ?", id).Updates(
340 map[string]interface{}{
341 "remain_quota": gorm.Expr("remain_quota - ?", quota),
342 "used_quota": gorm.Expr("used_quota + ?", quota),
343 "accessed_time": common.GetTimestamp(),
344 },
345 ).Error
346 return err
347}
348
349// CountUserTokens returns total number of tokens for the given user, used for pagination
350func CountUserTokens(userId int) (int64, error) {

Callers 1

DecreaseTokenQuotaFunction · 0.85

Calls 1

GetTimestampFunction · 0.92

Tested by

no test coverage detected