mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-06-09 16:07:36 +08:00
fix: add summary statistics switch (#21987)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -684,11 +684,19 @@ func ListItems(manager IModelManager, ctx context.Context, userCred mcclient.Tok
|
||||
var totalCnt int
|
||||
var totalJson jsonutils.JSONObject
|
||||
if pagingConf == nil {
|
||||
// calculate total
|
||||
totalQ := q.CountQuery()
|
||||
totalCnt, totalJson, err = manager.CustomizedTotalCount(ctx, userCred, query, totalQ)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "CustomizedTotalCount")
|
||||
summaryStats := jsonutils.QueryBoolean(query, "summary_stats", false)
|
||||
if summaryStats {
|
||||
// calculate total
|
||||
totalQ := q.CountQuery()
|
||||
totalCnt, totalJson, err = manager.CustomizedTotalCount(ctx, userCred, query, totalQ)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "CustomizedTotalCount")
|
||||
}
|
||||
} else {
|
||||
totalCnt, err = q.CountWithError()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "CountWithError")
|
||||
}
|
||||
}
|
||||
//log.Debugf("total count %d", totalCnt)
|
||||
if totalCnt == 0 {
|
||||
|
||||
@@ -884,7 +884,7 @@ func (manager *SGuestManager) initAdminSecgroupId() error {
|
||||
adminSecId := adminSec.Id
|
||||
guests := make([]SGuest, 0, 10)
|
||||
q := manager.Query()
|
||||
q = q.In("hypervisor", []string{api.HYPERVISOR_KVM}).IsNullOrEmpty("admin_secgrp_id")
|
||||
q = q.In("hypervisor", []string{api.HYPERVISOR_KVM, api.HYPERVISOR_POD}).IsNullOrEmpty("admin_secgrp_id")
|
||||
err := db.FetchModelObjects(manager, q, &guests)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "db.FetchModelObjects")
|
||||
|
||||
Reference in New Issue
Block a user