Closed nozomione closed 1 year ago
🗒️ Based on the 1:1 @davidsmejia, we should fetch datasets with the query string details: true
by default (reason: future BE API revision is being taken into account). For this reason, we deleted getDatasetDetails
and we also removed the details
parameter from the rest of the methods.
Context
This is a rewrite of the original issue: https://github.com/AlexsLemonade/refinebio-web/issues/101
As with the existing refine.bio, we want to be able to manage users' datasets when they use the application.
Problem or idea
Using the context API, we'll create a dataset manager context
DatasetManagerContext
and implement its hookuseDatasetManager
which manages a user's dataset and keeps it in sync with the API.The general strategy should be to have a manager that;
❚ State Management
Context State
The
DatasetManagerContext
inherits the following states from the global contextRefinebioContext
that are shared across the application.dataset
: (object) the latest user-created dataset state retrieved from the APIsetDataset
: an async method for settingdataset
datasetId
: (uuid) a user-created dataset ID retrieved from the API at creationsetDatasetId
: an async method for settingdatasetId
downloadOptions
: (object) a user-selected download options for a file downloadsetDownloadOptions
: an async method for settingdownloadOptions
email
: (string) a user's provided email address entered in the email form for a file downloadtoken
: (uuid) a user's token required for a file downloadHook State
error
: (object) an object that stores an error object (e.g., network)setError
: an async method for settingerror
loading
: (boolean) the loading indicator for the dataset datasetLoading
: an async method for settingloading
❚ Method
The
useDatasetManager
hook contains the helper methods that are primarily used in the UI and each one corresponds to a specific application behavior.Following are the implementation details and pseudocode (parameters marked with * are required):
Dataset
async createDataset(setCurrentDatasetId = false) return dataset Id
async getDataset(id) return dataset
async clearDataset(id) return dataset
async updateDataset(id*, params*) return dataset
Experiment
getTotalExperiments(data*) return number
formatExperiments() return object
async removeExperiment(experimentAccessionCode*) return dataset
Samples
async addSamples(samplesToAdd*) return dataset
formatSampleMetadata(metadata*) return array
getTotalSamples(data*) return number
async removeSamples(samplesToRemove*) return dataset
async replaceSamples(samplesToReplace*) return dataset
Example: To fetch the latest dataset state:
Solution or next step
Based on the above requirements, implement the dataset context manager and its hook.