Github user nickwallen commented on a diff in the pull request:
https://github.com/apache/metron/pull/768#discussion_r143565157
--- Diff:
metron-interface/metron-alerts/src/app/alerts/alerts-list/tree-view/tree-view.component.ts
---
@@ -0,0 +1,319 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
+import {Router} from '@angular/router';
+import {Subscription} from 'rxjs/Rx';
+
+import {TableViewComponent} from '../table-view/table-view.component';
+import {SearchResponse} from '../../../model/search-response';
+import {SearchService} from '../../../service/search.service';
+import {TreeGroupData, TreeAlertsSubscription} from './tree-group-data';
+import {GroupResponse} from '../../../model/group-response';
+import {GroupResult} from '../../../model/group-result';
+import {Group} from '../../../model/group';
+import {SortField} from '../../../model/sort-field';
+import {Sort} from '../../../utils/enums';
+import {MetronDialogBox, DialogType} from
'../../../shared/metron-dialog-box';
+import {ElasticsearchUtils} from '../../../utils/elasticsearch-utils';
+import {SearchRequest} from '../../../model/search-request';
+
+@Component({
+ selector: 'app-tree-view',
+ templateUrl: './tree-view.component.html',
+ styleUrls: ['./tree-view.component.scss']
+})
+
+export class TreeViewComponent extends TableViewComponent implements
OnChanges {
+
+ groupByFields: string[] = [];
+ topGroups: TreeGroupData[] = [];
+ groupResponse: GroupResponse = new GroupResponse();
+ treeGroupSubscriptionMap: {[key: string]: TreeAlertsSubscription } = {};
+
+ constructor(router: Router,
+ searchService: SearchService,
+ metronDialogBox: MetronDialogBox) {
+ super(router, searchService, metronDialogBox);
+ }
+
+ collapseGroup(groupArray: TreeGroupData[], level: number, index: number)
{
+ for (let i = index + 1; i < groupArray.length; i++) {
+ if (groupArray[i].level > (level)) {
+ groupArray[i].show = false;
+ groupArray[i].expand = false;
+ } else {
+ break;
+ }
+ }
+ }
+
+ createQuery(selectedGroup: TreeGroupData) {
+ let searchQuery = this.queryBuilder.generateSelect();
+ let groupQery = Object.keys(selectedGroup.groupQueryMap).map(key => {
+ return key.replace(/:/g, '\\:') +
+ ':' +
+ String(selectedGroup.groupQueryMap[key])
+ .replace(/[\*\+\-=~><\"\?^\${}\(\)\:\!\/[\]\\\s]/g, '\\$&') //
replace single special characters
+ .replace(/\|\|/g, '\\||') // replace ||
+ .replace(/\&\&/g, '\\&&'); // replace &&
+ }).join(' AND ');
+
+ groupQery += searchQuery === '*' ? '' : (' AND ' + searchQuery);
+ return groupQery;
+ }
+
+ expandGroup(groupArray: TreeGroupData[], level: number, index: number) {
+ for (let i = index + 1; i < groupArray.length; i++) {
+ if (groupArray[i].level === (level + 1)) {
+ groupArray[i].show = true;
+ } else {
+ break;
+ }
+ }
+ }
+
+ getAlerts(selectedGroup: TreeGroupData): Subscription {
+ let searchRequest = new SearchRequest();
+ searchRequest.query = this.createQuery(selectedGroup);
+ searchRequest.from = selectedGroup.pagingData.from;
+ searchRequest.size = selectedGroup.pagingData.size;
+ searchRequest.sort = selectedGroup.sortField ?
[selectedGroup.sortField] : [];
+
+ return this.searchGroup(selectedGroup, searchRequest);
--- End diff --
@iraghumitra I noticed that when grouping there are cases when the two
locations where we display total counts will differ. See the attached
screenshots. I underlined in yellow the counts that I am talking about.


It seems that the data used to build the total count in the group header is
stale in comparison with the data used to display the individual alerts. We
initially call `/group` to display the group header. When a user expands the
group we issue a `/search`, which retrieves fresher data. Data that likely has
a different total from what is currently displayed in the group header.
Can we update the count in the group header somewhere? Maybe around here?
---