-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Static cohort on person modal #2952
Conversation
<Button type="primary" onClick={() => saveCohortWithFilters()}> | ||
{'Save cohort'} | ||
</Button> | ||
</div> | ||
{user?.is_multi_tenancy && featureFlags['filter_by_session_props'] ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@macobo put the button here temporarily. i think it should be clear from conflicts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some initial comments but I'm still unsure about the general logic, but might be best to chat about this IRL.
is_static: true, | ||
name: cohortName, | ||
} | ||
cohortLogic({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels slightly sketchy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup. I originally had this in the connect
handler, but I think kea typegen doesn't handle logics that are initialized with props in connect yet so it was erroring unless I did this. Need to QA to make sure the logics work as expected here
Button could have better placement |
Found {people.count === 99 ? '99+' : people.count} {people.count === 1 ? 'user' : 'users'} | ||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start' }}> | ||
Found {people.count === 99 ? '99+' : people.count} {people.count === 1 ? 'user' : 'users'} | ||
{(view === ViewType.TRENDS || view === ViewType.STICKINESS) && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYT about putting this behind a feature flag?
Advantage: We can turn it off more easily if/as we discover bugs
Disadvantage: More management work, won't work well with self-hosted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't have a chance to test this out - deploy wasn't working? Left some comments, we're not far from merging.
@@ -328,9 +328,42 @@ function _Insights() { | |||
) | |||
} | |||
|
|||
function TrendInsight({ view }) { | |||
const { filters: _filters, loading, showingPeople } = useValues(trendsLogic({ dashboardItemId: null, view })) | |||
function SaveCohortModal({ onOk, onCancel, visible }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-actionable: This is causing some duplication while at the same time missing e.g. validation for cohort name length - might cause pain down the line. I don't think worth abstracting out though, given the "extra" bits in the main modal.
from posthog.tasks.calculate_cohort import insert_cohort_from_query | ||
|
||
|
||
class ClickhouseCohortSerializer(CohortSerializer): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is missing tests it seems.
Perhaps we can generalize the posthog.api.test.test_cohort and reuse it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean the base serializer is missing tests or the clickhousecohortserializer? There's no logic to test in the clickhouseserializer functions as they're essentially just overrides to the base function call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant the whole view as a whole - we have tests for /api/cohort for postgres but not for this I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah i see the confusion. So the tests in posthog/api/cohort
only have top level testing where they just make sure the celery task is eventually called. Adding this to the ee flow would be redundant as these tests are not testing any specific logic from EE.
The actual ee logic is tested but in different places which makes this slightly confusing. For example, ee/clickhouse/models/test/test_cohort
has a test for the insert_users_by_list
function and then ee/tasks/test/test_calculate_cohort
contains the tests for the newly added functionality in this PR
ee/clickhouse/views/cohort.py
Outdated
insert_cohort_from_query.delay(cohort.pk, INSIGHT_STICKINESS, filter.to_dict()) | ||
|
||
def _handle_trend_people(self, cohort: Cohort, filter: Filter) -> None: | ||
if len(filter.entities) >= 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I need a bit of context for this, code is unclear.
Which entities are we sending over here? Only the one relevant for the modal? If so, there should only ever be exactly one entity right?
If all, then choosing the first seems incorrect and not sure when the else case can happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in #3428 could also use a frontend test but I think we should merge the fix first so this PR isn't stuck. I have a log of component tests that I will write separately
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Things are looking good, we should get this in. There's a test failure though.
Perhaps worth putting the new frontend code behind a feature flag though?
feature flag added! test fixed! #3428 should be merged first |
Changes
Please describe.
upload-static-cohort-csv
'save-cohort-on-modal'
If this affects the frontend, include screenshots.
Checklist