Skip to content

Commit

Permalink
Update helper method to be more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
DerAndereAndi committed Apr 18, 2024
1 parent 09d78db commit 689039c
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions features/loadcontrol.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ func (l *LoadControl) GetLimitDescriptionsForCategory(category model.LoadControl

// returns the load control limit descriptions of a provided type, direction and scope
// returns an error if no description data for the category is available
//
// providing an empty string for any of the params, will ignore the value in the request
func (l *LoadControl) GetLimitDescriptionsForTypeCategoryDirectionScope(
limitType model.LoadControlLimitTypeType,
limitCategory model.LoadControlCategoryType,
Expand All @@ -97,14 +99,10 @@ func (l *LoadControl) GetLimitDescriptionsForTypeCategoryDirectionScope(

for _, item := range data {
if item.LimitId != nil &&
item.LimitType != nil &&
*item.LimitType == limitType &&
item.LimitCategory != nil &&
*item.LimitCategory == limitCategory &&
item.LimitDirection != nil &&
*item.LimitDirection == limitDirection &&
item.ScopeType != nil &&
*item.ScopeType == scope {
(limitType == "" || (item.LimitType != nil && *item.LimitType == limitType)) &&
(limitCategory == "" || (item.LimitCategory != nil && *item.LimitCategory == limitCategory)) &&
(limitDirection == "" || (item.LimitDirection != nil && *item.LimitDirection == limitDirection)) &&
(scope == "" || (item.ScopeType != nil && *item.ScopeType == scope)) {
result = append(result, item)
}
}
Expand Down

0 comments on commit 689039c

Please sign in to comment.