client/locations-list-map.js
// NOTE: the incoming data structure is very brittle; if that changes at all, this will break
the incoming data structure is very brittle; if that changes at all, this will break
the incoming data structure is very brittle ; if that changes at all this will break
function parseFiltersFromData(data, datasetFilters) {
  const filters = {};
  Object.keys(datasetFilters).forEach((datasetFilterKey) => {
    filters[datasetFilterKey] = {};
  });
  Object.keys(data).forEach((state) => {
    Object.keys(data[state].cities).forEach((city) => {
      data[state].cities[city].entries.forEach((entry) => {
        Object.keys(datasetFilters).forEach((datasetFilterKey) => {
          const { dataKey } = datasetFilters[datasetFilterKey];
          if (entry[dataKey]) {
            entry[dataKey].split(/,( |)(?![^(]*\))/).map((a) => a.trim()).forEach((i) => {
              const filterKey = i.toLowerCase();
              if (ENUM_MAPPINGS[filterKey] !== undefined && filters[datasetFilterKey][filterKey] === undefined) {
                filters[datasetFilterKey][filterKey] = {
                  ...ENUM_MAPPINGS[filterKey],
                  value: filterKey,
                };
              }
            });
          }
        });
      });
    });
  });
  return filters;
}
function parseFiltersFromData ( data , datasetFilters ) { const filters = { } ; Object . keys ( datasetFilters ) . forEach ( ( datasetFilterKey ) => { filters [ datasetFilterKey ] = { } ; } ) ; Object . keys ( data ) . forEach ( ( state ) => { Object . keys ( data [ state ] . cities ) . forEach ( ( city ) => { data [ state ] . cities [ city ] . entries . forEach ( ( entry ) => { Object . keys ( datasetFilters ) . forEach ( ( datasetFilterKey ) => { const { dataKey } = datasetFilters [ datasetFilterKey ] ; if ( entry [ dataKey ] ) { entry [ dataKey ] . split ( / ,( |)(?![^(]*\)) / ) . map ( ( a ) => a . trim ( ) ) . forEach ( ( i ) => { const filterKey = i . toLowerCase ( ) ; if ( ENUM_MAPPINGS [ filterKey ] !== undefined && filters [ datasetFilterKey ] [ filterKey ] === undefined ) { filters [ datasetFilterKey ] [ filterKey ] = { ... ENUM_MAPPINGS [ filterKey ] , value : filterKey , } ; } } ) ; } } ) ; } ) ; } ) ; } ) ; return filters ; }
NOTE: the incoming data structure is very brittle; if that changes at all, this will break
NOTE : the incoming data structure is very brittle ; if that changes at all this will break