Skip to content

Commit

Permalink
chore(data-warehouse): make sure counts are updated at end of import (#…
Browse files Browse the repository at this point in the history
…20223)

make sure counts are updated at end of import
  • Loading branch information
EDsCODE authored and Bianca Yang committed Feb 8, 2024
1 parent 0a1786e commit fd7d738
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion posthog/temporal/data_imports/pipelines/stripe/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from dlt.sources import DltResource
from pendulum import DateTime
from asgiref.sync import sync_to_async
from posthog.temporal.data_imports.pipelines.helpers import check_limit
from posthog.temporal.data_imports.pipelines.helpers import check_limit, aupdate_job_count
from posthog.warehouse.models import ExternalDataJob

stripe.api_version = "2022-11-15"
Expand Down Expand Up @@ -92,6 +92,8 @@ async def stripe_pagination(
if not response["has_more"] or status == ExternalDataJob.Status.CANCELLED:
break

await aupdate_job_count(job_id, team_id, count)


@dlt.source(max_table_nesting=0)
def stripe_source(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ async def setup_job_1():
# if job was not canceled, this job would run indefinitely
assert len(job_1_customer_objects["Contents"]) == 1

await sync_to_async(job_1.refresh_from_db)()
assert job_1.rows_synced == 1


@pytest.mark.django_db(transaction=True)
@pytest.mark.asyncio
Expand Down

0 comments on commit fd7d738

Please sign in to comment.