From 8f165d5b684c564514f17b4c42cd9a51ada82d4b Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Fri, 6 Dec 2024 17:02:49 +0000 Subject: [PATCH] types --- .../processors/posthog/PosthogProcessor.ts | 2 -- .../src/events/publishers/view.ts | 1 - .../server/src/api/controllers/view/views.ts | 21 ------------------- .../functions/backfill/app/tables.ts | 18 ---------------- packages/server/src/sdk/app/views/external.ts | 4 ++-- packages/server/src/sdk/app/views/internal.ts | 2 +- 6 files changed, 3 insertions(+), 45 deletions(-) diff --git a/packages/backend-core/src/events/processors/posthog/PosthogProcessor.ts b/packages/backend-core/src/events/processors/posthog/PosthogProcessor.ts index 687fe54256..4700b47be2 100644 --- a/packages/backend-core/src/events/processors/posthog/PosthogProcessor.ts +++ b/packages/backend-core/src/events/processors/posthog/PosthogProcessor.ts @@ -13,8 +13,6 @@ const EXCLUDED_EVENTS: Event[] = [ Event.ROLE_UPDATED, Event.DATASOURCE_UPDATED, Event.QUERY_UPDATED, - // Event.TABLE_UPDATED, - // Event.VIEW_UPDATED, Event.VIEW_FILTER_UPDATED, Event.VIEW_CALCULATION_UPDATED, Event.AUTOMATION_TRIGGER_UPDATED, diff --git a/packages/backend-core/src/events/publishers/view.ts b/packages/backend-core/src/events/publishers/view.ts index 6d107d58f3..3097ae4cfa 100644 --- a/packages/backend-core/src/events/publishers/view.ts +++ b/packages/backend-core/src/events/publishers/view.ts @@ -30,7 +30,6 @@ async function created(view: ViewV2, timestamp?: string | number) { } async function updated(newView: ViewV2) { - // // check whether any of the fields are different let viewJoins = 0 for (const key in newView.schema) { if (newView.schema[key]?.columns) { diff --git a/packages/server/src/api/controllers/view/views.ts b/packages/server/src/api/controllers/view/views.ts index f1aa219aca..9fdd808d38 100644 --- a/packages/server/src/api/controllers/view/views.ts +++ b/packages/server/src/api/controllers/view/views.ts @@ -65,27 +65,6 @@ export async function save(ctx: Ctx) { builderSocket?.emitTableUpdate(ctx, table) } -// export async function calculationEvents(existingView: View, newView: View) { -// const existingCalculation = existingView && existingView.calculation -// const newCalculation = newView && newView.calculation -// -// if (existingCalculation && !newCalculation) { -// await events.view.calculationDeleted(existingView) -// } -// -// if (!existingCalculation && newCalculation) { -// await events.view.calculationCreated(newView) -// } -// -// if ( -// existingCalculation && -// newCalculation && -// existingCalculation !== newCalculation -// ) { -// await events.view.calculationUpdated(newView) -// } -// } - export async function filterEvents(existingView: View, newView: View) { const hasExistingFilters = !!( existingView && diff --git a/packages/server/src/migrations/functions/backfill/app/tables.ts b/packages/server/src/migrations/functions/backfill/app/tables.ts index c6e46173dc..e8437bd529 100644 --- a/packages/server/src/migrations/functions/backfill/app/tables.ts +++ b/packages/server/src/migrations/functions/backfill/app/tables.ts @@ -7,24 +7,6 @@ export const backfill = async (appDb: Database, timestamp: string | number) => { for (const table of tables) { await events.table.created(table, timestamp) - - if (table.views) { - for (const view of Object.values(table.views)) { - if (sdk.views.isV2(view)) { - continue - } - - // await events.view.created(view, timestamp) - - if (view.calculation) { - await events.view.calculationCreated(view, timestamp) - } - - if (view.filters?.length) { - await events.view.filterCreated(view, timestamp) - } - } - } } return tables.length diff --git a/packages/server/src/sdk/app/views/external.ts b/packages/server/src/sdk/app/views/external.ts index 9016a3bd61..65e0ff410d 100644 --- a/packages/server/src/sdk/app/views/external.ts +++ b/packages/server/src/sdk/app/views/external.ts @@ -63,7 +63,7 @@ export async function create( export async function update( tableId: string, view: Readonly -): Promise<{ view: ViewV2; existingView: ViewV2 }> { +): Promise<{ view: Readonly; existingView: ViewV2 }> { const db = context.getAppDB() const { datasourceId, tableName } = breakExternalTableId(tableId) @@ -87,7 +87,7 @@ export async function update( delete views[existingView.name] views[view.name] = view await db.put(ds) - return { view, existingView } + return { view, existingView } as { view: ViewV2; existingView: ViewV2 } } export async function remove(viewId: string): Promise { diff --git a/packages/server/src/sdk/app/views/internal.ts b/packages/server/src/sdk/app/views/internal.ts index ec152abe54..4f7abad357 100644 --- a/packages/server/src/sdk/app/views/internal.ts +++ b/packages/server/src/sdk/app/views/internal.ts @@ -76,7 +76,7 @@ export async function update( delete table.views[existingView.name] table.views[view.name] = view await db.put(table) - return { view, existingView } + return { view, existingView } as { view: ViewV2; existingView: ViewV2 } } export async function remove(viewId: string): Promise {