Skip to content

Commit

Permalink
change created_at to _timestamp (#3820)
Browse files Browse the repository at this point in the history
* change created_at to _timestamp

* remove test
  • Loading branch information
EDsCODE committed Mar 30, 2021
1 parent 8ed52b5 commit 1768b89
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 28 deletions.
26 changes: 0 additions & 26 deletions ee/clickhouse/models/test/test_cohort.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,32 +205,6 @@ def test_prop_cohort_with_negation(self):
result = sync_execute(final_query, {**params, "team_id": self.team.pk})
self.assertEqual(len(result), 0)

def test_cohort_updated_props(self):
# The way clickhouse works is that updates aren't instant, so two people with the same ID are in the database
# Make sure we get the last one.
person1 = _create_person(
distinct_ids=["some_other_id_2"],
team_id=self.team.pk,
properties={"$some_prop": "updated"},
timestamp=datetime(2020, 1, 1, 12, 0, 1),
)
_create_person(
uuid=person1.uuid,
distinct_ids=["some_other_id"],
team_id=self.team.pk,
properties={"$some_prop": "something"},
timestamp=datetime(2020, 1, 1, 12, 0, 4),
)

cohort1 = Cohort.objects.create(
team=self.team, groups=[{"properties": {"$some_prop": "updated"}}], name="cohort1",
)

final_query, params = format_filter_query(cohort1)

result = sync_execute(final_query, {**params, "team_id": self.team.pk})
self.assertEqual(len(result), 0)

def test_cohort_get_person_ids_by_cohort_id(self):
user1 = _create_person(distinct_ids=["user1"], team_id=self.team.pk, properties={"$some_prop": "something"})
user2 = _create_person(distinct_ids=["user2"], team_id=self.team.pk, properties={"$some_prop": "another"})
Expand Down
4 changes: 2 additions & 2 deletions ee/clickhouse/sql/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@

GET_LATEST_PERSON_SQL = """
SELECT * FROM person JOIN (
SELECT id, max(created_at) as created_at FROM person WHERE team_id = %(team_id)s GROUP BY id
) as person_max ON person.id = person_max.id AND person.created_at = person_max.created_at
SELECT id, max(_timestamp) as _timestamp FROM person WHERE team_id = %(team_id)s GROUP BY id
) as person_max ON person.id = person_max.id AND person._timestamp = person_max._timestamp
WHERE team_id = %(team_id)s
{query}
"""
Expand Down

0 comments on commit 1768b89

Please sign in to comment.