Skip to content

Commit

Permalink
fix(usage-reports): use startTime not start_time (#18737)
Browse files Browse the repository at this point in the history
* use startTime not start_time

* Update query snapshots

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
raquelmsmith and github-actions[bot] authored Nov 20, 2023
1 parent dd5be88 commit 3d3df11
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion posthog/tasks/test/__snapshots__/test_usage_report.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
FROM events
WHERE team_id = 2
AND event = 'external data sync job'
AND parseDateTimeBestEffort(JSONExtractString(properties, 'start_time')) BETWEEN '2022-01-10 00:00:00' AND '2022-01-10 23:59:59'
AND parseDateTimeBestEffort(JSONExtractString(properties, 'startTime')) BETWEEN '2022-01-10 00:00:00' AND '2022-01-10 23:59:59'
GROUP BY job_id,
team)
GROUP BY team
Expand Down
6 changes: 3 additions & 3 deletions posthog/tasks/test/test_usage_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ def test_external_data_rows_synced_response(
properties={
"count": 10,
"job_id": 10924,
"start_time": start_time,
"startTime": start_time,
},
timestamp=now() - relativedelta(hours=i),
team=self.analytics_team,
Expand All @@ -1029,7 +1029,7 @@ def test_external_data_rows_synced_response(
properties={
"count": 10,
"job_id": 10924,
"start_time": start_time,
"startTime": start_time,
},
timestamp=now() - relativedelta(hours=i, minutes=i),
team=self.analytics_team,
Expand All @@ -1042,7 +1042,7 @@ def test_external_data_rows_synced_response(
properties={
"count": 10,
"job_id": 10924,
"start_time": (now() - relativedelta(hours=i)).strftime("%Y-%m-%dT%H:%M:%SZ"),
"startTime": (now() - relativedelta(hours=i)).strftime("%Y-%m-%dT%H:%M:%SZ"),
},
timestamp=now() - relativedelta(hours=i),
team=self.analytics_team,
Expand Down
4 changes: 2 additions & 2 deletions posthog/tasks/usage_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
)

import requests
from retry import retry
import structlog
from dateutil import parser
from django.conf import settings
from django.db import connection
from django.db.models import Count, Q
from posthoganalytics.client import Client
from psycopg2 import sql
from retry import retry
from sentry_sdk import capture_exception

from posthog import version_requirement
Expand Down Expand Up @@ -604,7 +604,7 @@ def get_teams_with_rows_synced_in_period(begin: datetime, end: datetime) -> List
SELECT team, sum(rows_synced) FROM (
SELECT JSONExtractString(properties, 'job_id') AS job_id, distinct_id AS team, any(JSONExtractInt(properties, 'count')) AS rows_synced
FROM events
WHERE team_id = %(team_to_query)s AND event = 'external data sync job' AND parseDateTimeBestEffort(JSONExtractString(properties, 'start_time')) BETWEEN %(begin)s AND %(end)s
WHERE team_id = %(team_to_query)s AND event = 'external data sync job' AND parseDateTimeBestEffort(JSONExtractString(properties, 'startTime')) BETWEEN %(begin)s AND %(end)s
GROUP BY job_id, team
)
GROUP BY team
Expand Down

0 comments on commit 3d3df11

Please sign in to comment.