Browse Source

#2624

fix bug
tags/v1.22.8.2^2
chenyifan01 3 years ago
parent
commit
5ee78082f4
1 changed files with 8 additions and 2 deletions
  1. +8
    -2
      models/resource_queue.go

+ 8
- 2
models/resource_queue.go View File

@@ -97,6 +97,10 @@ type ResourceQueueCodesRes struct {
AiCenterName string
}

func (ResourceQueueCodesRes) TableName() string {
return "resource_queue"
}

type ResourceAiCenterRes struct {
AiCenterCode string
AiCenterName string
@@ -173,8 +177,9 @@ func GetResourceQueueCodes(opts GetQueueCodesOptions) ([]*ResourceQueueCodesRes,
if opts.Cluster != "" {
cond = cond.And(builder.Eq{"cluster": opts.Cluster})
}
cond = cond.And(builder.Or(builder.IsNull{"deleted_time"}, builder.Eq{"deleted_time": 0}))
r := make([]*ResourceQueueCodesRes, 0)
err := x.Table("resource_queue").Where(cond).OrderBy("id desc").Find(&r)
err := x.Where(cond).OrderBy("cluster desc,ai_center_code asc").Find(&r)
if err != nil {
return nil, err
}
@@ -335,7 +340,8 @@ func SyncGrampusQueues(updateList []ResourceQueue, insertList []ResourceQueue, e

func GetResourceAiCenters() ([]ResourceAiCenterRes, error) {
r := make([]ResourceAiCenterRes, 0)
err := x.Table("resource_queue").Distinct("ai_center_code", "ai_center_name").Find(&r)

err := x.SQL("SELECT t.ai_center_code, t.ai_center_name FROM (SELECT DISTINCT ai_center_code, ai_center_name,cluster FROM resource_queue WHERE (deleted_time IS NULL OR deleted_time=0)) t ORDER BY cluster desc,ai_center_code asc").Find(&r)
if err != nil {
return nil, err
}


Loading…
Cancel
Save