Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsobrmlr committed Mar 20, 2024
1 parent 4f26595 commit e15842d
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions posthog/management/commands/compare_hogql_funnel_insights.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class Command(BaseCommand):
help = "Test if HogQL insights match their legacy counterparts"

def handle(self, *args, **options):

IGNORED_INSIGHTS = []

Check failure on line 34 in posthog/management/commands/compare_hogql_funnel_insights.py

View workflow job for this annotation

GitHub Actions / Python code quality checks

Need type annotation for "IGNORED_INSIGHTS" (hint: "IGNORED_INSIGHTS: List[<type>] = ...")

Check failure on line 34 in posthog/management/commands/compare_hogql_funnel_insights.py

View workflow job for this annotation

GitHub Actions / Python code quality checks

Need type annotation for "IGNORED_INSIGHTS" (hint: "IGNORED_INSIGHTS: List[<type>] = ...")

insights = (
Expand All @@ -48,7 +47,8 @@ def handle(self, *args, **options):
## breakdowns
# & Q(filters__breakdown__isnull=True) # without breakdown
# & Q(short_id="v1trHpS3"),
& ~Q(short_id__in=IGNORED_INSIGHTS) & Q(team_id=1),
& ~Q(short_id__in=IGNORED_INSIGHTS)
& Q(team_id=2),
saved=True,
deleted=False,
)
Expand All @@ -70,6 +70,10 @@ def handle(self, *args, **options):
funnel_viz_type = filter.funnel_viz_type or FunnelVizType.STEPS
print(f"\t{funnel_order_type} {funnel_viz_type}")

all_ok = True
hogql_time = 0
legacy_time = 0

try:
now = datetime.now()
funnel_class = get_legacy_class(filter)
Expand All @@ -78,7 +82,6 @@ def handle(self, *args, **options):
except ValidationError as e:
legacy_error = e
except Exception as e:
url = f"{BASE_URL}/insights/{insight.short_id}/edit"
print(f"LEGACY Insight ERROR: {e}")
continue

Expand All @@ -94,12 +97,9 @@ def handle(self, *args, **options):
continue
hogql_error = e
except Exception as e:
url = f"{BASE_URL}/insights/{insight.short_id}/edit"
print(f"HogQL Insight ERROR: {e}")
continue

all_ok = True

if legacy_error is not None:
if hogql_error is None:
print(
Expand Down Expand Up @@ -180,12 +180,13 @@ def handle(self, *args, **options):
all_ok = False

if all_ok:
diff = hogql_time - legacy_time
percentage = hogql_time / legacy_time
significant = percentage > 1.1 and diff > 1
warn = ""
if significant:
warn = "-- /!\\ {:.1%} /!\\".format(percentage)
if hogql_time != 0 and legacy_time != 0:
diff = hogql_time - legacy_time
percentage = hogql_time / legacy_time
significant = percentage > 1.1 and diff > 1
if significant:
warn = "-- /!\\ {:.1%} /!\\".format(percentage)
print(f"\tLegacy time: {legacy_time} HogQL time: {hogql_time} {warn}")
print("ALL OK!")

Expand Down

0 comments on commit e15842d

Please sign in to comment.