feat: able to query token with admin user

This commit is contained in:
JustSong
2023-06-24 19:13:33 +08:00
parent a515f9284e
commit 3ce982d8ee
4 changed files with 52 additions and 28 deletions

View File

@@ -66,7 +66,7 @@ func RecordConsumeLog(userId int, promptTokens int, completionTokens int, modelN
}
}
func GetAllLogs(logType int, startTimestamp int64, endTimestamp int64, modelName string, username string, startIdx int, num int) (logs []*Log, err error) {
func GetAllLogs(logType int, startTimestamp int64, endTimestamp int64, modelName string, username string, tokenName string, startIdx int, num int) (logs []*Log, err error) {
var tx *gorm.DB
if logType == LogTypeUnknown {
tx = DB
@@ -79,6 +79,9 @@ func GetAllLogs(logType int, startTimestamp int64, endTimestamp int64, modelName
if username != "" {
tx = tx.Where("username = ?", username)
}
if tokenName != "" {
tx = tx.Where("token_name = ?", tokenName)
}
if startTimestamp != 0 {
tx = tx.Where("created_at >= ?", startTimestamp)
}