You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2019/03/11 05:37:22 UTC

[GitHub] [ignite] Klaster1 commented on a change in pull request #6021: IGNITE-11035 Updates in queries page.

Klaster1 commented on a change in pull request #6021: IGNITE-11035 Updates in queries page.
URL: https://github.com/apache/ignite/pull/6021#discussion_r264096067
 
 

 ##########
 File path: modules/web-console/frontend/app/components/page-queries/components/queries-notebook/controller.ts
 ##########
 @@ -1233,46 +1264,109 @@ export class NotebookCtrl {
             _rebuildColumns(paragraph);
         };
 
-        const _showLoading = (paragraph, enable) => {
-            if (paragraph.qryType === 'scan')
-                paragraph.scanningInProgress = enable;
-
-            paragraph.loading = enable;
-        };
-
-        const _fetchQueryResult = (paragraph, clearChart, res, qryArg) => {
-            if (!_.isNil(res.rows)) {
-                _processQueryResult(paragraph, clearChart, res);
-                _tryStartRefresh(paragraph);
-
-                $scope.$applyAsync();
+        /**
+         * Execute query and get first result page.
+         *
+         * @param qryType Query type. 'query' or `scan`.
+         * @param qryArg Argument with query properties.
+         * @param {(res) => any} onQueryStarted Action to execute when query ID is received.
+         * @return {Observable<VisorQueryResult>} Observable with first query result page.
+         */
+        const _executeQuery0 = (qryType, qryArg, onQueryStarted: (res) => any = () => {}) => {
+            return from(qryType === 'scan' ? agentMgr.queryScan(qryArg) : agentMgr.querySql(qryArg)).pipe(
+                tap((res) => {
+                    onQueryStarted(res);
+                    $scope.$applyAsync();
+                }),
+                expand((res) => {
+                    const fetchFirstPageTask = timer(100, 500).pipe(
+                        exhaustMap(() => agentMgr.queryFetchFistsPage(qryArg.nid, res.queryId, qryArg.pageSize)),
+                        filter((res) => !_.isNil(res.rows))
+                    );
 
-                return;
-            }
+                    const pingQueryTask = timer(60000, 60000).pipe(
+                        exhaustMap(() => agentMgr.queryPing(qryArg.nid, res.queryId)),
+                        takeWhile(({inProgress}) => inProgress),
+                        ignoreElements()
+                    );
 
-            const subscription = timer(100, 500).pipe(
-                exhaustMap(() => agentMgr.queryFetchFistsPage(qryArg.nid, res.queryId, qryArg.pageSize)),
+                    return merge(fetchFirstPageTask, pingQueryTask);
+                }),
                 filter((res) => !_.isNil(res.rows)),
-                take(1),
-                map((res) => _fetchQueryResult(paragraph, false, res, qryArg)),
-                catchError((err) => {
-                    if (paragraph.subscription) {
-                        paragraph.subscription.unsubscribe();
-                        paragraph.setError(err);
-
-                        _showLoading(paragraph, false);
-                        delete paragraph.subscription;
+                first()
 
 Review comment:
   @vsisko  given that `first` and `take(1)` [are slightly different](https://stackoverflow.com/q/42345969/333777), do you really intend to throw if no results arrive upon observable completion? If user cancels the query by leaving the screen, wouldn't it throw?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services