AlexsLemonade / refinebio-web

Refinebio Web
https://staging.web.refine.bio
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

Remove formatExperiments from useDatasetManager #361

Open nozomione opened 1 month ago

nozomione commented 1 month ago

Context

Epic: #358

The formatExperiments method is currently used within the useDatasetManager hook to format dataset.experiments array field for the UI. We want to remove this method from the hook and have the data presentation components handle formatting directly using dataset.experiments.

e.g., ) The experiments field:

experiments: [
   {    
      title: "Drug-induced change in g…agents for 2, 6 and 24h",
      accession_code: "GSE116436",
      organism_names: […],
      sample_metadata: […],
      technology: "MICROARRAY"
    }
]

The formatExperiments function:

// formats the sample and experiment arrays from the API response
// to objects with experiment accession codes as their keys for UI
const formatExperiments = (experiments = []) => {
  if (!experiments.length) return {}

  return experiments.reduce(
    (acc, experiment) => ({
      ...acc,
      [experiment.accession_code]: experiment
    }),
    {}
  )
}

Problem or idea

We should remove formatExperiments from the codebase and adjust the formatting logic in the data presentation components to use dataset.experiments.

Additionally, we'll rename all variables that use the term species to organism (e.g., samplesBySpecies to samplesByOrganism) in the SpeciesView component as part of this process.

Solution or next step

  1. Remove the formatExperiments method from useDatasetManager
  2. Update the data presentation components to format dataset.experiments
  3. Rename variables that use the term species to organism in SpeciesView