Skip to content

Commit cc43ebb

Browse files
committed
code polish
1 parent 5be9034 commit cc43ebb

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

packages/cubejs-cubestore-driver/src/CubeStoreQueueDriver.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class CubestoreQueueDriverConnection implements QueueDriverConnectionInterface {
8383
values.push(JSON.stringify(data));
8484

8585
const rows = await this.driver.query(`QUEUE ADD PRIORITY ?${options.orphanedTimeout ? ' ORPHANED ?' : ''} ? ?`, values);
86-
if (rows && rows.length) {
86+
if (rows?.length) {
8787
return [
8888
rows[0].added === 'true' ? 1 : 0,
8989
rows[0].id ? parseInt(rows[0].id, 10) : null,
@@ -104,7 +104,7 @@ class CubestoreQueueDriverConnection implements QueueDriverConnectionInterface {
104104
// queryKeyHash as compatibility fallback
105105
queueId || this.prefixKey(hash),
106106
]);
107-
if (rows && rows.length) {
107+
if (rows?.length) {
108108
return this.decodeQueryDefFromRow(rows[0], 'cancelQuery');
109109
}
110110

@@ -149,7 +149,7 @@ class CubestoreQueueDriverConnection implements QueueDriverConnectionInterface {
149149
const rows = await this.driver.query('CACHE INCR ?', [
150150
`${this.options.redisQueuePrefix}:PROCESSING_COUNTER`
151151
]);
152-
if (rows && rows.length) {
152+
if (rows?.length) {
153153
return rows[0].value;
154154
}
155155

@@ -186,7 +186,7 @@ class CubestoreQueueDriverConnection implements QueueDriverConnectionInterface {
186186
const rows = await this.driver.query('QUEUE RESULT ?', [
187187
this.prefixKey(this.redisHash(queryKey)),
188188
]);
189-
if (rows && rows.length) {
189+
if (rows?.length) {
190190
return this.decodeQueryDefFromRow(rows[0], 'getResult');
191191
}
192192

@@ -245,7 +245,7 @@ class CubestoreQueueDriverConnection implements QueueDriverConnectionInterface {
245245
const rows = await this.driver.query('QUEUE GET ?', [
246246
queueId || this.prefixKey(hash),
247247
]);
248-
if (rows && rows.length) {
248+
if (rows?.length) {
249249
return this.decodeQueryDefFromRow(rows[0], 'getQueryDef');
250250
}
251251

@@ -271,7 +271,7 @@ class CubestoreQueueDriverConnection implements QueueDriverConnectionInterface {
271271
this.options.concurrency,
272272
this.prefixKey(hash),
273273
]);
274-
if (rows && rows.length) {
274+
if (rows?.length) {
275275
const active = rows[0].active ? (rows[0].active).split(',') as unknown as QueryKeyHash[] : [];
276276
const pending = parseInt(rows[0].pending, 10);
277277

@@ -302,7 +302,7 @@ class CubestoreQueueDriverConnection implements QueueDriverConnectionInterface {
302302
// queryKeyHash as compatibility fallback
303303
queueId || this.prefixKey(hash),
304304
]);
305-
if (rows && rows.length) {
305+
if (rows?.length) {
306306
return this.decodeQueryDefFromRow(rows[0], 'getResultBlocking');
307307
}
308308

@@ -348,8 +348,8 @@ export class CubeStoreQueueDriver implements QueueDriverInterface {
348348
return this.connection;
349349
}
350350

351-
// eslint-disable-next-line no-return-assign
352-
return this.connection = await this.driverFactory();
351+
this.connection = await this.driverFactory();
352+
return this.connection;
353353
}
354354

355355
public async createConnection(): Promise<CubestoreQueueDriverConnection> {

packages/cubejs-testing/test/smoke-cubesql.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -179,23 +179,23 @@ describe('SQL API', () => {
179179
}
180180

181181
it('regular query', async () => {
182-
expect(await generateSql(`SELECT SUM(totalAmount) AS total FROM Orders;`)).toMatchSnapshot();
182+
expect(await generateSql('SELECT SUM(totalAmount) AS total FROM Orders;')).toMatchSnapshot();
183183
});
184184

185185
it('regular query with missing column', async () => {
186-
expect(await generateSql(`SELECT SUM(foobar) AS total FROM Orders;`)).toMatchSnapshot();
186+
expect(await generateSql('SELECT SUM(foobar) AS total FROM Orders;')).toMatchSnapshot();
187187
});
188188

189189
it('regular query with parameters', async () => {
190-
expect(await generateSql(`SELECT SUM(totalAmount) AS total FROM Orders WHERE status = 'foo';`)).toMatchSnapshot();
190+
expect(await generateSql('SELECT SUM(totalAmount) AS total FROM Orders WHERE status = \'foo\';')).toMatchSnapshot();
191191
});
192192

193193
it('strictly post-processing', async () => {
194-
expect(await generateSql(`SELECT version();`)).toMatchSnapshot();
194+
expect(await generateSql('SELECT version();')).toMatchSnapshot();
195195
});
196196

197197
it('strictly post-processing with disabled post-processing', async () => {
198-
expect(await generateSql(`SELECT version();`, true)).toMatchSnapshot();
198+
expect(await generateSql('SELECT version();', true)).toMatchSnapshot();
199199
});
200200

201201
it('double aggregation post-processing', async () => {

packages/cubejs-testing/test/smoke-duckdb.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe('duckdb', () => {
9090
]
9191
});
9292

93-
// There are 2 'processed' orders
93+
// There are 2 'processed' orders
9494
expect(response.rawData()[0]['Orders.count']).toBe('2');
9595
});
9696

0 commit comments

Comments
 (0)