healthyregions / SDOHPlace

Landing page and data discovery application for SDOH Place Project.
https://sdohplace.org
GNU General Public License v3.0
1 stars 0 forks source link

Create helpers.js to load metadata schema and translate Solr records #74

Closed mradamcox closed 8 months ago

mradamcox commented 9 months ago

Use discovery_app branch.

We should add a function (or two) to pages/search/_metadata/helpers.js to do the following:

  1. Get full metadata schema

Load both metadata schema files in that directory, combine and return them in a single object.

  1. Translate Solr records for easier access in templates

Take a json object input from Solr, and use the lookup produced above to output and object with a format that uses the more readable id as key and includes a "meta" property with the field-specific attributes. For example:

input solr document json (partial):

{ 
  dct_title_s: "CDC Social Vulnerability Index (SVI) 2000"
}

output object:

{
  title: {
    meta: {
      "label": "Title",
      "uri": "dct_title_s",
      "data_type": "string",
      "multiple": false,
      "obligation": "required",
      "controlled": false,
      "controlled_options": [],
      "schema": "Aardvark",
      "display_group": "Descriptive",
      "slug": "title",
      "widget": "text-simple.html"
    },
    value: "CDC Social Vulnerability Index (SVI) 2000"    
  }  
}

It's likely that we won't need all of these meta properties, but for now we should begin by making everything available.

pengyin-shan commented 8 months ago

Close this issue since its PR has been merged to the discovery_app branch