AlexsLemonade / refinebio-web

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

Add getDatasetFrom helper to useDatasetManager #385

Open nozomione opened 3 weeks ago

nozomione commented 3 weeks ago

Context

Epic: #358

In the dataset route, we render the UI based on the dataset lifecycle states which include unprocessed, processing, processed (unexpired or expired), and processing error.

If the dataset state is processed but expired, we provide users options to regenerate it.

renegerate-dataset

In the FileSummary component, we have a local state regeneratedDataset that stores the reference to that expired dataset. This allows us to re-render the appropriate UI when users change dataset download options before regenerating that dataset.

// sets expired processed dataset as regeneratedDataset
    if (isReadyExpired) setRegeneratedDataset(dataset)

Instead of storing the reference of the expired dataset, we want to make a copy of the dataset reference and selectively copy only the necessary fields.

e.g., The required fields:

data: { GSE73927: […] }
aggregate_by: "SPECIES"
scale_by: "MINMAX"
quantile_normalize: true

Problem or idea

To achieve this, we should add a new helper getDatasetFrom to the useDatasetManager hook. This method will handle the copying and extraction of the relevant fields from the expired dataset object, which will be used when setting the value of setRegeneratedDataset as follows:

setRegeneratedDataset(getDatasetFrom(dataset))

Solution or next step