From a61e1afdc3a6118e485e466b8e545c72e59745b2 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Thu, 20 Jan 2022 16:17:09 +0000 Subject: [PATCH] Merge fix and linting --- .../support/queryLevelTransformerFunction.js | 14 --------- .../queryLevelTransformerFunctionWithData.js | 31 ------------------- packages/server/src/integrations/utils.ts | 23 +++++++++++--- 3 files changed, 18 insertions(+), 50 deletions(-) delete mode 100644 packages/builder/cypress/support/queryLevelTransformerFunction.js delete mode 100644 packages/builder/cypress/support/queryLevelTransformerFunctionWithData.js diff --git a/packages/builder/cypress/support/queryLevelTransformerFunction.js b/packages/builder/cypress/support/queryLevelTransformerFunction.js deleted file mode 100644 index 8ad3e573d..000000000 --- a/packages/builder/cypress/support/queryLevelTransformerFunction.js +++ /dev/null @@ -1,14 +0,0 @@ -// eslint-disable-next-line no-undef -const breweries = data -const totals = {} - -for (let brewery of breweries) { - const state = brewery.state - if (totals[state] == null) { - totals[state] = 1 - } else { - totals[state]++ - } -} -const entries = Object.entries(totals) -return entries.map(([state, count]) => ({ state, count })) diff --git a/packages/builder/cypress/support/queryLevelTransformerFunctionWithData.js b/packages/builder/cypress/support/queryLevelTransformerFunctionWithData.js deleted file mode 100644 index 50f3da709..000000000 --- a/packages/builder/cypress/support/queryLevelTransformerFunctionWithData.js +++ /dev/null @@ -1,31 +0,0 @@ -// eslint-disable-next-line no-undef -const breweries = data -const totals = {} -for (let brewery of breweries) { - const state = brewery.state - if (totals[state] == null) { - totals[state] = 1 - } else { - totals[state]++ - } -} -const stateCodes = { - texas: "tx", - colorado: "co", - florida: "fl", - iwoa: "ia", - louisiana: "la", - california: "ca", - pennsylvania: "pa", - georgia: "ga", - "new hampshire": "nh", - virginia: "va", - michigan: "mi", - maryland: "md", - ohio: "oh", -} -const entries = Object.entries(totals) -return entries.map(([state, count]) => { - stateCodes[state.toLowerCase()] - return { state, count, flag: "http://flags.ox3.in/svg/us/${stateCode}.svg" } -}) diff --git a/packages/server/src/integrations/utils.ts b/packages/server/src/integrations/utils.ts index b8c96efff..b9e643e26 100644 --- a/packages/server/src/integrations/utils.ts +++ b/packages/server/src/integrations/utils.ts @@ -153,8 +153,15 @@ export function isIsoDateString(str: string) { * @param column The column to check, to see if it is a valid relationship. * @param tableIds The IDs of the tables which currently exist. */ -function shouldCopyRelationship(column: { type: string, tableId?: string }, tableIds: [string]) { - return column.type === FieldTypes.LINK && column.tableId && tableIds.includes(column.tableId) +function shouldCopyRelationship( + column: { type: string; tableId?: string }, + tableIds: [string] +) { + return ( + column.type === FieldTypes.LINK && + column.tableId && + tableIds.includes(column.tableId) + ) } /** @@ -165,9 +172,15 @@ function shouldCopyRelationship(column: { type: string, tableId?: string }, tabl * @param column The column to check for options or boolean type. * @param fetchedColumn The fetched column to check for the type in the external database. */ -function shouldCopySpecialColumn(column: { type: string }, fetchedColumn: { type: string } | undefined) { - return column.type === FieldTypes.OPTIONS || - ((!fetchedColumn || fetchedColumn.type === FieldTypes.NUMBER) && column.type === FieldTypes.BOOLEAN) +function shouldCopySpecialColumn( + column: { type: string }, + fetchedColumn: { type: string } | undefined +) { + return ( + column.type === FieldTypes.OPTIONS || + ((!fetchedColumn || fetchedColumn.type === FieldTypes.NUMBER) && + column.type === FieldTypes.BOOLEAN) + ) } /**