feat(website): Cumulative graph of submission on groups page#5839
feat(website): Cumulative graph of submission on groups page#5839theosanderson wants to merge 3 commits intomainfrom
Conversation
|
I guess we could just notshow the graph is |
|
Claude finished @theosanderson's task in 1m 49s —— View job Code Review CompleteI've reviewed the PR and provided inline comments on specific issues. Here's my overall assessment: SummaryThis PR adds a cumulative submissions chart to the group page, controlled by a new config option Key FindingsArchitecture & Design:
Code Quality Issues:
Testing:
Documentation:
RecommendationsHigh Priority:
Medium Priority: Low Priority: Security & Performance
Response to anna-parker's commentRegarding the suggestion to hide the graph when
The PR looks good overall and is ready for merge after addressing the high-priority items. |
|
|
||
| useEffect(() => { | ||
| ChartJS.register(CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend); | ||
| setIsRegistered(true); |
There was a problem hiding this comment.
The Chart.js registration should not be done in a component using useEffect. This violates React best practices and can cause issues:
- Chart.js plugins are global and should be registered once at module level
- Using state (
isRegistered) to conditionally render based on registration is unnecessary - Multiple component instances would try to register the same plugins multiple times
Recommendation: Move registration to module level:
// At the top of the file, outside the component
ChartJS.register(CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend);Then remove the isRegistered state and the useEffect entirely (lines 36-41 and 85-87).
|
|
||
| return { | ||
| labels: sortedDates, | ||
| datasets: datasets.filter((ds) => ds.data[ds.data.length - 1] > 0), |
There was a problem hiding this comment.
This filter removes organisms with zero cumulative submissions, but only checks the final data point. Consider these edge cases:
- An organism with submissions that were all revoked would still show as a line at 0
- The check
> 0could be!== 0for consistency (though functionally equivalent)
Recommendation: Add a comment explaining the intent:
// Only show organisms that have at least one submission
datasets: datasets.filter((ds) => ds.data[ds.data.length - 1] > 0),|
|
||
| const { data: timeSeriesData, isLoading: timeSeriesLoading } = useQuery({ | ||
| queryKey: ['group-time-series', groupId, clientConfig, organisms, metadataItemForCumulativeGroupGraph], | ||
| queryFn: () => fetchTimeSeriesData(groupId, clientConfig, organisms, metadataItemForCumulativeGroupGraph!), |
There was a problem hiding this comment.
The query will execute even when metadataItemForCumulativeGroupGraph is null, which could cause issues:
- The non-null assertion (
metadataItemForCumulativeGroupGraph!) on line 76 is unsafe - TypeScript will assume it's non-null but it could still be null - If someone changes the
enabledcondition, the query function could be called withnull
Recommendation: Make the queryFn handle the null case explicitly:
queryFn: () => {
if (metadataItemForCumulativeGroupGraph === null) {
return Promise.resolve({});
}
return fetchTimeSeriesData(groupId, clientConfig, organisms, metadataItemForCumulativeGroupGraph);
},| "group": "general", | ||
| "type": ["string", "null"], | ||
| "default": null, | ||
| "description": "The metadata field used to plot cumulative submissions over time on the group page. Set to null to disable the chart." |
There was a problem hiding this comment.
The description could be more specific about the expected metadata field characteristics:
- Should mention that the field should be a date field (though technically any field could work)
- Could clarify what happens when set to
nullvs an invalid field name - The relationship to
earliestReleaseDateconfiguration could be mentioned
Recommendation: Enhance the description:
"description": "The metadata field used to plot cumulative submissions over time on the group page (typically 'earliestReleaseDate' or another date field). Set to null to disable the chart. If the specified field does not exist for an organism, the chart will show no data for that organism."|
I found this on slack again and just didn't want it to be forgotten 😆 |
feat(website): Add cumulative submissions chart to group page
Adds a line chart showing cumulative submissions over time on the group page, with each organism as its own series.
Changes
metadataItemForCumulativeGroupGraphto control which metadata field is used for the x-axis (e.g.earliestReleaseDate)null(chart hidden), set toearliestReleaseDatefor preview serverCumulativeSubmissionsChartcomponent in its own fileFiles changed
Kubernetes config:
values.schema.json- Added schema for new config optionvalues.yaml- Default value (null)values_preview_server.yaml- Set toearliestReleaseDatetemplates/_common-metadata.tpl- Pass config to websiteWebsite:
src/types/config.ts- Added type for new config fieldsrc/components/User/CumulativeSubmissionsChart.tsx- New chart componentsrc/components/User/GroupPage.tsx- Fetch time series data and render chartsrc/pages/group/[groupId]/index.astro- Pass config prop🚀 Preview: Add
previewlabel to enable