You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2023/04/11 13:19:09 UTC

[streampipes] branch dev updated: [hotfix] Fix handling of count queries in data explorer (#1501)

This is an automated email from the ASF dual-hosted git repository.

riemer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new 9694615e5 [hotfix] Fix handling of count queries in data explorer (#1501)
9694615e5 is described below

commit 9694615e5776d228d98cc814d7ec74f2ab5b0d87
Author: Dominik Riemer <do...@gmail.com>
AuthorDate: Tue Apr 11 15:19:00 2023 +0200

    [hotfix] Fix handling of count queries in data explorer (#1501)
    
    * [hotfix] Fix handling of count queries in data explorer
    
    * [hotfix] Use HttpContext to hide loading bar in API calls
---
 .../dataexplorer/param/model/SelectColumn.java     | 24 ++++++++++++++++++++--
 .../query/DataExplorerQueryExecutor.java           |  3 ++-
 ui/src/app/connect/services/rest.service.ts        |  5 +++--
 .../widgets/table/table-widget.component.html      |  2 +-
 ui/src/app/editor/services/editor.service.ts       |  5 +++--
 ui/src/app/login/services/login.service.ts         |  5 +++--
 .../notifications/service/notifications.service.ts |  5 +++--
 ui/src/app/services/rest-api.service.ts            |  7 ++++---
 8 files changed, 41 insertions(+), 15 deletions(-)

diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/param/model/SelectColumn.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/param/model/SelectColumn.java
index fe7be2da4..1fb7661e9 100644
--- a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/param/model/SelectColumn.java
+++ b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/param/model/SelectColumn.java
@@ -67,15 +67,35 @@ public class SelectColumn implements IQueryStatement {
 
   public static SelectColumn fromApiQueryString(String queryString,
                                                 String globalAggregationFunction) {
+    SelectColumn column = SelectColumn.fromApiQueryString(queryString);
     AggregationFunction aggregationFunction = AggregationFunction.valueOf(globalAggregationFunction);
-    String targetField = aggregationFunction.name().toLowerCase() + "_" + queryString;
-    return new SelectColumn(queryString, AggregationFunction.valueOf(globalAggregationFunction), targetField);
+    column.setAggregationFunction(aggregationFunction);
+    column.setTargetField(aggregationFunction.name().toLowerCase() + "_" + column.getOriginalField());
+    column.setRename(true);
+    column.setSimpleField(false);
+    return column;
   }
 
   public String getOriginalField() {
     return originalField;
   }
 
+  public void setAggregationFunction(AggregationFunction aggregationFunction) {
+    this.aggregationFunction = aggregationFunction;
+  }
+
+  public void setTargetField(String targetField) {
+    this.targetField = targetField;
+  }
+
+  public void setSimpleField(boolean simpleField) {
+    this.simpleField = simpleField;
+  }
+
+  public void setRename(boolean rename) {
+    this.rename = rename;
+  }
+
   @Override
   public void buildStatement(IDataLakeQueryBuilder<?> builder) {
     if (this.simpleField) {
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/DataExplorerQueryExecutor.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/DataExplorerQueryExecutor.java
index 29d7de50f..f0aecf237 100644
--- a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/DataExplorerQueryExecutor.java
+++ b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/DataExplorerQueryExecutor.java
@@ -57,7 +57,8 @@ public abstract class DataExplorerQueryExecutor<X, W> {
       X countQuery = makeCountQuery(params);
       W countQueryResult = executeQuery(countQuery);
       var limit = params.getLimit();
-      Double amountOfQueryResults = limit == Integer.MIN_VALUE ? getAmountOfResults(countQueryResult) : limit;
+      var amountOfResults = getAmountOfResults(countQueryResult);
+      Double amountOfQueryResults = limit == Integer.MIN_VALUE ? amountOfResults : Math.min(amountOfResults, limit);
 
       if (amountOfQueryResults > this.maximumAmountOfEvents) {
         SpQueryResult tooMuchData = new SpQueryResult();
diff --git a/ui/src/app/connect/services/rest.service.ts b/ui/src/app/connect/services/rest.service.ts
index 1b77ebafb..06531338f 100644
--- a/ui/src/app/connect/services/rest.service.ts
+++ b/ui/src/app/connect/services/rest.service.ts
@@ -18,7 +18,7 @@
 
 import { Injectable } from '@angular/core';
 
-import { HttpClient } from '@angular/common/http';
+import { HttpClient, HttpContext } from '@angular/common/http';
 
 import { Observable } from 'rxjs';
 import { map } from 'rxjs/operators';
@@ -32,6 +32,7 @@ import {
     PlatformServicesCommons,
     SpDataStream,
 } from '@streampipes/platform-services';
+import { NGX_LOADING_BAR_IGNORED } from '@ngx-loading-bar/http-client';
 
 @Injectable()
 export class RestService {
@@ -84,7 +85,7 @@ export class RestService {
             `${this.platformServicesCommons.apiBasePath}/pipeline-element/runtime`,
             sourceDescription,
             {
-                headers: { ignoreLoadingBar: '' },
+                context: new HttpContext().set(NGX_LOADING_BAR_IGNORED, true),
             },
         );
     }
diff --git a/ui/src/app/data-explorer/components/widgets/table/table-widget.component.html b/ui/src/app/data-explorer/components/widgets/table/table-widget.component.html
index 1b44a9132..7fcada6fe 100644
--- a/ui/src/app/data-explorer/components/widgets/table/table-widget.component.html
+++ b/ui/src/app/data-explorer/components/widgets/table/table-widget.component.html
@@ -120,7 +120,7 @@
             <tr mat-row *matRowDef="let row; columns: columnNames"></tr>
         </table>
         <mat-paginator
-            *ngIf="showData"
+            color="accent"
             [length]="100"
             [pageSize]="500"
             [pageSizeOptions]="[10, 20, 50, 100, 500, 1000]"
diff --git a/ui/src/app/editor/services/editor.service.ts b/ui/src/app/editor/services/editor.service.ts
index 6aef9e793..0b36c21aa 100644
--- a/ui/src/app/editor/services/editor.service.ts
+++ b/ui/src/app/editor/services/editor.service.ts
@@ -17,7 +17,7 @@
  */
 
 import { Injectable } from '@angular/core';
-import { HttpClient } from '@angular/common/http';
+import { HttpClient, HttpContext } from '@angular/common/http';
 import {
     DataProcessorInvocation,
     DataSetModificationMessage,
@@ -40,6 +40,7 @@ import {
 import { DialogService, PanelType } from '@streampipes/shared-ui';
 import { HelpComponent } from '../dialog/help/help.component';
 import { map } from 'rxjs/operators';
+import { NGX_LOADING_BAR_IGNORED } from '@ngx-loading-bar/http-client';
 
 @Injectable({ providedIn: 'root' })
 export class EditorService {
@@ -234,7 +235,7 @@ export class EditorService {
                 previewId +
                 '/' +
                 pipelineElementDomId,
-            { headers: { ignoreLoadingBar: '' } },
+            { context: new HttpContext().set(NGX_LOADING_BAR_IGNORED, true) },
         );
     }
 
diff --git a/ui/src/app/login/services/login.service.ts b/ui/src/app/login/services/login.service.ts
index b868e9f62..c61f80fad 100644
--- a/ui/src/app/login/services/login.service.ts
+++ b/ui/src/app/login/services/login.service.ts
@@ -17,12 +17,13 @@
  */
 
 import { Injectable, OnInit } from '@angular/core';
-import { HttpClient } from '@angular/common/http';
+import { HttpClient, HttpContext } from '@angular/common/http';
 import { PlatformServicesCommons } from '@streampipes/platform-services';
 import { Observable } from 'rxjs';
 import { LoginModel } from '../components/login/login.model';
 import { map } from 'rxjs/operators';
 import { RegistrationModel } from '../components/register/registration.model';
+import { NGX_LOADING_BAR_IGNORED } from '@ngx-loading-bar/http-client';
 
 @Injectable()
 export class LoginService {
@@ -48,7 +49,7 @@ export class LoginService {
         return this.http.get(
             this.platformServicesCommons.apiBasePath + '/auth/token/renew',
             {
-                headers: { ignoreLoadingBar: '' },
+                context: new HttpContext().set(NGX_LOADING_BAR_IGNORED, true),
             },
         );
     }
diff --git a/ui/src/app/notifications/service/notifications.service.ts b/ui/src/app/notifications/service/notifications.service.ts
index 8433f4584..8485a540f 100644
--- a/ui/src/app/notifications/service/notifications.service.ts
+++ b/ui/src/app/notifications/service/notifications.service.ts
@@ -15,7 +15,7 @@
  *   limitations under the License.
  */
 
-import { HttpClient } from '@angular/common/http';
+import { HttpClient, HttpContext } from '@angular/common/http';
 import { Observable } from 'rxjs';
 import {
     ExistingNotification,
@@ -25,6 +25,7 @@ import { Injectable } from '@angular/core';
 import { NotificationUtils } from '../utils/notifications.utils';
 import { map } from 'rxjs/operators';
 import { PlatformServicesCommons } from '@streampipes/platform-services';
+import { NGX_LOADING_BAR_IGNORED } from '@ngx-loading-bar/http-client';
 
 @Injectable()
 export class NotificationsService {
@@ -80,7 +81,7 @@ export class NotificationsService {
             this.notificationUrl + '/' + notificationItem._id,
             notificationItem,
             {
-                headers: { ignoreLoadingBar: '' },
+                context: new HttpContext().set(NGX_LOADING_BAR_IGNORED, true),
             },
         );
     }
diff --git a/ui/src/app/services/rest-api.service.ts b/ui/src/app/services/rest-api.service.ts
index 62a2d46ff..82fdc1ada 100644
--- a/ui/src/app/services/rest-api.service.ts
+++ b/ui/src/app/services/rest-api.service.ts
@@ -18,8 +18,9 @@
 
 import { Injectable } from '@angular/core';
 import { PlatformServicesCommons } from '@streampipes/platform-services';
-import { HttpClient } from '@angular/common/http';
+import { HttpClient, HttpContext } from '@angular/common/http';
 import { Observable } from 'rxjs';
+import { NGX_LOADING_BAR_IGNORED } from '@ngx-loading-bar/http-client';
 
 @Injectable()
 export class RestApi {
@@ -44,13 +45,13 @@ export class RestApi {
 
     configured(): Observable<any> {
         return this.$http.get(this.getServerUrl() + '/setup/configured', {
-            headers: { ignoreLoadingBar: '' },
+            context: new HttpContext().set(NGX_LOADING_BAR_IGNORED, true),
         });
     }
 
     getUnreadNotificationsCount(): Observable<any> {
         return this.$http.get(this.urlApiBase() + '/notifications/count', {
-            headers: { ignoreLoadingBar: '' },
+            context: new HttpContext().set(NGX_LOADING_BAR_IGNORED, true),
         });
     }