From eccb15a98856f7284aae81e540184a2c1d37a3ab Mon Sep 17 00:00:00 2001 From: Naz Date: Thu, 25 Mar 2021 15:01:54 +1300 Subject: [PATCH] Removed unecessaryly complex logic from exporter refs https://github.com/TryGhost/Team/issues/555 - The getVersionAndTables was doing too much and was only used once creating clutter in doExport method. Refactored code doing 2 direct calls instead of destructuring "dances". --- core/server/data/exporter/index.js | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/core/server/data/exporter/index.js b/core/server/data/exporter/index.js index dd438ba4a4..81120bfb3f 100644 --- a/core/server/data/exporter/index.js +++ b/core/server/data/exporter/index.js @@ -57,15 +57,6 @@ const exportFileName = async function exportFileName(options) { } }; -const getVersionAndTables = function getVersionAndTables(options) { - const props = { - version: ghostVersion.full, - tables: commands.getTables(options.transacting) - }; - - return Promise.props(props); -}; - const exportTable = function exportTable(tableName, options) { if (EXCLUDED_TABLES.indexOf(tableName) < 0 || (options.include && _.isArray(options.include) && options.include.indexOf(tableName) !== -1)) { @@ -84,14 +75,8 @@ const getSettingsTableData = function getSettingsTableData(settingsData) { const doExport = async function doExport(options) { options = options || {include: []}; - let tables; - let version; - try { - const result = await getVersionAndTables(options); - - tables = result.tables; - version = result.version; + const tables = await commands.getTables(options.transacting); const tableData = await Promise.mapSeries(tables, function (tableName) { return exportTable(tableName, options); @@ -100,14 +85,14 @@ const doExport = async function doExport(options) { const exportData = { meta: { exported_on: new Date().getTime(), - version: version + version: ghostVersion.full }, data: { // Filled below } }; - _.each(tables, function (name, i) { + tables.forEach((name, i) => { if (name === 'settings') { exportData.data[name] = getSettingsTableData(tableData[i]); } else {