From 0c825a50c8de0acf38ceca7d2b6d4e635fae40d0 Mon Sep 17 00:00:00 2001 From: alicegoarnisson Date: Wed, 18 Dec 2024 11:43:26 +0100 Subject: [PATCH] feat(orga): added new attribute in builder --- .../factory/build-knowledge-element-snapshot.js | 2 ++ .../factory/knowledge-elements-snapshot-factory.js | 3 ++- api/db/seeds/data/common/tooling/campaign-tooling.js | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/api/db/database-builder/factory/build-knowledge-element-snapshot.js b/api/db/database-builder/factory/build-knowledge-element-snapshot.js index 854e6ef788f..1a3888501e8 100644 --- a/api/db/database-builder/factory/build-knowledge-element-snapshot.js +++ b/api/db/database-builder/factory/build-knowledge-element-snapshot.js @@ -9,6 +9,7 @@ const buildKnowledgeElementSnapshot = function ({ userId, snappedAt = new Date('2020-01-01'), snapshot, + campaignParticipationId, } = {}) { const dateMinusOneDay = new Date(snappedAt.getTime() - 1000 * 60 * 60 * 24 * 7); userId = _.isUndefined(userId) ? buildUser().id : userId; @@ -24,6 +25,7 @@ const buildKnowledgeElementSnapshot = function ({ userId, snappedAt, snapshot, + campaignParticipationId, }; return databaseBuffer.pushInsertable({ diff --git a/api/db/database-builder/factory/knowledge-elements-snapshot-factory.js b/api/db/database-builder/factory/knowledge-elements-snapshot-factory.js index d173d79eb95..d6b6c896cf7 100644 --- a/api/db/database-builder/factory/knowledge-elements-snapshot-factory.js +++ b/api/db/database-builder/factory/knowledge-elements-snapshot-factory.js @@ -1,7 +1,7 @@ import { databaseBuffer } from '../database-buffer.js'; import { buildKnowledgeElement } from './build-knowledge-element.js'; -function buildSnapshot({ id, userId, snappedAt, knowledgeElementsAttributes }) { +function buildSnapshot({ id, userId, snappedAt, knowledgeElementsAttributes, campaignParticipationId }) { const knowledgeElements = knowledgeElementsAttributes.map((attributes) => buildKnowledgeElement(attributes)); const values = { @@ -9,6 +9,7 @@ function buildSnapshot({ id, userId, snappedAt, knowledgeElementsAttributes }) { userId, snappedAt, snapshot: JSON.stringify(knowledgeElements), + campaignParticipationId, }; return databaseBuffer.pushInsertable({ diff --git a/api/db/seeds/data/common/tooling/campaign-tooling.js b/api/db/seeds/data/common/tooling/campaign-tooling.js index 7adb4bc70a8..bbdcfc41351 100644 --- a/api/db/seeds/data/common/tooling/campaign-tooling.js +++ b/api/db/seeds/data/common/tooling/campaign-tooling.js @@ -404,6 +404,7 @@ async function createProfilesCollectionCampaign({ userId, snappedAt: sharedAt, snapshot: JSON.stringify(keDataForSnapshot), + campaignParticipationId, }); await databaseBuilder.commit();