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(surveys): fix nps score decimal #18237

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions frontend/src/scenes/surveys/SurveyView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { surveyLogic } from './surveyLogic'
import { surveysLogic } from './surveysLogic'
import { PageHeader } from 'lib/components/PageHeader'
import { SurveyReleaseSummary } from './Survey'
import { ChartDisplayType, PropertyFilterType, PropertyOperator, Survey, SurveyQuestionType, SurveyType } from '~/types'
import { PropertyFilterType, PropertyOperator, Survey, SurveyQuestionType, SurveyType } from '~/types'
import { SurveyAPIEditor } from './SurveyAPIEditor'
import { NodeKind } from '~/queries/schema'
import { dayjs } from 'lib/dayjs'
Expand Down Expand Up @@ -271,6 +271,7 @@ export function SurveyResult({ disableEventsTable }: { disableEventsTable?: bool
<div className="text-4xl font-bold">{surveyNPSScore}</div>
<div className="font-semibold text-muted-alt mb-2">Total NPS Score</div>
{featureFlags[FEATURE_FLAGS.SURVEYS_RESULTS_VISUALIZATIONS] && (
// TODO: rework this to show nps scores over time
<SurveyNPSResults survey={survey as Survey} />
)}
</>
Expand Down Expand Up @@ -383,7 +384,6 @@ function SurveyNPSResults({ survey }: { survey: Survey }): JSX.Element {
],
trendsFilter: {
formula: '(A / (A+B+C) * 100) - (C / (A+B+C)* 100)',
display: ChartDisplayType.ActionsLineGraphCumulative,
},
},
}}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/surveys/surveyLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ export const surveyLogic = kea<surveyLogicType>([
const passives = questionResults.slice(7, 9).reduce((a, b) => a + b, 0)
const detractors = questionResults.slice(0, 7).reduce((a, b) => a + b, 0)
const npsScore = ((promoters - detractors) / (promoters + passives + detractors)) * 100
return npsScore
return npsScore.toFixed(1)
}
}
},
Expand Down