MCPcopy Create free account
hub / github.com/QuantumNous/new-api / decreaseTokenQuota

Function decreaseTokenQuota

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

Source from the content-addressed store, hash-verified

429}
430
431func decreaseTokenQuota(id int, quota int) (err error) {
432 err = DB.Model(&Token{}).Where("id = ?", id).Updates(
433 map[string]interface{}{
434 "remain_quota": gorm.Expr("remain_quota - ?", quota),
435 "used_quota": gorm.Expr("used_quota + ?", quota),
436 "accessed_time": common.GetTimestamp(),
437 },
438 ).Error
439 return err
440}
441
442// CountUserTokens returns total number of tokens for the given user, used for pagination
443func CountUserTokens(userId int) (int64, error) {

Callers 1

DecreaseTokenQuotaFunction · 0.85

Calls 1

GetTimestampFunction · 0.92

Tested by

no test coverage detected