Skip to content

Commit

Permalink
Merge pull request #1075 from geonetwork/GSGCT-139-fix-dates-resources
Browse files Browse the repository at this point in the history
[Datahub] Fix dates
  • Loading branch information
AlitaBernachot authored Jan 29, 2025
2 parents b3f73a3 + 70c055f commit 070a455
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 16 deletions.
15 changes: 13 additions & 2 deletions apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ describe('dataset pages', () => {
.children('div')
.should('have.length', 4)
})
it('should display the creation date, the publication date, the frequency, the languages and the temporal extent', () => {
it('should display the resource creation date (for resource), the publication date (for resource), the frequency, the languages and the temporal extent', () => {
cy.get('datahub-record-metadata')
.find('[id="about"]')
.find('gn-ui-expandable-panel')
Expand All @@ -239,7 +239,18 @@ describe('dataset pages', () => {
.children('div')
.eq(2)
.children('div')
.should('have.length', 5)
.as('aboutContent')
cy.get('@aboutContent').should('have.length', 5)
cy.get('@aboutContent')
.eq(0)
.children('p')
.eq(1)
.should('contain.text', '9/22/2020')
cy.get('@aboutContent')
.eq(1)
.children('p')
.eq(1)
.should('contain.text', '3/17/2024')
})
it('should not display the same text twice in the constraints', () => {
// this dataset has the same text for the license and the legal constraints
Expand Down
14 changes: 9 additions & 5 deletions libs/api/metadata-converter/src/lib/gn4/gn4.converter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1649,9 +1649,10 @@ describe('Gn4Converter', () => {
],
recordCreated: new Date('2021-10-05T12:48:57.678Z'),
recordUpdated: new Date('2021-10-05T12:48:57.678Z'),
recordPublished: new Date('2021-04-01T00:00:00.000Z'),
recordPublished: new Date('2021-11-05T12:48:57.678Z'),
resourceCreated: new Date('2012-01-01T00:00:00.000Z'),
resourceUpdated: new Date('2021-12-13T00:00:00.000Z'),
resourcePublished: new Date('2021-04-01T00:00:00.000Z'),
status: 'ongoing',
topics: ['Installations de suivi environnemental', 'Océans'],
title: 'Surval - Données par paramètre',
Expand Down Expand Up @@ -2092,7 +2093,7 @@ describe('Gn4Converter', () => {
status: null,
lineage: null,
recordUpdated: new Date('2024-10-15T07:37:39.350Z'),
recordPublished: new Date('2023-12-17T23:00:00.000Z'),
recordPublished: null,
ownerOrganization: {
name: 'My Organization',
website: new URL('http://my.org/'),
Expand Down Expand Up @@ -2350,6 +2351,7 @@ describe('Gn4Converter', () => {
otherLanguages: [],
title: 'Service OGC API Records du catalogue NAP-ITS-Wallonia',
resourceUpdated: new Date('2023-12-17T23:00:00.000Z'),
resourcePublished: new Date('2023-12-17T23:00:00.000Z'),
abstract:
"Point d'accès OGC API Records du catalogue NAP-ITS-Wallonia contenant la description des données régionales de mobilité telles que demandé par la législation sur les systèmes de transport intelligents.",
extras: {
Expand Down Expand Up @@ -2974,9 +2976,10 @@ describe('Gn4Converter', () => {
website: new URL('http://my.org/'),
},
recordCreated: new Date('2013-07-29T11:33:08.000Z'),
recordPublished: new Date('2018-03-31T22:00:00.000Z'),
recordPublished: null,
recordUpdated: new Date('2024-07-22T11:52:39.049Z'),
resourceCreated: new Date('2017-05-31T22:00:00.000Z'),
resourcePublished: new Date('2018-03-31T22:00:00.000Z'),
reuseType: 'application',
securityConstraints: [],
spatialExtents: [
Expand Down Expand Up @@ -3277,7 +3280,9 @@ describe('Gn4Converter', () => {
status: 'completed',
lineage: null,
recordUpdated: new Date('2024-01-25T07:45:05.215Z'),
recordPublished: new Date('2023-12-20T14:23:54.000Z'),
recordPublished: null,
recordCreated: new Date('2024-01-25T07:19:13.493Z'),
resourcePublished: new Date('2023-12-20T14:23:54.000Z'),
ownerOrganization: {
name: 'My Organization',
website: new URL('http://my.org/'),
Expand Down Expand Up @@ -3365,7 +3370,6 @@ describe('Gn4Converter', () => {
landingPage: new URL(
'http://my.catalog.org/metadata/be209d24-586f-48f5-b944-e284079b7823'
),
recordCreated: new Date('2024-01-25T07:19:13.493Z'),
})
})
})
Expand Down
12 changes: 8 additions & 4 deletions libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ export class Gn4FieldMapper {
getFirstValue(selectField<string>(source, 'revisionDateForResource'))
),
}),
publicationDateForResource: (output, source) => ({
...output,
resourcePublished: toDate(
selectField<string>(source, 'publicationDateForResource')
),
}),
createDate: (output, source) => ({
...output,
recordCreated: toDate(selectField<string>(source, 'createDate')),
Expand All @@ -136,11 +142,9 @@ export class Gn4FieldMapper {
...output,
recordUpdated: toDate(selectField<string>(source, 'changeDate')),
}),
publicationDateForResource: (output, source) => ({
publicationDate: (output, source) => ({
...output,
recordPublished: toDate(
selectField<string>(source, 'publicationDateForResource')
),
recordPublished: toDate(selectField<string>(source, 'publicationDate')),
}),
resourceLanguage: (output, source) => {
const langList = getAsArray(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,7 @@ export const elasticFullResponseFixture = () => ({
changeDate: '2021-10-05T12:48:57.678Z',
id: '11700',
createDate: '2021-10-05T12:48:57.678Z',
publicationDate: '2021-11-05T12:48:57.678Z',
owner: '100',
groupOwner: '2',
logo: '/images/logos/81e8a591-7815-4d2f-a7da-5673192e74c9.png',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ <h5 translate class="font-medium text-black text-sm mb-[2px] mt-[16px]">
<gn-ui-expandable-panel
*ngIf="
metadata.lineage ||
metadata.recordUpdated ||
metadata.resourceUpdated ||
metadata.updateFrequency ||
metadata.status
"
Expand Down Expand Up @@ -160,16 +160,16 @@ <h5 translate class="font-medium text-black text-sm mb-[2px] mt-[16px]">
<div
class="py-6 px-6 rounded bg-gray-100 grid grid-cols-2 gap-y-6 gap-x-[20px] text-gray-700"
>
<div *ngIf="metadata.recordCreated">
<div *ngIf="metadata.resourceCreated">
<p class="text-sm" translate>record.metadata.creation</p>
<p class="text-primary font-medium mt-1">
{{ metadata.recordCreated.toLocaleDateString() }}
{{ metadata.resourceCreated.toLocaleDateString() }}
</p>
</div>
<div *ngIf="metadata.recordPublished">
<div *ngIf="metadata.resourcePublished">
<p class="text-sm" translate>record.metadata.publication</p>
<p class="text-primary font-medium mt-1">
{{ metadata.recordPublished.toLocaleDateString() }}
{{ metadata.resourcePublished.toLocaleDateString() }}
</p>
</div>
<div *ngIf="updateFrequency">
Expand Down

0 comments on commit 070a455

Please sign in to comment.