Skip to content

Commit

Permalink
fix(surveys): fix nps score decimal (#18237)
Browse files Browse the repository at this point in the history
* fixed decimal

* fix
  • Loading branch information
liyiy authored Oct 27, 2023
1 parent 51f256e commit f393cc7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
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

0 comments on commit f393cc7

Please sign in to comment.