From 3c18d54f3e563325b262cca439780292a3f59089 Mon Sep 17 00:00:00 2001 From: Tom Owers Date: Fri, 21 Jun 2024 10:10:28 +0100 Subject: [PATCH 1/9] Added incremental syncs for postgres --- frontend/src/lib/api.ts | 4 + .../lib/lemon-ui/LemonRadio/LemonRadio.tsx | 10 +- .../external/forms/PostgresSchemaForm.tsx | 187 ++++---- .../external/forms/SyncMethodForm.tsx | 184 ++++++++ .../data-warehouse/new/sourceWizardLogic.tsx | 53 ++- .../settings/DataWarehouseSourcesTable.tsx | 398 ++++++++++++------ .../settings/dataWarehouseSettingsLogic.ts | 42 +- ...rehouseSourcesTableSyncMethodModalLogic.ts | 66 +++ frontend/src/types.ts | 24 +- latest_migrations.manifest | 2 +- ...30_externaldataschema_sync_type_payload.py | 45 ++ .../data_imports/pipelines/helpers.py | 9 + .../data_imports/pipelines/pipeline.py | 40 +- .../data_imports/pipelines/schemas.py | 19 +- .../pipelines/sql_database/__init__.py | 49 ++- .../pipelines/sql_database/helpers.py | 16 +- .../data_imports/pipelines/stripe/settings.py | 65 ++- .../pipelines/zendesk/settings.py | 12 + .../workflow_activities/import_data.py | 90 ++-- posthog/warehouse/api/external_data_schema.py | 175 +++++++- posthog/warehouse/api/external_data_source.py | 97 ++++- .../warehouse/models/external_data_schema.py | 66 ++- posthog/warehouse/types.py | 17 + requirements.in | 2 +- requirements.txt | 2 +- 25 files changed, 1348 insertions(+), 326 deletions(-) create mode 100644 frontend/src/scenes/data-warehouse/external/forms/SyncMethodForm.tsx create mode 100644 frontend/src/scenes/data-warehouse/settings/dataWarehouseSourcesTableSyncMethodModalLogic.ts create mode 100644 posthog/migrations/0430_externaldataschema_sync_type_payload.py create mode 100644 posthog/warehouse/types.py diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index bded3aa4f319d..1fc8b95f37abf 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -73,6 +73,7 @@ import { RolesListParams, RoleType, ScheduledChangeType, + SchemaIncrementalFieldsResponse, SearchListParams, SearchResponse, SessionRecordingPlaylistType, @@ -2070,6 +2071,9 @@ const api = { async resync(schemaId: ExternalDataSourceSchema['id']): Promise { await new ApiRequest().externalDataSourceSchema(schemaId).withAction('resync').create() }, + async incremental_fields(schemaId: ExternalDataSourceSchema['id']): Promise { + return await new ApiRequest().externalDataSourceSchema(schemaId).withAction('incremental_fields').create() + }, }, dataWarehouseViewLinks: { diff --git a/frontend/src/lib/lemon-ui/LemonRadio/LemonRadio.tsx b/frontend/src/lib/lemon-ui/LemonRadio/LemonRadio.tsx index badc2cb919b12..58d4bd01adc59 100644 --- a/frontend/src/lib/lemon-ui/LemonRadio/LemonRadio.tsx +++ b/frontend/src/lib/lemon-ui/LemonRadio/LemonRadio.tsx @@ -14,6 +14,7 @@ export interface LemonRadioProps { onChange: (newValue: T) => void options: LemonRadioOption[] className?: string + radioPosition?: 'center' | 'top' } /** Single choice radio. */ @@ -22,6 +23,7 @@ export function LemonRadio({ onChange, options, className, + radioPosition, }: LemonRadioProps): JSX.Element { return (
@@ -30,8 +32,12 @@ export function LemonRadio({