Skip to content

feat: Use dot notation for revenue views #31016

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

Merged
merged 2 commits into from
Apr 11, 2025

Conversation

rafaeelaudibert
Copy link
Member

Following https://github.com/PostHog/posthog/pull/30947/files let's also make the revenue views use dot notation. This will make them fit slightly better.

Following https://github.com/PostHog/posthog/pull/30947/files let's also
make the revenue views use dot notation. This will make them fit
slightly better.
@rafaeelaudibert rafaeelaudibert added the feature/revenue-analytics Team Revenue Analytics label Apr 9, 2025
@rafaeelaudibert rafaeelaudibert requested review from Gilbert09 and a team April 9, 2025 17:48
Comment on lines 197 to 201
if source.prefix is None:
name = f"stripe.revenue_view"
else:
prefix = source.prefix.strip("_")
name = f"stripe.{prefix}.revenue_view"
Copy link
Member Author

Choose a reason for hiding this comment

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

It's always stripe for now, so I don't mind hardcoding this, will eventually need to make this a little bit more dynamic

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

Overall, the PR updates revenue view naming to adopt dot notation consistently across the codebase, affecting data source prefixes, query construction, and view assignment logic.

  • Modified /products/revenue_analytics/backend/models.py to generate RevenueAnalyticsRevenueView names with dot notation, noting a potential double dot if source.prefix is empty.
  • Updated /posthog/hogql/database/database.py to use the view’s name attribute for revenue view assignment instead of concatenating strings.
  • Changed /products/revenue_analytics/backend/hogql_queries/revenue_example_data_warehouse_tables_query_runner.py to build queries with unqualified field references aligning with dot notation.
  • Adjusted prefix settings in /posthog/warehouse/test/utils.py to remove an underscore suffix.

4 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines 197 to 201
if source.prefix is None:
name = f"stripe.revenue_view"
else:
prefix = source.prefix.strip("_")
name = f"stripe.{prefix}.revenue_view"
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Empty prefix ("") will lead to 'stripe..revenue_view'. Consider checking for falsy values instead of 'is None'.

Suggested change
if source.prefix is None:
name = f"stripe.revenue_view"
else:
prefix = source.prefix.strip("_")
name = f"stripe.{prefix}.revenue_view"
if not source.prefix:
name = f"stripe.revenue_view"
else:
prefix = source.prefix.strip("_")
name = f"stripe.{prefix}.revenue_view"

Copy link
Member

Choose a reason for hiding this comment

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

This is needed - prefix can be ""

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, nice, fixed it + added some tests
e7dedd7

Copy link
Member

@Gilbert09 Gilbert09 left a comment

Choose a reason for hiding this comment

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

The greptile comment is legit btw

Comment on lines 197 to 201
if source.prefix is None:
name = f"stripe.revenue_view"
else:
prefix = source.prefix.strip("_")
name = f"stripe.{prefix}.revenue_view"
Copy link
Member

Choose a reason for hiding this comment

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

This is needed - prefix can be ""

Added some tests to prove it works
@rafaeelaudibert rafaeelaudibert enabled auto-merge (squash) April 11, 2025 02:40
@rafaeelaudibert rafaeelaudibert merged commit f0a2dc0 into master Apr 11, 2025
108 of 109 checks passed
@rafaeelaudibert rafaeelaudibert deleted the use-dot-notation-for-revenue-views branch April 11, 2025 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/revenue-analytics Team Revenue Analytics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants