From 61fb17e8af8746d605d8acfa563be35e8ecc763e Mon Sep 17 00:00:00 2001 From: Ted Kaemming <65315+tkaemming@users.noreply.github.com> Date: Thu, 7 Dec 2023 18:37:40 -0800 Subject: [PATCH] Split up non-deferred from deferred overrides, remove another comment. --- posthog/models/person/person.py | 35 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/posthog/models/person/person.py b/posthog/models/person/person.py index ad3b9c16b04ba..364e76c7758f8 100644 --- a/posthog/models/person/person.py +++ b/posthog/models/person/person.py @@ -134,24 +134,6 @@ class Meta: uuid = models.UUIDField() -class PendingPersonOverride(models.Model): - id = models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID") - team_id = models.BigIntegerField() - old_person_id = models.UUIDField() - override_person_id = models.UUIDField() - oldest_event = models.DateTimeField() - - -class FlatPersonOverride(models.Model): - # TODO: What additional constraints here make sense (and are practical to implement?) - id = models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID") - team_id = models.BigIntegerField() - old_person_id = models.UUIDField() - override_person_id = models.UUIDField() - oldest_event = models.DateTimeField() - version = models.BigIntegerField(null=True, blank=True) - - class PersonOverride(models.Model): """A model of persons to be overriden in merge or merge-like events. @@ -197,6 +179,23 @@ class Meta: version: models.BigIntegerField = models.BigIntegerField(null=True, blank=True) +class PendingPersonOverride(models.Model): + id = models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID") + team_id = models.BigIntegerField() + old_person_id = models.UUIDField() + override_person_id = models.UUIDField() + oldest_event = models.DateTimeField() + + +class FlatPersonOverride(models.Model): + id = models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID") + team_id = models.BigIntegerField() + old_person_id = models.UUIDField() + override_person_id = models.UUIDField() + oldest_event = models.DateTimeField() + version = models.BigIntegerField(null=True, blank=True) + + def get_distinct_ids_for_subquery(person: Person | None, team: Team) -> List[str]: """_summary_ Fetching distinct_ids for a person from CH is slow, so we