-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add alertId parameter in get chained alert API and paginate associated alerts if alertId param is set. #1070
Conversation
…d alerts if alertId param is mentioned Signed-off-by: Surya Sashank Nistala <[email protected]>
Codecov Report
@@ Coverage Diff @@
## 2.9 #1070 +/- ##
============================================
- Coverage 72.75% 68.00% -4.76%
Complexity 119 119
============================================
Files 160 160
Lines 10447 10467 +20
Branches 1572 1576 +4
============================================
- Hits 7601 7118 -483
- Misses 1952 2647 +695
+ Partials 894 702 -192
|
val getAssociatedAlerts: Boolean = request.param("getAssociatedAlerts", "false").toBoolean() | ||
val workflowIds = mutableListOf<String>() | ||
if (workflowId.isNullOrEmpty() == false) { | ||
workflowIds.add(workflowId) | ||
} | ||
val alertIds = mutableListOf<String>() | ||
if (alertId.isNullOrEmpty() == false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: use isNotEmpty()
or isNotBlank()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alertId is of type String?
isNotEmpty() and isNotBlank() can be used only if it is not nullable. so the isNullOrEmpty() check takes care of it. There isn't a negated implementation of isNullOrEmpty
try { | ||
val associatedAlertIds = mutableSetOf<String>() | ||
alerts.forEach { associatedAlertIds.addAll(it.associatedAlertIds) } | ||
if (associatedAlertIds.isEmpty()) return | ||
val queryBuilder = QueryBuilders.boolQuery() | ||
val searchRequest = SearchRequest(alertIndex) | ||
// if chained alert id param is non-null, paginate the associated alerts. | ||
if (getWorkflowAlertsRequest.alertIds.isNullOrEmpty() == false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: use isNotEmpty()
or isNotBlank()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a list
if (!tableProp.missing.isNullOrBlank()) { | ||
sortBuilder.missing(tableProp.missing) | ||
} | ||
searchRequest.source().sort(sortBuilder).size(tableProp.size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We dont take the from
value. How are we paginating associated alerts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make the PR first to main
Signed-off-by: Surya Sashank Nistala <[email protected]>
Closing this PR Will backport #1071 to 2.9 |
Get chained alert API will support filtering based on an alertId. The motivation is to fetch associated alerts with support for pagination. The size and sort params would apply to fetch associated alerts in this api when alert id is mentioned