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

Simplify test accounts #6221

Merged
merged 10 commits into from
Oct 7, 2021
Merged

Simplify test accounts #6221

merged 10 commits into from
Oct 7, 2021

Conversation

macobo
Copy link
Contributor

@macobo macobo commented Oct 4, 2021

This PR introduces the concept of "simplifying" filters. See #5877 for more detail

This is the first part of refactoring for #5854 - I'm planning on introducing "simplification" for cohort filters as well, but want to avoid excessive bloat.

Going forward, all controllers should pass team to filters on creation - we'll eventually make this mandatory as well.

How did you test this code?

Manual testing + existing code coverage

@timgl timgl temporarily deployed to posthog-pr-6221 October 4, 2021 07:05 Inactive
@macobo macobo force-pushed the simplify-test-accounts-2 branch from d6577bf to 21951cf Compare October 4, 2021 07:17
@macobo macobo temporarily deployed to posthog-pr-6221 October 4, 2021 07:17 Inactive
@macobo macobo force-pushed the simplify-test-accounts-2 branch from 21951cf to e507b54 Compare October 4, 2021 07:22
@macobo macobo temporarily deployed to posthog-pr-6221 October 4, 2021 07:22 Inactive
@macobo macobo temporarily deployed to posthog-pr-6221 October 4, 2021 07:30 Inactive
@macobo macobo force-pushed the simplify-test-accounts-2 branch from 1c59c90 to eee2132 Compare October 4, 2021 07:31
@macobo macobo temporarily deployed to posthog-pr-6221 October 4, 2021 07:31 Inactive
@macobo macobo force-pushed the simplify-test-accounts-2 branch from eee2132 to a899225 Compare October 4, 2021 07:39
@macobo macobo temporarily deployed to posthog-pr-6221 October 4, 2021 07:40 Inactive
@macobo macobo force-pushed the simplify-test-accounts-2 branch from 5119589 to dbfc99e Compare October 4, 2021 07:48
@macobo macobo temporarily deployed to posthog-pr-6221 October 4, 2021 07:48 Inactive
@macobo macobo force-pushed the simplify-test-accounts-2 branch from dbfc99e to 1ebd13d Compare October 4, 2021 07:49
@macobo macobo temporarily deployed to posthog-pr-6221 October 4, 2021 07:49 Inactive
@macobo macobo force-pushed the simplify-test-accounts-2 branch from 1ebd13d to 859a5b5 Compare October 4, 2021 08:41
@macobo macobo temporarily deployed to posthog-pr-6221 October 4, 2021 08:41 Inactive
@macobo macobo temporarily deployed to posthog-pr-6221 October 4, 2021 09:53 Inactive
@macobo macobo temporarily deployed to posthog-pr-6221 October 4, 2021 10:04 Inactive
@codecov-commenter
Copy link

codecov-commenter commented Oct 4, 2021

Codecov Report

❗ No coverage uploaded for pull request base (master@25163d0). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #6221   +/-   ##
=========================================
  Coverage          ?   91.76%           
=========================================
  Files             ?      392           
  Lines             ?    29561           
  Branches          ?     2500           
=========================================
  Hits              ?    27126           
  Misses            ?     1907           
  Partials          ?      528           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 25163d0...6fe0db3. Read the comment docs.

@macobo macobo marked this pull request as ready for review October 5, 2021 07:12
@macobo macobo force-pushed the simplify-test-accounts-2 branch from 6fe0db3 to f0dd66e Compare October 5, 2021 09:26
@macobo macobo temporarily deployed to posthog-pr-6221 October 5, 2021 09:27 Inactive
@macobo macobo force-pushed the simplify-test-accounts-2 branch from f0dd66e to ca1232b Compare October 6, 2021 10:25
@macobo macobo requested review from EDsCODE and neilkakkar October 6, 2021 10:25
@macobo macobo temporarily deployed to posthog-pr-6221 October 6, 2021 10:26 Inactive
@macobo macobo force-pushed the simplify-test-accounts-2 branch from ca1232b to d941d6c Compare October 7, 2021 06:17
@macobo macobo temporarily deployed to posthog-pr-6221 October 7, 2021 06:26 Inactive
@macobo macobo force-pushed the simplify-test-accounts-2 branch from 92bf70b to 0a495c3 Compare October 7, 2021 08:51
@macobo macobo temporarily deployed to posthog-pr-6221 October 7, 2021 08:51 Inactive
@macobo macobo mentioned this pull request Oct 7, 2021
)
result = ClickhouseTrends().run(filter, self.team,)
self.assertEqual(result[0]["count"], 1)
result = ClickhouseTrends().run(filter.with_data({"filter_test_accounts": "false"}), self.team,)
filter2 = Filter(
Copy link
Contributor

Choose a reason for hiding this comment

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

optional nit: This test is clearer if you run filter2 first, and then with_data({'filter_test_accounts': 'true'})

@@ -106,3 +108,7 @@ def __init__(

self._data = data
self.kwargs = kwargs

if "team" in kwargs and not self.is_simplified:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need to do this here when you're doing it in the BaseFilter? O.o

Ah, is it because this class overrides self._data ? Hmmmm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because BaseFilter init is not called here :)

@@ -0,0 +1,28 @@
from typing import TYPE_CHECKING, TypeVar

if TYPE_CHECKING: # Avoid circular import
Copy link
Contributor

Choose a reason for hiding this comment

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

when you already have the type in a quoted string, why do you need to do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So mypy actually checks those quoted strings so you need to import them for typechecking to occur 😅

Copy link
Contributor

@neilkakkar neilkakkar left a comment

Choose a reason for hiding this comment

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

Some minor comments, but otherwise looks good to me! Great work - really simplifies things around filter test accounts.

Copy link
Member

@EDsCODE EDsCODE left a comment

Choose a reason for hiding this comment

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

super helpful refactor. filter_test_accounts was weird to work with

@macobo macobo force-pushed the simplify-test-accounts-2 branch from 0a495c3 to 182837d Compare October 7, 2021 19:49
@macobo macobo temporarily deployed to posthog-pr-6221 October 7, 2021 19:50 Inactive
@macobo macobo merged commit ef7f31c into master Oct 7, 2021
@macobo macobo deleted the simplify-test-accounts-2 branch October 7, 2021 20:14
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.

5 participants