瀏覽代碼

fix: lint

zijiren233 9 月之前
父節點
當前提交
a2d5a9a435
共有 4 個文件被更改,包括 10 次插入22 次删除
  1. 1 1
      .github/workflows/check-semgrep.yml
  2. 0 15
      .github/workflows/ci.yml
  3. 8 6
      model/log.go
  4. 1 0
      model/modelconfig.go

+ 1 - 1
.github/workflows/check-semgrep.yml

@@ -21,7 +21,7 @@ jobs:
     name: Scan
     runs-on: ubuntu-24.04
     container:
-      image: semgrep/semgrep:1.109.0
+      image: semgrep/semgrep:latest
     continue-on-error: true
     if: (github.actor != 'dependabot[bot]')
     steps:

+ 0 - 15
.github/workflows/ci.yml

@@ -11,28 +11,13 @@ on:
   push:
     branches: [ "main" ]
     paths-ignore:
-      - "docs/**"
       - "**/*.md"
       - "**/*.yaml"
-      - "CONTRIBUTORS"
-      - "CHANGELOG/**"
-      - "controllers/**"
-      - "service/**"
-      - "webhooks/**"
-      - "frontend/**"
   pull_request:
     branches: [ "*" ]
     paths-ignore:
-      - "docs/**"
-      - "CHANGELOG/**"
       - "**/*.md"
       - "**/*.yaml"
-      - "CONTRIBUTORS"
-      - "CHANGELOG/**"
-      - "controllers/**"
-      - "service/**"
-      - "webhooks/**"
-      - "frontend/**"
 
 jobs:
   golangci-lint:

+ 8 - 6
model/log.go

@@ -349,11 +349,12 @@ func buildGetLogsQuery(
 	if group != "" {
 		tx = tx.Where("group_id = ?", group)
 	}
-	if !startTimestamp.IsZero() && !endTimestamp.IsZero() {
+	switch {
+	case !startTimestamp.IsZero() && !endTimestamp.IsZero():
 		tx = tx.Where("request_at BETWEEN ? AND ?", startTimestamp, endTimestamp)
-	} else if !startTimestamp.IsZero() {
+	case !startTimestamp.IsZero():
 		tx = tx.Where("request_at >= ?", startTimestamp)
-	} else if !endTimestamp.IsZero() {
+	case !endTimestamp.IsZero():
 		tx = tx.Where("request_at <= ?", endTimestamp)
 	}
 	if tokenName != "" {
@@ -601,11 +602,12 @@ func buildSearchLogsQuery(
 		tx = tx.Where("model = ?", modelName)
 	}
 
-	if !startTimestamp.IsZero() && !endTimestamp.IsZero() {
+	switch {
+	case !startTimestamp.IsZero() && !endTimestamp.IsZero():
 		tx = tx.Where("request_at BETWEEN ? AND ?", startTimestamp, endTimestamp)
-	} else if !startTimestamp.IsZero() {
+	case !startTimestamp.IsZero():
 		tx = tx.Where("request_at >= ?", startTimestamp)
-	} else if !endTimestamp.IsZero() {
+	case !endTimestamp.IsZero():
 		tx = tx.Where("request_at <= ?", endTimestamp)
 	}
 

+ 1 - 0
model/modelconfig.go

@@ -16,6 +16,7 @@ const (
 	PriceUnit = 1000
 )
 
+//nolint:revive
 type ModelConfig struct {
 	CreatedAt         time.Time              `gorm:"index;autoCreateTime"          json:"created_at"`
 	UpdatedAt         time.Time              `gorm:"index;autoUpdateTime"          json:"updated_at"`