Skip to content

Commit

Permalink
fix link avatar+email, only show relevant legend items
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajmajerik committed Oct 19, 2023
1 parent e6ac8ab commit 39e7d7a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
11 changes: 9 additions & 2 deletions frontend/src/scenes/surveys/surveyLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export const surveyLogic = kea<surveyLogicType>([
const query: HogQLQuery = {
kind: NodeKind.HogQLQuery,
query: `
SELECT properties, distinct_id
SELECT distinct_id, properties, person.properties
FROM events
WHERE event == 'survey sent'
AND properties.$survey_id == '${survey.id}'
Expand All @@ -383,7 +383,14 @@ export const surveyLogic = kea<surveyLogicType>([
const responseJSON = await api.query(query)
const { results } = responseJSON

const events = results?.map((r) => ({ properties: JSON.parse(r[0]), distinct_id: r[1] }))
const events =
results?.map((r) => {
const distinct_id = r[0]
const properties = JSON.parse(r[1])
const personProperties = JSON.parse(r[2])
properties.email = personProperties.email
return { distinct_id, properties }
}) || []

return { ...values.surveyRatingResults, [questionIndex]: { events } }
},
Expand Down
21 changes: 12 additions & 9 deletions frontend/src/scenes/surveys/surveyViewViz.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,18 @@ export function UsersStackedBar({ surveyUserStats }: { surveyUserStats: SurveyUs
{ count: seen, label: 'Viewed', style: { backgroundColor: '#1D4AFF' } },
{ count: dismissed, label: 'Dismissed', style: { backgroundColor: '#E3A506' } },
{ count: sent, label: 'Submitted', style: { backgroundColor: '#529B08' } },
].map(({ count, label, style }) => (
<div key={`survey-summary-legend-${label}`} className="flex items-center mr-6">
<div className="w-3 h-3 rounded-full mr-2" style={style} />
<span className="font-semibold text-muted-alt">{`${label} (${(
(count / total) *
100
).toFixed(1)}%)`}</span>
</div>
))}
].map(
({ count, label, style }) =>
count > 0 && (
<div key={`survey-summary-legend-${label}`} className="flex items-center mr-6">
<div className="w-3 h-3 rounded-full mr-2" style={style} />
<span className="font-semibold text-muted-alt">{`${label} (${(
(count / total) *
100
).toFixed(1)}%)`}</span>
</div>
)
)}
</div>
</div>
</div>
Expand Down

0 comments on commit 39e7d7a

Please sign in to comment.