From 337d826a078d1f30b6e6d54ddb35537755be8c71 Mon Sep 17 00:00:00 2001 From: sinatragianpaolo Date: Tue, 18 Jun 2024 12:45:24 +0200 Subject: [PATCH] Remove unused code for insights in PATCH /campaigns/{campaignId}/ux --- .../ux/_patch/delete-sentiments.spec.ts | 1 - .../ux/_patch/draft-modified.spec.ts | 102 ------------------ .../campaignId/ux/_patch/index.spec.ts | 1 - .../campaigns/campaignId/ux/_patch/index.ts | 39 ------- 4 files changed, 143 deletions(-) diff --git a/src/routes/campaigns/campaignId/ux/_patch/delete-sentiments.spec.ts b/src/routes/campaigns/campaignId/ux/_patch/delete-sentiments.spec.ts index 9ae4f1bfc..3bd8d672f 100644 --- a/src/routes/campaigns/campaignId/ux/_patch/delete-sentiments.spec.ts +++ b/src/routes/campaigns/campaignId/ux/_patch/delete-sentiments.spec.ts @@ -34,7 +34,6 @@ const campaign = { const requestBody = { goal: "Test Goal", usersNumber: 5, - insights: [], sentiments: [], questions: [], methodology: { diff --git a/src/routes/campaigns/campaignId/ux/_patch/draft-modified.spec.ts b/src/routes/campaigns/campaignId/ux/_patch/draft-modified.spec.ts index 5337c80df..610bd26c6 100644 --- a/src/routes/campaigns/campaignId/ux/_patch/draft-modified.spec.ts +++ b/src/routes/campaigns/campaignId/ux/_patch/draft-modified.spec.ts @@ -59,81 +59,12 @@ describe("PATCH /campaigns/{campaignId}/ux - from draft modified", () => { published: 0, }, ]); - - await tryber.tables.UxCampaignInsights.do().insert([ - { - id: 1, - campaign_id: 123, - version: 1, - title: "Publish insight", - description: "Publish description", - severity_id: 1, - cluster_ids: "1", - finding_id: 10, - enabled: 1, - }, - { - id: 2, - campaign_id: 123, - version: 1, - title: "Publish insight 2", - description: "Publish description 2", - severity_id: 1, - cluster_ids: "1", - finding_id: 20, - enabled: 1, - }, - // Draft modified insights - { - id: 3, - campaign_id: 123, - version: 2, - title: "Publish insight", - description: "Publish description", - severity_id: 1, - cluster_ids: "1", - finding_id: 10, - enabled: 1, - }, - { - id: 4, - campaign_id: 123, - version: 2, - title: "Publish insight 2", - description: "Publish description 2", - severity_id: 1, - cluster_ids: "1", - finding_id: 20, - enabled: 1, - }, - ]); - - await tryber.tables.UxCampaignVideoParts.do().insert([ - { - id: 1, - media_id: 1, - insight_id: 2, - start: 0, - end: 10, - description: "Publish video part", - }, - { - id: 2, - media_id: 1, - insight_id: 4, - start: 0, - end: 10, - description: "Publish video part", - }, - ]); }); afterAll(async () => { await tryber.tables.WpAppqEvdCampaign.do().delete(); await tryber.tables.UxCampaignData.do().delete(); await tryber.tables.WpAppqUserTaskMedia.do().delete(); - await tryber.tables.UxCampaignInsights.do().delete(); - await tryber.tables.UxCampaignVideoParts.do().delete(); await tryber.tables.UxCampaignQuestions.do().delete(); }); @@ -144,35 +75,6 @@ describe("PATCH /campaigns/{campaignId}/ux - from draft modified", () => { .send({ goal: "Test Goal", usersNumber: 5, - insights: [ - { - id: 3, - title: "Publish insight", - description: "Publish description", - order: 0, - severityId: 1, - clusterIds: [1], - videoParts: [], - }, - { - id: 4, - title: "Publish insight 2", - description: "Publish description 2", - order: 0, - severityId: 1, - clusterIds: [1], - videoParts: [ - { - id: 2, - order: 0, - start: 0, - end: 10, - mediaId: 1, - description: "Publish video part", - }, - ], - }, - ], sentiments: [], questions: [], methodology, @@ -198,9 +100,5 @@ describe("PATCH /campaigns/{campaignId}/ux - from draft modified", () => { campaign_id: 123, }) ); - - const videoParts = await tryber.tables.UxCampaignVideoParts.do().select(); - - expect(videoParts.length).toBe(2); }); }); diff --git a/src/routes/campaigns/campaignId/ux/_patch/index.spec.ts b/src/routes/campaigns/campaignId/ux/_patch/index.spec.ts index 87d18745d..7f1206ae8 100644 --- a/src/routes/campaigns/campaignId/ux/_patch/index.spec.ts +++ b/src/routes/campaigns/campaignId/ux/_patch/index.spec.ts @@ -21,7 +21,6 @@ const campaign = { const requestBody = { goal: "Test Goal", usersNumber: 5, - insights: [], sentiments: [], questions: [], methodology: { diff --git a/src/routes/campaigns/campaignId/ux/_patch/index.ts b/src/routes/campaigns/campaignId/ux/_patch/index.ts index 5c74af590..656696436 100644 --- a/src/routes/campaigns/campaignId/ux/_patch/index.ts +++ b/src/routes/campaigns/campaignId/ux/_patch/index.ts @@ -283,7 +283,6 @@ export default class PatchUx extends UserRoute<{ } await this.publishData(); - await this.publishInsight(); await this.publishQuestions(); await this.publishSentiments(); this.version++; @@ -353,42 +352,4 @@ export default class PatchUx extends UserRoute<{ } } } - - private async publishInsight() { - const draftData = this.lastDraft?.data; - if (!draftData) throw new OpenapiError("No draft found"); - - let findingOrder = 0; - for (const insight of draftData.findings) { - const insertedInsight = await tryber.tables.UxCampaignInsights.do() - .insert({ - campaign_id: this.campaignId, - cluster_ids: - insight.clusters === "all" - ? "0" - : insight.clusters.map((c) => c.id).join(","), - description: insight.description, - order: findingOrder++, - severity_id: insight.severity.id, - title: insight.title, - version: this.version + 1, - finding_id: insight.findingId, - }) - .returning("id"); - - const insertedInsightId = insertedInsight[0].id ?? insertedInsight[0]; - - let videoPartOrder = 0; - for (const videoPart of insight.videoParts) { - await tryber.tables.UxCampaignVideoParts.do().insert({ - start: videoPart.start, - end: videoPart.end, - media_id: videoPart.mediaId, - description: videoPart.description, - order: videoPartOrder++, - insight_id: insertedInsightId, - }); - } - } - } }