You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/05/25 15:10:35 UTC

[GitHub] [superset] AAfghahi commented on a diff in pull request #20179: chore: Convert QueryAutoRefresh to TypeScript functional React component

AAfghahi commented on code in PR #20179:
URL: https://github.com/apache/superset/pull/20179#discussion_r881773386


##########
superset-frontend/src/SqlLab/components/QueryAutoRefresh/index.tsx:
##########
@@ -0,0 +1,109 @@
+/**
+ * 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 { useState } from 'react';
+import { SupersetClient } from '@superset-ui/core';
+import * as Actions from 'src/SqlLab/actions/sqlLab';
+import { Query } from 'src/SqlLab/types';
+import useInterval from 'src/SqlLab/utils/useInterval';
+
+const QUERY_UPDATE_FREQ = 2000;
+const QUERY_UPDATE_BUFFER_MS = 5000;
+const MAX_QUERY_AGE_TO_POLL = 21600000;
+const QUERY_TIMEOUT_LIMIT = 10000;
+
+interface UserOfflineFunc {
+  (offline: boolean): boolean;
+}
+
+interface RefreshQueriesFunc {
+  (alteredQueries: any): any;
+}
+
+interface Actions {
+  setUserOffline: UserOfflineFunc;
+  refreshQueries: RefreshQueriesFunc;
+}
+
+export interface QueryAutoRefreshProps {
+  queries: Query[];
+  actions: Actions;
+  queriesLastUpdate: number;
+}
+
+// returns true if the Query.state matches one of the specifc values indicating the query is still processing on server
+export const isQueryRunning = (q: Query): boolean =>

Review Comment:
   Would this be better as an enum?



##########
superset-frontend/src/SqlLab/fixtures.ts:
##########
@@ -512,7 +513,86 @@ export const failedQueryWithErrors = {
   tempTable: '',
 };
 
-export const runningQuery = {
+const baseQuery: Query = {

Review Comment:
   crazy that this hasn't existed yet!



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org