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

fix: prevent generation of charts if number of responses exceed limit #6937

Merged
merged 8 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useLocation } from 'react-router-dom'
import { Box, Container, Divider, Stack } from '@chakra-ui/react'
import { useFeatureValue } from '@growthbook/growthbook-react'

import { FormResponseMode } from '~shared/types/form'

Expand All @@ -21,7 +22,7 @@ export const ChartsPage = (): JSX.Element => {
const { data: form, isLoading } = useAdminForm()
const { totalResponsesCount, secretKey } = useStorageResponsesContext()
const { pathname } = useLocation()

const chartsMaxResponseCount = useFeatureValue('chartsMaxResponseCount', 100) // limit number of responses to 100 as fallback
const toast = useToast({ status: 'danger' })

if (isLoading) return <ResponsesPageSkeleton />
Expand Down Expand Up @@ -53,7 +54,9 @@ export const ChartsPage = (): JSX.Element => {
return <></>
}

if (totalResponsesCount === 0) {
const responseCount = totalResponsesCount || 0

if (responseCount === 0) {
return (
<EmptyChartsContainer
title="No charts generated yet."
Expand All @@ -62,6 +65,15 @@ export const ChartsPage = (): JSX.Element => {
)
}

if (responseCount > chartsMaxResponseCount) {
return (
<EmptyChartsContainer
title="No charts generated"
subtitle="The number of form submissions has exceeded the capacity allowed by Charts beta."
/>
)
}

return secretKey ? (
<UnlockedCharts />
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,6 @@ export const UnlockedChartsContainer = () => {
</Text>
{prettifiedResponsesCount}
</Text>
<Text textStyle="body-2" color="secondary.400">
{filteredDecryptedData.length > 1000
? 'Charts are generated based on the latest 1,000 responses.'
: null}
</Text>
</Flex>
<DateRangePicker
value={dateRangePickerHelper.dateStringToDatePickerValue(dateRange)}
Expand Down
Loading