Skip to content

Commit

Permalink
add note about queryset evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
tkaemming committed Mar 13, 2024
1 parent 3c294c1 commit 95b9ef7
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions posthog/management/commands/backfill_distinct_id_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,21 @@ def execute(self, dry_run: bool = False) -> None:
parameters,
)

update_query = Team.objects.raw(
"""
UPDATE posthog_team
SET extra_settings = COALESCE(extra_settings, '{}'::jsonb) || jsonb_build_object('distinct_id_overrides_backfilled', true)
WHERE id = %s
RETURNING id
""",
[self.team_id],
# XXX: The RETURNING set isn't really useful here, but this QuerySet
# needs to be iterated over to force execution, so we might as well
# return something...
updated_teams = list(
Team.objects.raw(
"""
UPDATE posthog_team
SET extra_settings = COALESCE(extra_settings, '{}'::jsonb) || jsonb_build_object('distinct_id_overrides_backfilled', true)
WHERE id = %s
RETURNING *
""",
[self.team_id],
)
)
logger.info("Completed %r, marked %s team as backfilled.", self, len(update_query))
logger.info("Completed %r, marked %s team as backfilled.", self, len(updated_teams))


class Command(BaseCommand):
Expand Down

0 comments on commit 95b9ef7

Please sign in to comment.