Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upHide scatterplot for large schools #2362
Conversation
edavidsonsawyer
added some commits
Jan 21, 2019
This comment has been minimized.
This comment has been minimized.
@kevinrobinson here's the simpler version of disabling the scatter plot for large schools. I'm not sure what's up with the build error so I'll try to look into that later on today. |
edavidsonsawyer
closed this
Jan 22, 2019
edavidsonsawyer
reopened this
Jan 22, 2019
kevinrobinson
reviewed
Jan 22, 2019
const el = testEl(props); | ||
const dash = mount(elWrappedInContext(el, context)); | ||
expect(dash.find('DisciplineScatterPlot').length > 0).toEqual(true); | ||
}); | ||
|
||
it('does not render a scatter plot when there are more than 500 incidents', () => { |
This comment has been minimized.
This comment has been minimized.
this.setState({selectedChart: 'incident_location', scatterPlotAvailable: false}); | ||
} | ||
} | ||
|
This comment has been minimized.
This comment has been minimized.
kevinrobinson
Jan 22, 2019
Contributor
Can you say more about why this is here, rather than computed in render
? I don't follow why it's using the lifecycle hook.
This comment has been minimized.
This comment has been minimized.
edavidsonsawyer
Jan 22, 2019
Author
Collaborator
It's here because the state has to change (from default scatter to some alternative), which can't be done in render. I could probably set the initial state conditionally in the constructor, but it seemed cleaner to just use getIncidentsFromStudents in the mounted component. It shouldn't be much of a performance issue since we cache the result of that function with memoizer.
This comment has been minimized.
This comment has been minimized.
kevinrobinson
Jan 22, 2019
•
Contributor
ah, thanks! Got it, it's because this is set in initialState
in the constructor, that's super helpful. Using the lifecycle hook implies that it's because of something related to the DOM or outside of React, and then leads to double-rendering on load.
Yeah, the better way to do this is describe this explicitly in the constructor, and then let initialState
decide what selectedChart
should be based on those props. Here that would involve factoring out the incident and filtering functions to be plain functions (rather than relying on this.state
and this.props
) and that seems a larger change than this is worth.
So if you tested this and it works without a visible jump, let me know and let's
This comment has been minimized.
This comment has been minimized.
edavidsonsawyer
Jan 22, 2019
Author
Collaborator
Great! I have tested this locally with schools above and below the 500 student threshold, and in the former case the scatter plot is cleanly removed. I would like to double check in production just to be sure the threshold is appropriate, but that can probably come from feedback from users.
This comment has been minimized.
This comment has been minimized.
kevinrobinson
Jan 22, 2019
Contributor
@edavidsonsawyer awesome, thanks!
kevinrobinson
merged commit 90e396e
into
studentinsights:master
Jan 22, 2019
1 check passed
This comment has been minimized.
This comment has been minimized.
@edavidsonsawyer looks good! |
edavidsonsawyer commentedJan 21, 2019
•
edited
Who is this PR for?
Educators
What problem does this PR fix?
For large schools, the scatterplot in the discipline dashboard has too many datapoints to show useful information.
What does this PR do?
Removes the scatterplot feature when there are more than 500 discipline incidents to display when first loading
Checklists
Which features or pages does this PR touch?
Does this PR use tests to help verify we can deploy these changes quickly and confidently?