From 339bdac655aa81a137a9f51c7b8d4d1cde4b1abc Mon Sep 17 00:00:00 2001 From: Carina <47381367+ssb-cgn@users.noreply.github.com> Date: Thu, 10 Oct 2024 15:26:15 +0200 Subject: [PATCH] [MIM-1883] Mim 1883 publish dataset draft (#2930) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Teste å hente draftversjon * Added datasource from draft * Remove logging * Fjern Michael som autoassign --- .github/auto_assign.yml | 2 +- src/main/resources/lib/ssb/dataset/publishOld.ts | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/auto_assign.yml b/.github/auto_assign.yml index 654953049..e7baed3a9 100644 --- a/.github/auto_assign.yml +++ b/.github/auto_assign.yml @@ -11,7 +11,7 @@ assignees: - johnnadeluy # - annesiri - Carl-OW - - michaelpande +# - michaelpande # A number of assignees to add to the pull request # Set to 0 to add all of the assignees. diff --git a/src/main/resources/lib/ssb/dataset/publishOld.ts b/src/main/resources/lib/ssb/dataset/publishOld.ts index a0cd2e0d6..dd322229e 100644 --- a/src/main/resources/lib/ssb/dataset/publishOld.ts +++ b/src/main/resources/lib/ssb/dataset/publishOld.ts @@ -3,6 +3,7 @@ import { get as getContent, Content } from '/lib/xp/content' import { NodeQueryResultHit } from '/lib/xp/node' import { send } from '/lib/xp/event' import { executeFunction, sleep } from '/lib/xp/task' +import { run, type ContextParams } from '/lib/xp/context' import { isSameOrBefore } from '/lib/ssb/utils/dateUtils' import { isSameDay } from '/lib/vendor/dateFns' @@ -111,7 +112,18 @@ export function publishDataset(): void { status: JobStatus.STARTED, dataSources: [], } - const dataSourceIds: Array = getDataSourceIdsFromStatistics(stat) + const draftContext: ContextParams = { + branch: 'draft', + } + const statisticDraft: Content | null = run(draftContext, () => { + return getContent({ key: stat._id }) + }) + const dataSourceIdsMaster: Array = getDataSourceIdsFromStatistics(stat) + const dataSourceIdsDraft: Array = statisticDraft ? getDataSourceIdsFromStatistics(statisticDraft) : [] + const uniqueDatasourceDraft: Array = dataSourceIdsDraft.filter( + (item) => !dataSourceIdsMaster.includes(item) + ) + const dataSourceIds: Array = dataSourceIdsMaster.concat(uniqueDatasourceDraft) const dataSources: Array | null> = dataSourceIds.map((key) => { return getContent({ key,