Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datahub (fix): Handle UpdateFrequency not defined #693

Merged
merged 4 commits into from
Nov 22, 2023

Conversation

tkohr
Copy link
Collaborator

@tkohr tkohr commented Nov 17, 2023

Follow-up for #679 which forgot to handle the UpdateFrequency if not defined: https://www.geo2france.fr/datahub/dataset/33fb5924-d7ea-4ac5-bf1e-651c0600109e

Also added a commit to the html util functions to better handle undefined inputs. Currently, they are only used for the record.abstract which should always be defined, but on the dev instance this will get rid of the 'undefined' strings displayed in the record-preview

this prevents displaying abstract 'undefined' as string in record-preview (although abstract should usually not be undefined)
Copy link
Contributor

github-actions bot commented Nov 17, 2023

Affected libs: api-metadata-converter, feature-editor, feature-search, feature-router, feature-map, feature-dataviz, feature-record, api-repository, feature-catalog, feature-auth, ui-search, ui-elements, ui-catalog, util-shared, ui-widgets, ui-inputs,
Affected apps: metadata-converter, metadata-editor, datahub, demo, webcomponents, search, map-viewer, datafeeder,

  • 🚀 Build and deploy storybook and demo on GitHub Pages
  • 📦 Build and push affected docker images

@tkohr tkohr added bug Something isn't working backport 2.0.x labels Nov 17, 2023
Copy link
Member

@fgravin fgravin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG thanks !

libs/util/shared/src/lib/utils/remove-whitespace.ts Outdated Show resolved Hide resolved
@jahow
Copy link
Collaborator

jahow commented Nov 20, 2023

I'm surprised that the update frequency can be null here. I would expect the key to not be there at all if no frequency could be read, @tkohr could you please describe where this null value comes from? is it from the GN index?

@tkohr
Copy link
Collaborator Author

tkohr commented Nov 21, 2023

I'm surprised that the update frequency can be null here. I would expect the key to not be there at all if no frequency could be read, @tkohr could you please describe where this null value comes from? is it from the GN index?

Indeed, there is no value at all in the GN response. The null comes from here. We also return null here. Should we replace both with undefined?

@jahow
Copy link
Collaborator

jahow commented Nov 21, 2023

updateFrequency is an optional field, so I don't see any reason why we should initialize it with null. I would suggest:

  1. Removing this line
  2. Returning "unkown" here

IMO these issues come from the fact that we don't use the Typescript strict mode, so we sometimes end up with unexpected null values. This is a recurring problem, and I think we should address it at the root, i.e. not putting null values where they're not expected (easier said than done).

What do you think @tkohr ?

@tkohr
Copy link
Collaborator Author

tkohr commented Nov 21, 2023

1. Removing [this](https://github.com/geonetwork/geonetwork-ui/blob/74e14d6e2bf40cee084c6b48e8001a5784b750dc/libs/api/metadata-converter/src/lib/gn4/gn4.metadata.mapper.ts#L25) line

Yes, right, remove it completely.

2. Returning "unkown" [here](https://github.com/geonetwork/geonetwork-ui/blob/74e14d6e2bf40cee084c6b48e8001a5784b750dc/libs/api/metadata-converter/src/lib/iso19139/codelists/update-frequency.mapper.ts#L65)

Why rather unknown than undefined here?

@jahow
Copy link
Collaborator

jahow commented Nov 21, 2023

Why rather unknown than undefined here?

Well if we couldn't match the frequency to anything, it is effectively unknown. If there's no frequency at all in the GN4 record then this shouldn't be called. But I'm not 100% sure, so do as you see fit :)

@tkohr
Copy link
Collaborator Author

tkohr commented Nov 21, 2023

Yes, right, got it, so I've used unknown now.

@tkohr
Copy link
Collaborator Author

tkohr commented Nov 21, 2023

Hum, so not returning null in the mapper broke this test, but I'm struggling to figure out where (in which transformation direction).

@jahow
Copy link
Collaborator

jahow commented Nov 21, 2023

Hum, so not returning null in the mapper broke this test, but I'm struggling to figure out where (in which transformation direction).

if it's taking you too far forget it, let's not spend too much time on this

@tkohr tkohr force-pushed the updateFrequency-undefined branch from 8a489e2 to fa4dc70 Compare November 22, 2023 09:53
@coveralls
Copy link

Coverage Status

coverage: 82.796% (-1.1%) from 83.888%
when pulling fa4dc70 on updateFrequency-undefined
into bd29f62 on main.

@tkohr
Copy link
Collaborator Author

tkohr commented Nov 22, 2023

Ok, I've kept the null as default value in the update-frequency.mapper, but removed it from initial record in the gn4.metadata.mapper.

Copy link
Collaborator

@jahow jahow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@tkohr tkohr merged commit 36a3f6c into main Nov 22, 2023
7 checks passed
@tkohr tkohr deleted the updateFrequency-undefined branch November 22, 2023 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants