mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
Merge pull request #12473 from tb365/automated-cherry-pick-of-#12471-upstream-release-3.7
Automated cherry pick of #12471: host count add filters
This commit is contained in:
@@ -184,7 +184,7 @@ func applyListItemsSearchFilters(manager IModelManager, ctx context.Context, q *
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func applyListItemsGeneralFilters(manager IModelManager, q *sqlchemy.SQuery,
|
||||
func ApplyListItemsGeneralFilters(manager IModelManager, q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential, filters []string, filterAny bool) (*sqlchemy.SQuery, error) {
|
||||
conds := make([]sqlchemy.ICondition, 0)
|
||||
schFields := searchFields(manager, userCred) // only filter searchable fields
|
||||
@@ -298,7 +298,7 @@ func listItemQueryFiltersRaw(manager IModelManager,
|
||||
filterAny, _ := query.Bool("filter_any")
|
||||
filters := jsonutils.GetQueryStringArray(query, "filter")
|
||||
if len(filters) > 0 {
|
||||
q, err = applyListItemsGeneralFilters(manager, q, userCred, filters, filterAny)
|
||||
q, err = ApplyListItemsGeneralFilters(manager, q, userCred, filters, filterAny)
|
||||
}
|
||||
jointFilter := jsonutils.GetQueryStringArray(query, "joint_filter")
|
||||
if len(jointFilter) > 0 {
|
||||
|
||||
@@ -1029,7 +1029,16 @@ func (self *SHostManager) GetPropertyNodeCount(ctx context.Context, userCred mcc
|
||||
}
|
||||
|
||||
func (self *SHostManager) getCount(ctx context.Context, userCred mcclient.TokenCredential, q *sqlchemy.SQuery, query api.HostListInput) (jsonutils.JSONObject, error) {
|
||||
q, err := self.ListItemFilter(ctx, q, userCred, query)
|
||||
filterAny := false
|
||||
if query.FilterAny != nil {
|
||||
filterAny = *query.FilterAny
|
||||
}
|
||||
q, err := db.ApplyListItemsGeneralFilters(self, q, userCred, query.Filter, filterAny)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
q, err = self.ListItemFilter(ctx, q, userCred, query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user