diff --git a/src/filters/filters.js b/src/filters/filters.js index 4be48093..1895e678 100644 --- a/src/filters/filters.js +++ b/src/filters/filters.js @@ -10,7 +10,6 @@ import datasette from '../services/datasette.js' const { govukMarkdown } = xGovFilters const addFilters = async (nunjucksEnv) => { - const datasetSlugNameTable = await datasette.runQuery('select dataset, name from dataset') const datasetNameMapping = createDatasetMapping(datasetSlugNameTable.rows) const datasetSlugToReadableName = makeDatasetSlugToReadableNameFilter(datasetNameMapping) diff --git a/src/filters/makeDatasetSlugToReadableNameFilter.js b/src/filters/makeDatasetSlugToReadableNameFilter.js index 401c4166..6ac79da0 100644 --- a/src/filters/makeDatasetSlugToReadableNameFilter.js +++ b/src/filters/makeDatasetSlugToReadableNameFilter.js @@ -29,16 +29,14 @@ export const makeDatasetSlugToReadableNameFilter = (datasetNameMapping) => { /** * Creates a mapping of dataset slugs to their corresponding readable names. - * + * * @param {Array<[string, string]>} dataSubjects - An array of tuples, where each tuple contains a dataset slug and its corresponding readable name. * @returns {Map} - A Map object where each key is a dataset slug and its value is the corresponding readable name. */ export const createDatasetMapping = (dataSubjects) => { - const datasetMapping = new Map(); + const datasetMapping = new Map() dataSubjects.forEach(([slug, name]) => { - datasetMapping.set(slug, name); - }); - return datasetMapping; + datasetMapping.set(slug, name) + }) + return datasetMapping } - - diff --git a/src/services/datasette.js b/src/services/datasette.js index d3c058c9..840daa17 100644 --- a/src/services/datasette.js +++ b/src/services/datasette.js @@ -37,7 +37,7 @@ export default { * @param {any[][]} rows - A 2D array of row data, where each inner array represents a row * @returns {object[]} - An array of objects, where each object represents a row with column names as keys */ -function formatData (columns, rows){ +function formatData (columns, rows) { // convert the rows into an easier to access format return rows.map((row) => { return row.reduce((acc, val, index) => {