|
|
@@ -12,6 +12,13 @@ const ( |
|
|
|
SpecOffShelf |
|
|
|
) |
|
|
|
|
|
|
|
type SearchSpecOrderBy int |
|
|
|
|
|
|
|
const ( |
|
|
|
SearchSpecOrderById SearchSpecOrderBy = iota |
|
|
|
SearchSpecOrder4Standard |
|
|
|
) |
|
|
|
|
|
|
|
type ResourceSpecification struct { |
|
|
|
ID int64 `xorm:"pk autoincr"` |
|
|
|
QueueId int64 `xorm:"INDEX"` |
|
|
@@ -85,6 +92,7 @@ type SearchResourceSpecificationOptions struct { |
|
|
|
Status int |
|
|
|
Cluster string |
|
|
|
AvailableCode int |
|
|
|
OrderBy SearchSpecOrderBy |
|
|
|
} |
|
|
|
|
|
|
|
type SearchResourceBriefSpecificationOptions struct { |
|
|
@@ -233,10 +241,18 @@ func SearchResourceSpecification(opts SearchResourceSpecificationOptions) (int64 |
|
|
|
return 0, nil, err |
|
|
|
} |
|
|
|
|
|
|
|
var orderby = "" |
|
|
|
switch opts.OrderBy { |
|
|
|
case SearchSpecOrder4Standard: |
|
|
|
orderby = "resource_queue.compute_resource asc,resource_queue.acc_card_type asc,resource_specification.acc_cards_num asc,resource_specification.cpu_cores asc,resource_specification.mem_gi_b asc,resource_specification.share_mem_gi_b asc" |
|
|
|
default: |
|
|
|
orderby = "resource_specification.id desc" |
|
|
|
} |
|
|
|
|
|
|
|
r := make([]ResourceSpecAndQueue, 0) |
|
|
|
err = x.Where(cond). |
|
|
|
Join("INNER", "resource_queue", "resource_queue.ID = resource_specification.queue_id"). |
|
|
|
Desc("resource_specification.id"). |
|
|
|
OrderBy(orderby). |
|
|
|
Limit(opts.PageSize, (opts.Page-1)*opts.PageSize). |
|
|
|
Unscoped().Find(&r) |
|
|
|
if err != nil { |
|
|
|