refact: changed get rows to export for tables
This commit is contained in:
parent
6b82a167b6
commit
b78a064f0e
@ -15,7 +15,7 @@ class Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getRows = () => this.rows
|
export = () => this.rows
|
||||||
|
|
||||||
setRows = rows => {
|
setRows = rows => {
|
||||||
const rowsValidation = this._validateRows(rows)
|
const rowsValidation = this._validateRows(rows)
|
||||||
|
@ -20,7 +20,7 @@ class FilterNode extends Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export = () => {
|
export = () => {
|
||||||
let rows = this.tables.map(t => t.getRows() ).flat()
|
let rows = this.tables.map(t => t.export() ).flat()
|
||||||
let filters = this._createFilterMethods()
|
let filters = this._createFilterMethods()
|
||||||
|
|
||||||
filters.forEach(f => {
|
filters.forEach(f => {
|
||||||
|
@ -8,7 +8,7 @@ class JoinNode extends Node {
|
|||||||
|
|
||||||
export = () => {
|
export = () => {
|
||||||
const baseTable = this.tables.find(t => t.label === this.baseTableLabel)
|
const baseTable = this.tables.find(t => t.label === this.baseTableLabel)
|
||||||
const baseTableRows = baseTable.getRows()
|
const baseTableRows = baseTable.export()
|
||||||
const tablesToJoin = this.tables.filter(t => {
|
const tablesToJoin = this.tables.filter(t => {
|
||||||
return t.label !== this.baseTableLabel
|
return t.label !== this.baseTableLabel
|
||||||
})
|
})
|
||||||
@ -17,7 +17,7 @@ class JoinNode extends Node {
|
|||||||
const foreignTable = tablesToJoin.find(t => {
|
const foreignTable = tablesToJoin.find(t => {
|
||||||
return t.label === joinParam.foreignTable
|
return t.label === joinParam.foreignTable
|
||||||
})
|
})
|
||||||
const foreignTableRows = foreignTable.getRows()
|
const foreignTableRows = foreignTable.export()
|
||||||
|
|
||||||
const mergedRows = baseTableRows.map(baseRow => {
|
const mergedRows = baseTableRows.map(baseRow => {
|
||||||
const matchingForeignRow = foreignTableRows.find(foreignRow => {
|
const matchingForeignRow = foreignTableRows.find(foreignRow => {
|
||||||
|
@ -40,7 +40,7 @@ const getTableRows = () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const table = new Table(input)
|
const table = new Table(input)
|
||||||
const tableRows = table.getRows()
|
const tableRows = table.export()
|
||||||
if (JSON.stringify(tableRows) === JSON.stringify(expectedOutput)) return true
|
if (JSON.stringify(tableRows) === JSON.stringify(expectedOutput)) return true
|
||||||
else return false
|
else return false
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user