From 8383bce459c206d57a198e11973359dc2aacfe05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98Liu?= <‘liuchunk08@gmail.com’> Date: Wed, 10 Jan 2024 14:37:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=90=9C=E7=B4=A2=E6=97=A5?= =?UTF-8?q?=E5=BF=97num=E4=B8=8D=E8=B5=B7=E4=BD=9C=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/log.go | 9 +++++++-- model/log.go | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/controller/log.go b/controller/log.go index 40626227..3265ce20 100644 --- a/controller/log.go +++ b/controller/log.go @@ -1,11 +1,12 @@ package controller import ( - "github.com/gin-gonic/gin" "net/http" "one-api/common" "one-api/model" "strconv" + + "github.com/gin-gonic/gin" ) func GetAllLogs(c *gin.Context) { @@ -38,10 +39,14 @@ func GetAllLogs(c *gin.Context) { func GetLogsByKey(c *gin.Context) { startidx, _ := strconv.Atoi(c.Query("startIdx")) num, _ := strconv.Atoi(c.Query("num")) - if startidx <= 0 || num <= 0 { + + if startidx <= 0 { startidx = 0 + } + if num <= 0 { num = 10 } + logType, _ := strconv.Atoi(c.Query("type")) startTimestamp, _ := strconv.ParseInt(c.Query("start_timestamp"), 10, 64) endTimestamp, _ := strconv.ParseInt(c.Query("end_timestamp"), 10, 64) diff --git a/model/log.go b/model/log.go index 6882431f..fce5661f 100644 --- a/model/log.go +++ b/model/log.go @@ -73,6 +73,7 @@ func RecordConsumeLog(ctx context.Context, userId int, channelId int, promptToke } func GetLogsByKey(logType int, startTimestamp int64, endTimestamp int64, key string, startIdx int, num int) (logs []*Log, err error) { var tx *gorm.DB + fmt.Println(num) token, err := GetNameByToken(key) if logType == LogTypeUnknown { tx = DB.Debug()