-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HOTFIX] Rename metadata tracks #776
Conversation
Codecov Report
@@ Coverage Diff @@
## master #776 +/- ##
==========================================
+ Coverage 83.69% 83.74% +0.04%
==========================================
Files 467 468 +1
Lines 7910 7922 +12
Branches 1525 1526 +1
==========================================
+ Hits 6620 6634 +14
+ Misses 1238 1236 -2
Partials 52 52
|
📦 Next.js Bundle AnalysisThis analysis was generated by the next.js bundle analysis action 🤖
|
Page | Size (compressed) |
---|---|
global |
521.92 KB (🟡 +53 B) |
Details
The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.
Any third party scripts you have added directly to your app using the <script>
tag are not accounted for in this analysis
If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!
One Page Changed Size
The following page changed size from the code in this PR compared to its base branch:
Page | Size (compressed) | First Load |
---|---|---|
/data-management |
246.43 KB (🟡 +15 B) |
768.35 KB |
Details
Only the gzipped size is provided here based on an expert tip.
First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link
is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.
Any third party scripts you have added directly to your app using the <script>
tag are not accounted for in this analysis
Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.
…e the position of the renamed track
… be loaded before initializin the metadata columns
const samplesLoaded = activeExperiment?.sampleIds.every((sampleId) => samples[sampleId]); | ||
|
||
if (activeExperiment?.sampleIds.length > 0 && samplesLoaded) { | ||
// if there are samples - build the table columns | ||
setSampleNames(new Set(activeExperiment.sampleIds.map((id) => samples[id]?.name.trim()))); | ||
|
||
const sanitizedSampleNames = new Set( | ||
activeExperiment.sampleIds.map((id) => samples[id]?.name.trim()), | ||
); | ||
|
||
setSampleNames(sanitizedSampleNames); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't load the samples immediately as soon as we start, so I added some checks that the samples are loaded first before going through with rendering
|
||
experiment.sampleIds.forEach((sampleUuid) => { | ||
dispatch({ | ||
type: SAMPLES_UPDATE, | ||
payload: { | ||
sampleUuid, | ||
sample: { metadata: { [newMetadataKey]: samples[sampleUuid].metadata[oldMetadataKey] } }, | ||
}, | ||
}); | ||
|
||
dispatch({ | ||
type: SAMPLES_METADATA_DELETE, | ||
payload: { | ||
metadataKey: oldMetadataKey, | ||
sampleUuid, | ||
}, | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the real issue was here (the rest of the changes was me refactoring), if a user adds a space after the metadata name it would not notice that the name had changed (trailing spaces are removed) so what happened here was the following:
- User has a metadata track "Track 1"
- User sets new name "Track 1 ":
The trailing space is removed so this means that:
oldMetadataKey = 'Track 1'
newMetadataKey = 'Track 1'
SAMPLES_UPDATE
: Setssample.metadata['Track 1'] = sample.metadata['Track 1']
SAMPLES_METADATA_DELETE
: Deletessample.metadata['Track 1']
So we ended up with a sample with an undefined value for the renamed metadata track, this would cause crashes when there was any further interaction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where the fix happens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really interesting and obscure bug
sampleIdsFromExperiment.forEach((sampleId) => { | ||
const value = draft[sampleId].metadata[oldKey]; | ||
|
||
delete draft[sampleId].metadata[oldKey]; | ||
|
||
draft[sampleId].metadata[newKey] = value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix for the bug is here:
We store the value in a temporary variable, delete the oldKey
and then set the newKey
, this ensures it will work even if oldKey === newKey
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just if "oldKey" == "newKey", do not update?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seemed safer to implement a simple solution that covers all cases rather than having a guard for the case where it breaks and then have the rest of the solution
const experimentsMetadataRename = (state, action) => { | ||
const { oldKey, newKey, experimentId } = action.payload; | ||
|
||
const { metadataKeys } = state[experimentId]; | ||
const newMetadataKeys = metadataKeys.map((metadataKey) => ( | ||
metadataKey === oldKey ? newKey : metadataKey | ||
)); | ||
|
||
return { | ||
...state, | ||
[experimentId]: { | ||
...state[experimentId], | ||
metadataKeys: newMetadataKeys, | ||
}, | ||
}; | ||
}; | ||
|
||
export default experimentsMetadataRename; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a rename of experimentsMetadataUpdate
, one extra thing I did here is deal with the annoying thing where if we renamed a metadata track key, it would push the renamed key to the end.
Look at src/redux/reducers/experiments/experimentsMetadataUpdate.js to see what was changed
Description
Details
URL to issue
N/A
Link to staging deployment URL (or set N/A)
https://ui-martinfosco-ui776.scp-staging.biomage.net/
Links to any PRs or resources related to this PR
Integration test branch
master
Merge checklist
Your changes will be ready for merging after all of the steps below have been completed.
Code updates
Have best practices and ongoing refactors being observed in this PR
Manual/unit testing
Integration testing
You must check the box below to run integration tests on the latest commit on your PR branch.
Integration tests have to pass before the PR can be merged. Without checking the box, your PR
will not pass the required status checks for merging.
Documentation updates
Optional