From 12c5f6f0a7fef4ef14d7f7ef20ccfe74a4b82509 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 30 Mar 2023 11:15:09 +0530 Subject: [PATCH] chore: lint Signed-off-by: Pranav C --- .../src/lib/controllers/dbData/oldData.ctl.ts | 11 ++---- .../sql/formulav2/formulaQueryBuilderv2.ts | 2 +- .../nocodb/src/lib/services/dbData/helpers.ts | 2 +- .../nocodb/src/lib/services/dbData/index.ts | 37 ++++--------------- .../src/lib/services/public/publicData.svc.ts | 20 +++------- 5 files changed, 17 insertions(+), 55 deletions(-) diff --git a/packages/nocodb/src/lib/controllers/dbData/oldData.ctl.ts b/packages/nocodb/src/lib/controllers/dbData/oldData.ctl.ts index 4c91aa2ecc..15608b4b91 100644 --- a/packages/nocodb/src/lib/controllers/dbData/oldData.ctl.ts +++ b/packages/nocodb/src/lib/controllers/dbData/oldData.ctl.ts @@ -132,19 +132,14 @@ async function dataRead(req: Request, res: Response) { dbDriver: await NcConnectionMgrv2.get(base), }); - const {ast} = await getAst({ + const { ast } = await getAst({ query: req.query, model, view, - }) + }); res.json( - await nocoExecute( - ast , - await baseModel.readByPk(req.params.rowId), - {}, - {} - ) + await nocoExecute(ast, await baseModel.readByPk(req.params.rowId), {}, {}) ); } diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/formulav2/formulaQueryBuilderv2.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/formulav2/formulaQueryBuilderv2.ts index 0b59219c43..3eb91300d9 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/formulav2/formulaQueryBuilderv2.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/formulav2/formulaQueryBuilderv2.ts @@ -836,7 +836,7 @@ export default async function formulaQueryBuilderv2( tableAlias ); - if(!validateFormula) return qb; + if (!validateFormula) return qb; try { // dry run qb.builder to see if it will break the grid view or not diff --git a/packages/nocodb/src/lib/services/dbData/helpers.ts b/packages/nocodb/src/lib/services/dbData/helpers.ts index 7f1353062e..92395e2f0b 100644 --- a/packages/nocodb/src/lib/services/dbData/helpers.ts +++ b/packages/nocodb/src/lib/services/dbData/helpers.ts @@ -242,7 +242,7 @@ export async function getDbRows(param: { temp = process.hrtime(startTime), elapsed = temp[0] * 1000 + temp[1] / 1000000 ) { - const {ast, dependencyFields} = await getAst({ + const { ast, dependencyFields } = await getAst({ query: query, includePkByDefault: false, model: view.model, diff --git a/packages/nocodb/src/lib/services/dbData/index.ts b/packages/nocodb/src/lib/services/dbData/index.ts index 5a62023a14..6bacb1f1b0 100644 --- a/packages/nocodb/src/lib/services/dbData/index.ts +++ b/packages/nocodb/src/lib/services/dbData/index.ts @@ -116,7 +116,6 @@ export async function getDataList(param: { const { ast, dependencyFields } = await getAst({ model, query, view }); - const listArgs: any = dependencyFields; try { listArgs.filterArr = JSON.parse(listArgs.filterArrJson); @@ -128,12 +127,7 @@ export async function getDataList(param: { let data = []; let count = 0; try { - data = await nocoExecute( - ast, - await baseModel.list(listArgs), - {}, - listArgs - ); + data = await nocoExecute(ast, await baseModel.list(listArgs), {}, listArgs); count = await baseModel.count(listArgs); } catch (e) { console.log(e); @@ -171,17 +165,10 @@ export async function getFindOne(param: { args.sortArr = JSON.parse(args.sortArrJson); } catch (e) {} - const {ast, dependencyFields} = await getAst({ model, query: args, view }) + const { ast, dependencyFields } = await getAst({ model, query: args, view }); const data = await baseModel.findOne({ ...args, dependencyFields }); - return data - ? await nocoExecute( - ast, - data, - {}, - {} - ) - : {}; + return data ? await nocoExecute(ast, data, {}, {}) : {}; } export async function getDataGroupBy(param: { @@ -228,14 +215,9 @@ export async function dataRead( NcError.notFound('Row not found'); } - const { ast, dependencyFields } = await getAst({ model, query: param.query, view }) + const { ast } = await getAst({ model, query: param.query, view }); - return await nocoExecute( - ast, - row, - {}, - param.query - ); + return await nocoExecute(ast, row, {}, param.query); } export async function dataExist( @@ -303,12 +285,7 @@ export async function getGroupedDataList(param: { ...listArgs, groupColumnId: param.columnId, }); - data = await nocoExecute( - { key: 1, value: ast }, - groupedData, - {}, - listArgs - ); + data = await nocoExecute({ key: 1, value: ast }, groupedData, {}, listArgs); const countArr = await baseModel.groupedListCount({ ...listArgs, groupColumnId: param.columnId, @@ -655,7 +632,7 @@ export async function dataReadByViewId(param: { dbDriver: await NcConnectionMgrv2.get(base), }); - const { ast } = await getAst({ model, query: param.query }) + const { ast } = await getAst({ model, query: param.query }); return await nocoExecute( ast, diff --git a/packages/nocodb/src/lib/services/public/publicData.svc.ts b/packages/nocodb/src/lib/services/public/publicData.svc.ts index 4a0a469117..0a29b7201b 100644 --- a/packages/nocodb/src/lib/services/public/publicData.svc.ts +++ b/packages/nocodb/src/lib/services/public/publicData.svc.ts @@ -63,21 +63,16 @@ export async function dataList(param: { query: param.query, model, view, - }) + }); - data = await nocoExecute( - ast, - await baseModel.list(listArgs), - {}, - listArgs - ); + data = await nocoExecute(ast, await baseModel.list(listArgs), {}, listArgs); count = await baseModel.count(listArgs); } catch (e) { - console.log(e) + console.log(e); // show empty result instead of throwing error here // e.g. search some text in a numeric field - NcError.internalServerError('Please try after some time') + NcError.internalServerError('Please try after some time'); } return new PagedResponseImpl(data, { ...param.query, count }); @@ -153,12 +148,7 @@ async function getGroupedDataList(param: { ...listArgs, groupColumnId, }); - data = await nocoExecute( - { key: 1, value: ast }, - groupedData, - {}, - listArgs - ); + data = await nocoExecute({ key: 1, value: ast }, groupedData, {}, listArgs); const countArr = await baseModel.groupedListCount({ ...listArgs, groupColumnId,