Skip to content
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

Narratives bug #736

Merged
merged 9 commits into from
Jul 9, 2019
Merged

Narratives bug #736

merged 9 commits into from
Jul 9, 2019

Conversation

kairstenfay
Copy link
Contributor

This fixes the bugs described in #722 and #731 (and maybe others?)

The last couple of commits are a WIP that need refactoring, but I won't have time to get back to it for a few weeks.

It represents a joint effort between @joverlee521, @jameshadfield and me.

kairstenfay and others added 9 commits July 9, 2019 14:37
Because the `updateOnMoveEnd` function only runs
code inside the conditional `if (d3elems) {}`, refactor
to create a `if (!d3elems) {}` guard statements and
unindent the code within the function.
In `maybeUpdateDemesAndTransmissions()`, the
variable `haveData` was not always a boolean as
was seemingly intended by its naming and usage.
Change one of the values in its declaration to
evaluate to a boolean by prefixing `!!`. 

Now `!!nextProps.nodeColors` evaluates to `true`
or `false` instead of a list or `false`.
Previously, in the function `maybeUpdateDemesAndTransmissions()` (part
of the Map component), there was a large, indented code block inside of
a conditional checking for truthiness in `colorOrVisibilityChange &&
haveData`. Because changes only occurred if this conditional was true,
refactor it so that the conditional is now a guard statement. If the
conditional evaluates to false, exit the function. Now the bulk of the
code is not indented.
Reduce the level of indendation of the bulk of the code in the function
`setupTransmissionData` by refactoring two of the conditional checks
into guard statements.

This change reduces the cognitive load required to read and understand
this function.
Refactor the function `setupDemeData` for better readability by
reducing the level of indentation of the code. This commit converts two
conditional checks into guard statements that exit the `forEach` loop
if each condition is not met.

Also removes an explicit `boolean === true` check in favor of `boolean`.
Shorten a conditional by casting the string to lower case.
Refactor the `updateTransmissionDataColAndVis` function to reduce the
level of indendation of the code. Convert the conditional checks to
guard statements that exist the `forEach` loop if the condition is not
met.
Logs an error in the function `updateVisibility' if
`d3elems` is undefined.

Co-authored-by: James Hadfield <jhadfiel@fredhutch.org>
Previously, when the geo resolution would change,
`drawDemesAndTransmissions` would not
necessarily be called, often causing data on the map
to not load at all between queries.

James also did some work here to correct the deme
and transmission data that were being loaded on
each narrative page change.

This commit further complicates the map code, but is
necessary to fix this bug. It is a prime candidate
for refactoring in #735

Co-authored-by: James Hadfield <jh22@sanger.ac.uk>
Co-authored-by: Jover Lee <joverlee521@gmail.com>
@jameshadfield
Copy link
Member

Thanks @kairstenfay and @joverlee521 🎉

I've cherry-picked the commits onto master so that we can release this as a v1 release -- the only thing that really changed was the way traits are accessed on nodes (v1: n.attr[geoResolution], v2: getTraitFromNode(n, geoResolution)).

@jameshadfield jameshadfield merged commit 6a6fce5 into master Jul 9, 2019
@jameshadfield jameshadfield deleted the narratives_bug branch July 9, 2019 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants