0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-28 09:16:49 +01:00

Fix trend breakdown duplicates (#8583)

* keep breakdown count consistent

* add constant back

* update test
This commit is contained in:
Neil Kakkar 2022-02-14 16:20:45 +00:00 committed by GitHub
parent 1f74f4b0f7
commit 2d613d7d97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 4 deletions

View File

@ -24,7 +24,7 @@ from ee.clickhouse.queries.person_distinct_id_query import get_team_distinct_ids
from ee.clickhouse.queries.person_query import ClickhousePersonQuery
from ee.clickhouse.queries.util import parse_timestamps
from ee.clickhouse.sql.trends.top_elements import TOP_ELEMENTS_ARRAY_OF_KEY_SQL
from posthog.constants import BREAKDOWN_TYPES
from posthog.constants import BREAKDOWN_TYPES, BREAKDOWN_VALUES_LIMIT
from posthog.models.cohort import Cohort
from posthog.models.entity import Entity
from posthog.models.filters.filter import Filter
@ -38,7 +38,7 @@ def get_breakdown_prop_values(
entity: Entity,
aggregate_operation: str,
team_id: int,
limit: int = 25,
limit: int = BREAKDOWN_VALUES_LIMIT,
extra_params={},
column_optimizer: Optional[ColumnOptimizer] = None,
):

View File

@ -30,6 +30,7 @@ from posthog.api.routing import StructuredViewSetMixin
from posthog.api.shared import UserBasicSerializer
from posthog.api.utils import format_paginated_url
from posthog.constants import (
BREAKDOWN_VALUES_LIMIT,
FROM_DASHBOARD,
INSIGHT,
INSIGHT_FUNNELS,
@ -291,7 +292,11 @@ class InsightViewSet(StructuredViewSetMixin, viewsets.ModelViewSet):
result = self.calculate_trends(request)
filter = Filter(request=request, team=self.team)
next = format_paginated_url(request, filter.offset, 20) if len(result["result"]) > 20 else None
next = (
format_paginated_url(request, filter.offset, BREAKDOWN_VALUES_LIMIT)
if len(result["result"]) >= BREAKDOWN_VALUES_LIMIT
else None
)
return Response({**result, "next": next})
@cached_function

View File

@ -557,7 +557,7 @@ class TestInsight(ClickhouseTestMixin, LicensedTestMixin, APIBaseTest, QueryMatc
},
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertIn("offset=20", response.json()["next"])
self.assertIn("offset=25", response.json()["next"])
def test_insight_paths_basic(self):
_create_person(team=self.team, distinct_ids=["person_1"])

View File

@ -213,3 +213,4 @@ class ExperimentSignificanceCode(str, Enum):
MAX_SLUG_LENGTH = 48
GROUP_TYPES_LIMIT = 5
BREAKDOWN_VALUES_LIMIT = 25