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: separate filters for surveys logic #28570

Merged
merged 12 commits into from
Feb 12, 2025

Conversation

lucasheriques
Copy link
Contributor

@lucasheriques lucasheriques commented Feb 11, 2025

Problem

Closes #27729

Filters were only being applied to the DataTableQuery on the SurveyResults page.

Now they're applied to all survey visualizations.

Changes

Loom demo

Store the PropertyFilter values inside surveyLogic.

Pass it down to the other queries as well.

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

Yes

How did you test this code?

Unit tests with the logic filters

Manual tests to see if filters are working for all charts

@lucasheriques lucasheriques requested a review from a team February 11, 2025 21:59
@lucasheriques lucasheriques self-assigned this Feb 11, 2025
Copy link
Contributor

github-actions bot commented Feb 11, 2025

Size Change: -47 B (0%)

Total Size: 1.18 MB

ℹ️ View Unchanged
Filename Size Change
frontend/dist/toolbar.js 1.18 MB -47 B (0%)

compressed-size-action

@lucasheriques lucasheriques marked this pull request as ready for review February 12, 2025 02:36
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR addresses a bug where survey result filters were only being applied to the data table and not to the visualization charts. Here's a concise summary of the key changes:

  • Added property filter state management in surveyLogic.tsx to centrally control filtering across all survey visualizations
  • Integrated SurveyResultsFilters component in SurveyView.tsx to provide a unified filtering interface
  • Added comprehensive test coverage in surveyLogic.test.ts to validate filter behavior across different survey visualization types
  • Modified HogQL queries to properly incorporate property filters in all survey metric calculations
  • Implemented filter state persistence to maintain consistency when reloading survey data

Key points:

  • Added propertyFilters state and actions in surveyLogic.tsx to manage filters centrally
  • Created new SurveyResultsFilters component that integrates with existing PropertyFilters UI
  • Added test cases to verify filter application across multiple visualization types
  • Ensured survey ID property is preserved when applying new filters

3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

// Reload all survey data when filters change
if (values.survey.questions) {
values.survey.questions.forEach((question, index) => {
if (question.type === SurveyQuestionType.Rating) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think a switch here would make the code more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree, will fix that on #28466, which is the PR on top of this, as this logic already changed a little bit

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Base automatically changed from fix/make-spacing-consistent-on-survey-results to master February 12, 2025 14:21
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@lucasheriques lucasheriques merged commit 21540f7 into master Feb 12, 2025
103 checks passed
@lucasheriques lucasheriques deleted the fix/separate-filters-for-survey-logic branch February 12, 2025 15:45
zlwaterfield pushed a commit that referenced this pull request Feb 13, 2025
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When filtering survey responses, the charts are not updated
3 participants