ruffle1986 commented on a change in pull request #1344: METRON-1654: findOne
request after an alert patch returns with the original state of the alert item
URL: https://github.com/apache/metron/pull/1344#discussion_r262968061
##########
File path:
metron-interface/metron-alerts/src/app/alerts/alerts-list/tree-view/tree-view.component.ts
##########
@@ -436,16 +437,13 @@ export class TreeViewComponent extends
TableViewComponent implements OnInit, OnC
return false;
}
- updateAlert(patchRequest: PatchRequest) {
- this.searchService.getAlert(patchRequest.sensorType,
patchRequest.guid).subscribe(alertSource => {
-
- Object.keys(this.treeGroupSubscriptionMap).forEach(key => {
- let group = this.treeGroupSubscriptionMap[key].group;
- if (group.response && group.response.results &&
group.response.results.length > 0) {
- group.response.results.filter(alert => alert.source.guid ===
patchRequest.guid)
- .map(alert => alert.source = alertSource);
- }
- });
+ updateAlert(alertSource: AlertSource) {
+ Object.keys(this.treeGroupSubscriptionMap).forEach(key => {
+ let group = this.treeGroupSubscriptionMap[key].group;
+ if (group.response && group.response.results &&
group.response.results.length > 0) {
+ group.response.results.filter(alert => alert.source.guid ===
alertSource.guid)
+ .map(alert => alert.source = alertSource);
Review comment:
When I see `map` in the code, I'm assuming a new array being created based
on a mapping function. A mapping function shouldn't mutate the items in the
original array. In this case, I'd rather use `forEach`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services