From 90a4fd79f1f2e4b157fc793349ca8781c4ff67e1 Mon Sep 17 00:00:00 2001 From: Tom Owers Date: Wed, 24 Apr 2024 11:54:13 +0100 Subject: [PATCH 1/4] Enable schema specific syncs during the onboarding wizard --- .../external/forms/SyncProgressStep.tsx | 19 +++++++++++-------- .../data-warehouse/new/sourceWizardLogic.tsx | 1 + posthog/warehouse/api/external_data_source.py | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/frontend/src/scenes/data-warehouse/external/forms/SyncProgressStep.tsx b/frontend/src/scenes/data-warehouse/external/forms/SyncProgressStep.tsx index 2432f349e3040..1e58314fdb862 100644 --- a/frontend/src/scenes/data-warehouse/external/forms/SyncProgressStep.tsx +++ b/frontend/src/scenes/data-warehouse/external/forms/SyncProgressStep.tsx @@ -3,28 +3,31 @@ import { useValues } from 'kea' import { sourceWizardLogic } from 'scenes/data-warehouse/new/sourceWizardLogic' import { dataWarehouseSettingsLogic } from 'scenes/data-warehouse/settings/dataWarehouseSettingsLogic' +import { ExternalDataSourceSchema } from '~/types' + export const SyncProgressStep = (): JSX.Element => { - const { databaseSchema, sourceId } = useValues(sourceWizardLogic) + const { sourceId } = useValues(sourceWizardLogic) const { dataWarehouseSources, dataWarehouseSourcesLoading } = useValues(dataWarehouseSettingsLogic) const source = dataWarehouseSources?.results.find((n) => n.id === sourceId) + const schemas = source?.schemas ?? [] - const getSyncStatus = (shouldSync: boolean): { status: string; tagType: LemonTagType } => { - if (!shouldSync) { + const getSyncStatus = (schema: ExternalDataSourceSchema): { status: string; tagType: LemonTagType } => { + if (!schema.should_sync) { return { status: 'Not synced', tagType: 'default', } } - if (!source || source.status === 'Running') { + if (schema.status === 'Running') { return { status: 'Syncing...', tagType: 'primary', } } - if (source.status === 'Completed') { + if (schema.status === 'Completed') { return { status: 'Completed', tagType: 'success', @@ -42,7 +45,7 @@ export const SyncProgressStep = (): JSX.Element => {
{ title: 'Table', key: 'table', render: function RenderTable(_, schema) { - return schema.table + return schema.name }, }, { title: 'Status', key: 'status', render: function RenderStatus(_, schema) { - const { status, tagType } = getSyncStatus(schema.should_sync) + const { status, tagType } = getSyncStatus(schema) return {status} }, diff --git a/frontend/src/scenes/data-warehouse/new/sourceWizardLogic.tsx b/frontend/src/scenes/data-warehouse/new/sourceWizardLogic.tsx index 2f400d9e14872..7ff85f473dd8f 100644 --- a/frontend/src/scenes/data-warehouse/new/sourceWizardLogic.tsx +++ b/frontend/src/scenes/data-warehouse/new/sourceWizardLogic.tsx @@ -448,6 +448,7 @@ export const sourceWizardLogic = kea([ lemonToast.success('New Data Resource Created') actions.setSourceId(id) actions.resetSourceConnectionDetails() + actions.loadSources(null) actions.onNext() } catch (e: any) { lemonToast.error(e.data?.message ?? e.message) diff --git a/posthog/warehouse/api/external_data_source.py b/posthog/warehouse/api/external_data_source.py index 36142a805938c..80576bc5da2d5 100644 --- a/posthog/warehouse/api/external_data_source.py +++ b/posthog/warehouse/api/external_data_source.py @@ -444,7 +444,7 @@ def database_schema(self, request: Request, *arg: Any, **kwargs: Any): }, ) - result_mapped_to_options = [{"table": row, "should_sync": False} for row in result] + result_mapped_to_options = [{"table": row, "should_sync": True} for row in result] return Response(status=status.HTTP_200_OK, data=result_mapped_to_options) # Return the possible endpoints for all other source types @@ -455,7 +455,7 @@ def database_schema(self, request: Request, *arg: Any, **kwargs: Any): data={"message": "Invalid parameter: source_type"}, ) - options = [{"table": row, "should_sync": False} for row in schemas] + options = [{"table": row, "should_sync": True} for row in schemas] return Response(status=status.HTTP_200_OK, data=options) @action(methods=["POST"], detail=False) From 900473bb34f84515665ccc3a2ac57017090e1108 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 24 Apr 2024 16:03:51 +0000 Subject: [PATCH 2/4] Update query snapshots --- .../test/__snapshots__/test_annotation.ambr | 248 +++++++----------- 1 file changed, 90 insertions(+), 158 deletions(-) diff --git a/posthog/api/test/__snapshots__/test_annotation.ambr b/posthog/api/test/__snapshots__/test_annotation.ambr index af842be0643e0..87ea17b09f573 100644 --- a/posthog/api/test/__snapshots__/test_annotation.ambr +++ b/posthog/api/test/__snapshots__/test_annotation.ambr @@ -84,6 +84,85 @@ ''' # --- # name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.10 + ''' + SELECT "posthog_annotation"."id", + "posthog_annotation"."content", + "posthog_annotation"."created_at", + "posthog_annotation"."updated_at", + "posthog_annotation"."dashboard_item_id", + "posthog_annotation"."team_id", + "posthog_annotation"."organization_id", + "posthog_annotation"."created_by_id", + "posthog_annotation"."scope", + "posthog_annotation"."creation_type", + "posthog_annotation"."date_marker", + "posthog_annotation"."deleted", + "posthog_annotation"."apply_all", + "posthog_dashboarditem"."id", + "posthog_dashboarditem"."name", + "posthog_dashboarditem"."derived_name", + "posthog_dashboarditem"."description", + "posthog_dashboarditem"."team_id", + "posthog_dashboarditem"."filters", + "posthog_dashboarditem"."filters_hash", + "posthog_dashboarditem"."query", + "posthog_dashboarditem"."order", + "posthog_dashboarditem"."deleted", + "posthog_dashboarditem"."saved", + "posthog_dashboarditem"."created_at", + "posthog_dashboarditem"."last_refresh", + "posthog_dashboarditem"."refreshing", + "posthog_dashboarditem"."created_by_id", + "posthog_dashboarditem"."is_sample", + "posthog_dashboarditem"."short_id", + "posthog_dashboarditem"."favorited", + "posthog_dashboarditem"."refresh_attempt", + "posthog_dashboarditem"."last_modified_at", + "posthog_dashboarditem"."last_modified_by_id", + "posthog_dashboarditem"."dashboard_id", + "posthog_dashboarditem"."layouts", + "posthog_dashboarditem"."color", + "posthog_dashboarditem"."dive_dashboard_id", + "posthog_dashboarditem"."updated_at", + "posthog_dashboarditem"."deprecated_tags", + "posthog_dashboarditem"."tags", + "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."is_active", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."requested_password_reset_at", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."strapi_id", + "posthog_user"."email_opt_in", + "posthog_user"."theme_mode", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."events_column_config" + FROM "posthog_annotation" + LEFT OUTER JOIN "posthog_dashboarditem" ON ("posthog_annotation"."dashboard_item_id" = "posthog_dashboarditem"."id") + LEFT OUTER JOIN "posthog_user" ON ("posthog_annotation"."created_by_id" = "posthog_user"."id") + WHERE ((("posthog_annotation"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_annotation"."scope" = 'organization') + OR "posthog_annotation"."team_id" = 2) + AND NOT "posthog_annotation"."deleted") + ORDER BY "posthog_annotation"."date_marker" DESC + LIMIT 1000 + ''' +# --- +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.11 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -114,7 +193,7 @@ LIMIT 21 ''' # --- -# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.11 +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.12 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -167,7 +246,7 @@ LIMIT 21 ''' # --- -# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.12 +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.13 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -199,93 +278,14 @@ WHERE "posthog_organizationmembership"."user_id" = 2 ''' # --- -# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.13 - ''' - SELECT COUNT(*) AS "__count" - FROM "posthog_annotation" - WHERE ((("posthog_annotation"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid - AND "posthog_annotation"."scope" = 'organization') - OR "posthog_annotation"."team_id" = 2) - AND NOT "posthog_annotation"."deleted") - ''' -# --- # name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.14 ''' - SELECT "posthog_annotation"."id", - "posthog_annotation"."content", - "posthog_annotation"."created_at", - "posthog_annotation"."updated_at", - "posthog_annotation"."dashboard_item_id", - "posthog_annotation"."team_id", - "posthog_annotation"."organization_id", - "posthog_annotation"."created_by_id", - "posthog_annotation"."scope", - "posthog_annotation"."creation_type", - "posthog_annotation"."date_marker", - "posthog_annotation"."deleted", - "posthog_annotation"."apply_all", - "posthog_dashboarditem"."id", - "posthog_dashboarditem"."name", - "posthog_dashboarditem"."derived_name", - "posthog_dashboarditem"."description", - "posthog_dashboarditem"."team_id", - "posthog_dashboarditem"."filters", - "posthog_dashboarditem"."filters_hash", - "posthog_dashboarditem"."query", - "posthog_dashboarditem"."order", - "posthog_dashboarditem"."deleted", - "posthog_dashboarditem"."saved", - "posthog_dashboarditem"."created_at", - "posthog_dashboarditem"."last_refresh", - "posthog_dashboarditem"."refreshing", - "posthog_dashboarditem"."created_by_id", - "posthog_dashboarditem"."is_sample", - "posthog_dashboarditem"."short_id", - "posthog_dashboarditem"."favorited", - "posthog_dashboarditem"."refresh_attempt", - "posthog_dashboarditem"."last_modified_at", - "posthog_dashboarditem"."last_modified_by_id", - "posthog_dashboarditem"."dashboard_id", - "posthog_dashboarditem"."layouts", - "posthog_dashboarditem"."color", - "posthog_dashboarditem"."dive_dashboard_id", - "posthog_dashboarditem"."updated_at", - "posthog_dashboarditem"."deprecated_tags", - "posthog_dashboarditem"."tags", - "posthog_user"."id", - "posthog_user"."password", - "posthog_user"."last_login", - "posthog_user"."first_name", - "posthog_user"."last_name", - "posthog_user"."is_staff", - "posthog_user"."is_active", - "posthog_user"."date_joined", - "posthog_user"."uuid", - "posthog_user"."current_organization_id", - "posthog_user"."current_team_id", - "posthog_user"."email", - "posthog_user"."pending_email", - "posthog_user"."temporary_token", - "posthog_user"."distinct_id", - "posthog_user"."is_email_verified", - "posthog_user"."requested_password_reset_at", - "posthog_user"."has_seen_product_intro_for", - "posthog_user"."strapi_id", - "posthog_user"."email_opt_in", - "posthog_user"."theme_mode", - "posthog_user"."partial_notification_settings", - "posthog_user"."anonymize_data", - "posthog_user"."toolbar_mode", - "posthog_user"."events_column_config" + SELECT COUNT(*) AS "__count" FROM "posthog_annotation" - LEFT OUTER JOIN "posthog_dashboarditem" ON ("posthog_annotation"."dashboard_item_id" = "posthog_dashboarditem"."id") - LEFT OUTER JOIN "posthog_user" ON ("posthog_annotation"."created_by_id" = "posthog_user"."id") WHERE ((("posthog_annotation"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid AND "posthog_annotation"."scope" = 'organization') OR "posthog_annotation"."team_id" = 2) AND NOT "posthog_annotation"."deleted") - ORDER BY "posthog_annotation"."date_marker" DESC - LIMIT 1000 ''' # --- # name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.15 @@ -538,90 +538,22 @@ # --- # name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.8 ''' - SELECT COUNT(*) AS "__count" - FROM "posthog_annotation" - WHERE ((("posthog_annotation"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid - AND "posthog_annotation"."scope" = 'organization') - OR "posthog_annotation"."team_id" = 2) - AND NOT "posthog_annotation"."deleted") + SELECT "posthog_instancesetting"."id", + "posthog_instancesetting"."key", + "posthog_instancesetting"."raw_value" + FROM "posthog_instancesetting" + WHERE "posthog_instancesetting"."key" = 'constance:posthog:RATE_LIMIT_ENABLED' + ORDER BY "posthog_instancesetting"."id" ASC + LIMIT 1 ''' # --- # name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.9 ''' - SELECT "posthog_annotation"."id", - "posthog_annotation"."content", - "posthog_annotation"."created_at", - "posthog_annotation"."updated_at", - "posthog_annotation"."dashboard_item_id", - "posthog_annotation"."team_id", - "posthog_annotation"."organization_id", - "posthog_annotation"."created_by_id", - "posthog_annotation"."scope", - "posthog_annotation"."creation_type", - "posthog_annotation"."date_marker", - "posthog_annotation"."deleted", - "posthog_annotation"."apply_all", - "posthog_dashboarditem"."id", - "posthog_dashboarditem"."name", - "posthog_dashboarditem"."derived_name", - "posthog_dashboarditem"."description", - "posthog_dashboarditem"."team_id", - "posthog_dashboarditem"."filters", - "posthog_dashboarditem"."filters_hash", - "posthog_dashboarditem"."query", - "posthog_dashboarditem"."order", - "posthog_dashboarditem"."deleted", - "posthog_dashboarditem"."saved", - "posthog_dashboarditem"."created_at", - "posthog_dashboarditem"."last_refresh", - "posthog_dashboarditem"."refreshing", - "posthog_dashboarditem"."created_by_id", - "posthog_dashboarditem"."is_sample", - "posthog_dashboarditem"."short_id", - "posthog_dashboarditem"."favorited", - "posthog_dashboarditem"."refresh_attempt", - "posthog_dashboarditem"."last_modified_at", - "posthog_dashboarditem"."last_modified_by_id", - "posthog_dashboarditem"."dashboard_id", - "posthog_dashboarditem"."layouts", - "posthog_dashboarditem"."color", - "posthog_dashboarditem"."dive_dashboard_id", - "posthog_dashboarditem"."updated_at", - "posthog_dashboarditem"."deprecated_tags", - "posthog_dashboarditem"."tags", - "posthog_user"."id", - "posthog_user"."password", - "posthog_user"."last_login", - "posthog_user"."first_name", - "posthog_user"."last_name", - "posthog_user"."is_staff", - "posthog_user"."is_active", - "posthog_user"."date_joined", - "posthog_user"."uuid", - "posthog_user"."current_organization_id", - "posthog_user"."current_team_id", - "posthog_user"."email", - "posthog_user"."pending_email", - "posthog_user"."temporary_token", - "posthog_user"."distinct_id", - "posthog_user"."is_email_verified", - "posthog_user"."requested_password_reset_at", - "posthog_user"."has_seen_product_intro_for", - "posthog_user"."strapi_id", - "posthog_user"."email_opt_in", - "posthog_user"."theme_mode", - "posthog_user"."partial_notification_settings", - "posthog_user"."anonymize_data", - "posthog_user"."toolbar_mode", - "posthog_user"."events_column_config" + SELECT COUNT(*) AS "__count" FROM "posthog_annotation" - LEFT OUTER JOIN "posthog_dashboarditem" ON ("posthog_annotation"."dashboard_item_id" = "posthog_dashboarditem"."id") - LEFT OUTER JOIN "posthog_user" ON ("posthog_annotation"."created_by_id" = "posthog_user"."id") WHERE ((("posthog_annotation"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid AND "posthog_annotation"."scope" = 'organization') OR "posthog_annotation"."team_id" = 2) AND NOT "posthog_annotation"."deleted") - ORDER BY "posthog_annotation"."date_marker" DESC - LIMIT 1000 ''' # --- From bf1446f9e0b312456131612de87948dd932f37f3 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 24 Apr 2024 16:15:11 +0000 Subject: [PATCH 3/4] Update query snapshots --- .../test/__snapshots__/test_annotation.ambr | 248 +++++++++++------- 1 file changed, 158 insertions(+), 90 deletions(-) diff --git a/posthog/api/test/__snapshots__/test_annotation.ambr b/posthog/api/test/__snapshots__/test_annotation.ambr index 87ea17b09f573..af842be0643e0 100644 --- a/posthog/api/test/__snapshots__/test_annotation.ambr +++ b/posthog/api/test/__snapshots__/test_annotation.ambr @@ -84,85 +84,6 @@ ''' # --- # name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.10 - ''' - SELECT "posthog_annotation"."id", - "posthog_annotation"."content", - "posthog_annotation"."created_at", - "posthog_annotation"."updated_at", - "posthog_annotation"."dashboard_item_id", - "posthog_annotation"."team_id", - "posthog_annotation"."organization_id", - "posthog_annotation"."created_by_id", - "posthog_annotation"."scope", - "posthog_annotation"."creation_type", - "posthog_annotation"."date_marker", - "posthog_annotation"."deleted", - "posthog_annotation"."apply_all", - "posthog_dashboarditem"."id", - "posthog_dashboarditem"."name", - "posthog_dashboarditem"."derived_name", - "posthog_dashboarditem"."description", - "posthog_dashboarditem"."team_id", - "posthog_dashboarditem"."filters", - "posthog_dashboarditem"."filters_hash", - "posthog_dashboarditem"."query", - "posthog_dashboarditem"."order", - "posthog_dashboarditem"."deleted", - "posthog_dashboarditem"."saved", - "posthog_dashboarditem"."created_at", - "posthog_dashboarditem"."last_refresh", - "posthog_dashboarditem"."refreshing", - "posthog_dashboarditem"."created_by_id", - "posthog_dashboarditem"."is_sample", - "posthog_dashboarditem"."short_id", - "posthog_dashboarditem"."favorited", - "posthog_dashboarditem"."refresh_attempt", - "posthog_dashboarditem"."last_modified_at", - "posthog_dashboarditem"."last_modified_by_id", - "posthog_dashboarditem"."dashboard_id", - "posthog_dashboarditem"."layouts", - "posthog_dashboarditem"."color", - "posthog_dashboarditem"."dive_dashboard_id", - "posthog_dashboarditem"."updated_at", - "posthog_dashboarditem"."deprecated_tags", - "posthog_dashboarditem"."tags", - "posthog_user"."id", - "posthog_user"."password", - "posthog_user"."last_login", - "posthog_user"."first_name", - "posthog_user"."last_name", - "posthog_user"."is_staff", - "posthog_user"."is_active", - "posthog_user"."date_joined", - "posthog_user"."uuid", - "posthog_user"."current_organization_id", - "posthog_user"."current_team_id", - "posthog_user"."email", - "posthog_user"."pending_email", - "posthog_user"."temporary_token", - "posthog_user"."distinct_id", - "posthog_user"."is_email_verified", - "posthog_user"."requested_password_reset_at", - "posthog_user"."has_seen_product_intro_for", - "posthog_user"."strapi_id", - "posthog_user"."email_opt_in", - "posthog_user"."theme_mode", - "posthog_user"."partial_notification_settings", - "posthog_user"."anonymize_data", - "posthog_user"."toolbar_mode", - "posthog_user"."events_column_config" - FROM "posthog_annotation" - LEFT OUTER JOIN "posthog_dashboarditem" ON ("posthog_annotation"."dashboard_item_id" = "posthog_dashboarditem"."id") - LEFT OUTER JOIN "posthog_user" ON ("posthog_annotation"."created_by_id" = "posthog_user"."id") - WHERE ((("posthog_annotation"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid - AND "posthog_annotation"."scope" = 'organization') - OR "posthog_annotation"."team_id" = 2) - AND NOT "posthog_annotation"."deleted") - ORDER BY "posthog_annotation"."date_marker" DESC - LIMIT 1000 - ''' -# --- -# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.11 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -193,7 +114,7 @@ LIMIT 21 ''' # --- -# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.12 +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.11 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -246,7 +167,7 @@ LIMIT 21 ''' # --- -# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.13 +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.12 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -278,7 +199,7 @@ WHERE "posthog_organizationmembership"."user_id" = 2 ''' # --- -# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.14 +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.13 ''' SELECT COUNT(*) AS "__count" FROM "posthog_annotation" @@ -288,6 +209,85 @@ AND NOT "posthog_annotation"."deleted") ''' # --- +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.14 + ''' + SELECT "posthog_annotation"."id", + "posthog_annotation"."content", + "posthog_annotation"."created_at", + "posthog_annotation"."updated_at", + "posthog_annotation"."dashboard_item_id", + "posthog_annotation"."team_id", + "posthog_annotation"."organization_id", + "posthog_annotation"."created_by_id", + "posthog_annotation"."scope", + "posthog_annotation"."creation_type", + "posthog_annotation"."date_marker", + "posthog_annotation"."deleted", + "posthog_annotation"."apply_all", + "posthog_dashboarditem"."id", + "posthog_dashboarditem"."name", + "posthog_dashboarditem"."derived_name", + "posthog_dashboarditem"."description", + "posthog_dashboarditem"."team_id", + "posthog_dashboarditem"."filters", + "posthog_dashboarditem"."filters_hash", + "posthog_dashboarditem"."query", + "posthog_dashboarditem"."order", + "posthog_dashboarditem"."deleted", + "posthog_dashboarditem"."saved", + "posthog_dashboarditem"."created_at", + "posthog_dashboarditem"."last_refresh", + "posthog_dashboarditem"."refreshing", + "posthog_dashboarditem"."created_by_id", + "posthog_dashboarditem"."is_sample", + "posthog_dashboarditem"."short_id", + "posthog_dashboarditem"."favorited", + "posthog_dashboarditem"."refresh_attempt", + "posthog_dashboarditem"."last_modified_at", + "posthog_dashboarditem"."last_modified_by_id", + "posthog_dashboarditem"."dashboard_id", + "posthog_dashboarditem"."layouts", + "posthog_dashboarditem"."color", + "posthog_dashboarditem"."dive_dashboard_id", + "posthog_dashboarditem"."updated_at", + "posthog_dashboarditem"."deprecated_tags", + "posthog_dashboarditem"."tags", + "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."is_active", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."requested_password_reset_at", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."strapi_id", + "posthog_user"."email_opt_in", + "posthog_user"."theme_mode", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."events_column_config" + FROM "posthog_annotation" + LEFT OUTER JOIN "posthog_dashboarditem" ON ("posthog_annotation"."dashboard_item_id" = "posthog_dashboarditem"."id") + LEFT OUTER JOIN "posthog_user" ON ("posthog_annotation"."created_by_id" = "posthog_user"."id") + WHERE ((("posthog_annotation"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_annotation"."scope" = 'organization') + OR "posthog_annotation"."team_id" = 2) + AND NOT "posthog_annotation"."deleted") + ORDER BY "posthog_annotation"."date_marker" DESC + LIMIT 1000 + ''' +# --- # name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.15 ''' SELECT "posthog_annotation"."id", @@ -538,22 +538,90 @@ # --- # name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.8 ''' - SELECT "posthog_instancesetting"."id", - "posthog_instancesetting"."key", - "posthog_instancesetting"."raw_value" - FROM "posthog_instancesetting" - WHERE "posthog_instancesetting"."key" = 'constance:posthog:RATE_LIMIT_ENABLED' - ORDER BY "posthog_instancesetting"."id" ASC - LIMIT 1 + SELECT COUNT(*) AS "__count" + FROM "posthog_annotation" + WHERE ((("posthog_annotation"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_annotation"."scope" = 'organization') + OR "posthog_annotation"."team_id" = 2) + AND NOT "posthog_annotation"."deleted") ''' # --- # name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.9 ''' - SELECT COUNT(*) AS "__count" + SELECT "posthog_annotation"."id", + "posthog_annotation"."content", + "posthog_annotation"."created_at", + "posthog_annotation"."updated_at", + "posthog_annotation"."dashboard_item_id", + "posthog_annotation"."team_id", + "posthog_annotation"."organization_id", + "posthog_annotation"."created_by_id", + "posthog_annotation"."scope", + "posthog_annotation"."creation_type", + "posthog_annotation"."date_marker", + "posthog_annotation"."deleted", + "posthog_annotation"."apply_all", + "posthog_dashboarditem"."id", + "posthog_dashboarditem"."name", + "posthog_dashboarditem"."derived_name", + "posthog_dashboarditem"."description", + "posthog_dashboarditem"."team_id", + "posthog_dashboarditem"."filters", + "posthog_dashboarditem"."filters_hash", + "posthog_dashboarditem"."query", + "posthog_dashboarditem"."order", + "posthog_dashboarditem"."deleted", + "posthog_dashboarditem"."saved", + "posthog_dashboarditem"."created_at", + "posthog_dashboarditem"."last_refresh", + "posthog_dashboarditem"."refreshing", + "posthog_dashboarditem"."created_by_id", + "posthog_dashboarditem"."is_sample", + "posthog_dashboarditem"."short_id", + "posthog_dashboarditem"."favorited", + "posthog_dashboarditem"."refresh_attempt", + "posthog_dashboarditem"."last_modified_at", + "posthog_dashboarditem"."last_modified_by_id", + "posthog_dashboarditem"."dashboard_id", + "posthog_dashboarditem"."layouts", + "posthog_dashboarditem"."color", + "posthog_dashboarditem"."dive_dashboard_id", + "posthog_dashboarditem"."updated_at", + "posthog_dashboarditem"."deprecated_tags", + "posthog_dashboarditem"."tags", + "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."is_active", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."requested_password_reset_at", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."strapi_id", + "posthog_user"."email_opt_in", + "posthog_user"."theme_mode", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."events_column_config" FROM "posthog_annotation" + LEFT OUTER JOIN "posthog_dashboarditem" ON ("posthog_annotation"."dashboard_item_id" = "posthog_dashboarditem"."id") + LEFT OUTER JOIN "posthog_user" ON ("posthog_annotation"."created_by_id" = "posthog_user"."id") WHERE ((("posthog_annotation"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid AND "posthog_annotation"."scope" = 'organization') OR "posthog_annotation"."team_id" = 2) AND NOT "posthog_annotation"."deleted") + ORDER BY "posthog_annotation"."date_marker" DESC + LIMIT 1000 ''' # --- From 0c75a3d1ae36b2d9c864df5c9585e593c7ece139 Mon Sep 17 00:00:00 2001 From: Tom Owers Date: Wed, 24 Apr 2024 17:51:11 +0100 Subject: [PATCH 4/4] Fixed tests --- posthog/warehouse/api/test/test_external_data_source.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/posthog/warehouse/api/test/test_external_data_source.py b/posthog/warehouse/api/test/test_external_data_source.py index ef84a5e1bc8df..1c23807b82328 100644 --- a/posthog/warehouse/api/test/test_external_data_source.py +++ b/posthog/warehouse/api/test/test_external_data_source.py @@ -228,7 +228,7 @@ def test_internal_postgres(self, patch_get_postgres_schemas): }, ) self.assertEqual(response.status_code, 200) - self.assertEqual(response.json(), [{"should_sync": False, "table": "table_1"}]) + self.assertEqual(response.json(), [{"should_sync": True, "table": "table_1"}]) new_team = Team.objects.create(name="new_team", organization=self.team.organization) @@ -262,7 +262,7 @@ def test_internal_postgres(self, patch_get_postgres_schemas): }, ) self.assertEqual(response.status_code, 200) - self.assertEqual(response.json(), [{"should_sync": False, "table": "table_1"}]) + self.assertEqual(response.json(), [{"should_sync": True, "table": "table_1"}]) new_team = Team.objects.create(name="new_team", organization=self.team.organization)