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(insights): use exclude_none flag for cleaner queries #24546

Merged
merged 2 commits into from
Aug 23, 2024

Conversation

thmsobrmlr
Copy link
Contributor

Problem

Changes

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

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

How did you test this code?

@posthog-bot
Copy link
Contributor

Hey @thmsobrmlr! 👋
This pull request seems to contain no description. Please add useful context, rationale, and/or any other information that will help make sense of this change now and in the distant Mars-based future.

return {"kind": "InsightVizNode", "source": filter_to_query(self.filters).model_dump(), "full": True}
return {
"kind": "InsightVizNode",
"source": filter_to_query(self.filters).model_dump(exclude_unset=True, exclude_none=True),
Copy link
Contributor

Choose a reason for hiding this comment

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

I've noticed that the exclude_unset also removes the kind property and other set-by-default properties from the source. For example, this query:

{'full': True, 'kind': 'DataTableNode', 'source': {'kind': 'ActorsQuery', 'properties': [{'key': 'id', 'type': 'cohort', 'value': 4669}]}}

Becomes:

{'full': True, 'kind': 'DataTableNode', 'source': {'properties': [{'key': 'id', 'value': 4669}]}}

I think we want to keep those properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yeah definitely. Don't know why I commited with this setting. Good catch!

@thmsobrmlr thmsobrmlr merged commit c25b571 into master Aug 23, 2024
86 checks passed
@thmsobrmlr thmsobrmlr deleted the cleaner-queries branch August 23, 2024 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants