Skip to content

Commit 60cd225

Browse files
Fix styling errors reportered by restyled
1 parent 3f7b779 commit 60cd225

File tree

1 file changed

+32
-29
lines changed

1 file changed

+32
-29
lines changed

Diff for: client/app/services/query-result.js

+32-29
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const logger = debug("redash:services:QueryResult");
99
const filterTypes = ["filter", "multi-filter", "multiFilter"];
1010

1111
function defer() {
12-
const result = { onStatusChange: status => {} };
12+
const result = { onStatusChange: (status) => {} };
1313
result.promise = new Promise((resolve, reject) => {
1414
result.resolve = resolve;
1515
result.reject = reject;
@@ -40,13 +40,13 @@ function getColumnNameWithoutType(column) {
4040
}
4141

4242
function getColumnFriendlyName(column) {
43-
return getColumnNameWithoutType(column).replace(/(?:^|\s)\S/g, a => a.toUpperCase());
43+
return getColumnNameWithoutType(column).replace(/(?:^|\s)\S/g, (a) => a.toUpperCase());
4444
}
4545

4646
const createOrSaveUrl = data => (data.id ? `api/query_results/${data.id}` : "api/query_results");
4747
const QueryResultResource = {
4848
get: ({ id }) => axios.get(`api/query_results/${id}`),
49-
post: data => axios.post(createOrSaveUrl(data), data),
49+
post: (data) => axios.post(createOrSaveUrl(data), data),
5050
};
5151

5252
export const ExecutionStatus = {
@@ -97,11 +97,11 @@ function handleErrorResponse(queryResult, error) {
9797
}
9898

9999
function sleep(ms) {
100-
return new Promise(resolve => setTimeout(resolve, ms));
100+
return new Promise((resolve) => setTimeout(resolve, ms));
101101
}
102102

103103
export function fetchDataFromJob(jobId, interval = 1000) {
104-
return axios.get(`api/jobs/${jobId}`).then(data => {
104+
return axios.get(`api/jobs/${jobId}`).then((data) => {
105105
const status = statuses[data.job.status];
106106
if (status === ExecutionStatus.WAITING || status === ExecutionStatus.PROCESSING) {
107107
return sleep(interval).then(() => fetchDataFromJob(data.job.id));
@@ -146,7 +146,7 @@ class QueryResult {
146146
// TODO: we should stop manipulating incoming data, and switch to relaying
147147
// on the column type set by the backend. This logic is prone to errors,
148148
// and better be removed. Kept for now, for backward compatability.
149-
each(this.query_result.data.rows, row => {
149+
each(this.query_result.data.rows, (row) => {
150150
forOwn(row, (v, k) => {
151151
let newType = null;
152152
if (isNumber(v)) {
@@ -173,7 +173,7 @@ class QueryResult {
173173
});
174174
});
175175

176-
each(this.query_result.data.columns, column => {
176+
each(this.query_result.data.columns, (column) => {
177177
column.name = "" + column.name;
178178
if (columnTypes[column.name]) {
179179
if (column.type == null || column.type === "string") {
@@ -265,14 +265,14 @@ class QueryResult {
265265

266266
getColumnNames() {
267267
if (this.columnNames === undefined && this.query_result.data) {
268-
this.columnNames = this.query_result.data.columns.map(v => v.name);
268+
this.columnNames = this.query_result.data.columns.map((v) => v.name);
269269
}
270270

271271
return this.columnNames;
272272
}
273273

274274
getColumnFriendlyNames() {
275-
return this.getColumnNames().map(col => getColumnFriendlyName(col));
275+
return this.getColumnNames().map((col) => getColumnFriendlyName(col));
276276
}
277277

278278
getTruncated() {
@@ -286,7 +286,7 @@ class QueryResult {
286286

287287
const filters = [];
288288

289-
this.getColumns().forEach(col => {
289+
this.getColumns().forEach((col) => {
290290
const name = col.name;
291291
const type = name.split("::")[1] || name.split("__")[1];
292292
if (includes(filterTypes, type)) {
@@ -302,8 +302,8 @@ class QueryResult {
302302
}
303303
}, this);
304304

305-
this.getRawData().forEach(row => {
306-
filters.forEach(filter => {
305+
this.getRawData().forEach((row) => {
306+
filters.forEach((filter) => {
307307
filter.values.push(row[filter.name]);
308308
if (filter.values.length === 1) {
309309
if (filter.multiple) {
@@ -315,8 +315,8 @@ class QueryResult {
315315
});
316316
});
317317

318-
filters.forEach(filter => {
319-
filter.values = uniqBy(filter.values, v => {
318+
filters.forEach((filter) => {
319+
filter.values = uniqBy(filter.values, (v) => {
320320
if (moment.isMoment(v)) {
321321
return v.unix();
322322
}
@@ -345,12 +345,12 @@ class QueryResult {
345345

346346
axios
347347
.get(`api/queries/${queryId}/results/${id}.json`)
348-
.then(response => {
348+
.then((response) => {
349349
// Success handler
350350
queryResult.isLoadingResult = false;
351351
queryResult.update(response);
352352
})
353-
.catch(error => {
353+
.catch((error) => {
354354
// Error handler
355355
queryResult.isLoadingResult = false;
356356
handleErrorResponse(queryResult, error);
@@ -362,10 +362,10 @@ class QueryResult {
362362
loadLatestCachedResult(queryId, parameters) {
363363
axios
364364
.post(`api/queries/${queryId}/results`, { queryId, parameters })
365-
.then(response => {
365+
.then((response) => {
366366
this.update(response);
367367
})
368-
.catch(error => {
368+
.catch((error) => {
369369
handleErrorResponse(this, error);
370370
});
371371
}
@@ -375,11 +375,11 @@ class QueryResult {
375375
this.deferred.onStatusChange(ExecutionStatus.LOADING_RESULT);
376376

377377
QueryResultResource.get({ id: this.job.query_result_id })
378-
.then(response => {
378+
.then((response) => {
379379
this.update(response);
380380
this.isLoadingResult = false;
381381
})
382-
.catch(error => {
382+
.catch((error) => {
383383
if (tryCount === undefined) {
384384
tryCount = 0;
385385
}
@@ -394,9 +394,12 @@ class QueryResult {
394394
});
395395
this.isLoadingResult = false;
396396
} else {
397-
setTimeout(() => {
398-
this.loadResult(tryCount + 1);
399-
}, 1000 * Math.pow(2, tryCount));
397+
setTimeout(
398+
() => {
399+
this.loadResult(tryCount + 1);
400+
},
401+
1000 * Math.pow(2, tryCount)
402+
);
400403
}
401404
});
402405
}
@@ -410,7 +413,7 @@ class QueryResult {
410413
: axios.get(`api/queries/${query}/jobs/${this.job.id}`);
411414

412415
request
413-
.then(jobResponse => {
416+
.then((jobResponse) => {
414417
this.update(jobResponse);
415418

416419
if (this.getStatus() === "processing" && this.job.query_result_id && this.job.query_result_id !== "None") {
@@ -429,7 +432,7 @@ class QueryResult {
429432
}, waitTime);
430433
}
431434
})
432-
.catch(error => {
435+
.catch((error) => {
433436
logger("Connection error", error);
434437
// TODO: use QueryResultError, or better yet: exception/reject of promise.
435438
this.update({
@@ -458,14 +461,14 @@ class QueryResult {
458461

459462
axios
460463
.post(`api/queries/${id}/results`, { id, parameters, apply_auto_limit: applyAutoLimit, max_age: maxAge })
461-
.then(response => {
464+
.then((response) => {
462465
queryResult.update(response);
463466

464467
if ("job" in response) {
465468
queryResult.refreshStatus(id, parameters);
466469
}
467470
})
468-
.catch(error => {
471+
.catch((error) => {
469472
handleErrorResponse(queryResult, error);
470473
});
471474

@@ -488,14 +491,14 @@ class QueryResult {
488491
}
489492

490493
QueryResultResource.post(params)
491-
.then(response => {
494+
.then((response) => {
492495
queryResult.update(response);
493496

494497
if ("job" in response) {
495498
queryResult.refreshStatus(query, parameters);
496499
}
497500
})
498-
.catch(error => {
501+
.catch((error) => {
499502
handleErrorResponse(queryResult, error);
500503
});
501504

0 commit comments

Comments
 (0)