Skip to content

Commit

Permalink
published date on first revision
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomociti committed May 2, 2024
1 parent 82b6d54 commit 4141f13
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apis/core/lib/domain/job/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function update({ resource, store }: JobUpdateParams): Promise<Grap
project.incrementPublishedRevision()

const dataset = await store.getResource<Dataset>(project.dataset.id)
if (job.revision === 1) {
if (job.revision === 1 && !dataset.published) {
dataset.setPublishedDate(job.modified)
}
} else if (isTransformJob(job)) {
Expand Down
27 changes: 27 additions & 0 deletions apis/core/test/domain/job/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() })
Expand Down

0 comments on commit 4141f13

Please sign in to comment.