From 4141f13f344885ce653eede0f89c8557ef3461ff Mon Sep 17 00:00:00 2001 From: Giacomo Citi Date: Thu, 2 May 2024 12:08:55 +0200 Subject: [PATCH] published date on first revision --- apis/core/lib/domain/job/update.ts | 2 +- apis/core/test/domain/job/update.test.ts | 27 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/apis/core/lib/domain/job/update.ts b/apis/core/lib/domain/job/update.ts index e257fcfef..db1fbc0d4 100644 --- a/apis/core/lib/domain/job/update.ts +++ b/apis/core/lib/domain/job/update.ts @@ -30,7 +30,7 @@ export async function update({ resource, store }: JobUpdateParams): Promise(project.dataset.id) - if (job.revision === 1) { + if (job.revision === 1 && !dataset.published) { dataset.setPublishedDate(job.modified) } } else if (isTransformJob(job)) { diff --git a/apis/core/test/domain/job/update.test.ts b/apis/core/test/domain/job/update.test.ts index 39c195bd0..a513b758e 100644 --- a/apis/core/test/domain/job/update.test.ts +++ b/apis/core/test/domain/job/update.test.ts @@ -202,6 +202,33 @@ describe('domain/job/update', () => { }) }) + it('does not change dataset published date on first revision', async () => { + // given + const resource = clownface({ dataset: $rdf.dataset() }) + .namedNode('job') + .addOut(schema.actionStatus, schema.CompletedActionStatus) + .addOut(dcterms.modified, $rdf.literal('2020-12-12T11:30:30', xsd.dateTime)) + job + .addOut(cc.revision, 1) + dataset.addOut(schema.datePublished, $rdf.literal('2020-10-12', xsd.date)) + + // when + await update({ + resource, + store, + }) + + // then + expect(dataset).to.matchShape({ + property: { + path: schema.datePublished, + hasValue: $rdf.literal('2020-10-12', xsd.date), + minCount: 1, + maxCount: 1, + }, + }) + }) + it('does not change dataset published date on revision>1', async () => { // given const resource = clownface({ dataset: $rdf.dataset() })