diff --git a/controller/billing.go b/controller/billing.go index 5f9de534..7fc1bf3d 100644 --- a/controller/billing.go +++ b/controller/billing.go @@ -8,7 +8,8 @@ import ( ) func GetSubscription(c *gin.Context) { - var quota int + var remainQuota int + var usedQuota int var err error var expirationDate int64 @@ -18,10 +19,14 @@ func GetSubscription(c *gin.Context) { expirationDate = token.ExpiredTime if common.DisplayTokenStatEnabled { - quota = token.RemainQuota + tokenId := c.GetInt("token_id") + token, err = model.GetTokenById(tokenId) + remainQuota = token.RemainQuota + usedQuota = token.UsedQuota } else { userId := c.GetInt("id") - quota, err = model.GetUserQuota(userId) + remainQuota, err = model.GetUserQuota(userId) + usedQuota, err = model.GetUserUsedQuota(userId) } if err != nil { openAIError := OpenAIError{ @@ -33,6 +38,7 @@ func GetSubscription(c *gin.Context) { }) return } + quota := remainQuota + usedQuota amount := float64(quota) if common.DisplayInCurrencyEnabled { amount /= common.QuotaPerUnit diff --git a/web/src/pages/Channel/EditChannel.jsx b/web/src/pages/Channel/EditChannel.jsx index 57df51ff..fba1c0d5 100644 --- a/web/src/pages/Channel/EditChannel.jsx +++ b/web/src/pages/Channel/EditChannel.jsx @@ -59,19 +59,19 @@ const EditChannel = () => { data.models = []; } else { data.models = data.models.split(','); - // setTimeout(() => { - // let localModelOptions = [...modelOptions]; - // data.models.forEach((model) => { - // if (!localModelOptions.find((option) => option.key === model)) { - // localModelOptions.push({ - // key: model, - // text: model, - // value: model, - // }); - // } - // }); - // setModelOptions(localModelOptions); - // }, 1000); + setTimeout(() => { + let localModelOptions = [...data.models]; + data.models.forEach((model) => { + if (!localModelOptions.find((option) => option.key === model)) { + localModelOptions.push({ + key: model, + text: model, + value: model + }); + } + }); + setModelOptions(localModelOptions); + }, 1000); } if (data.group === '') { data.groups = [];