-
Notifications
You must be signed in to change notification settings - Fork 0
allow customers to append custom distributions to the dcat:distribution
array
#18
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
Conversation
70199f3
to
d1481de
Compare
@@ -203,91 +195,154 @@ describe('formatDcatDataset', () => { | |||
'dct:title': 'OGC WMS', | |||
}, | |||
}; | |||
const result = JSON.parse(formatDcatDataset(distDataset, defaultFormatTemplate)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a big diff, but if you open in VSC mode (hit .
), you'll see that I moved all of this into a nested distributions
describe and made the following changes:
- Create a
distributions
const that all tests can reference, reducing redundancy - Create a
getDistributions
testing helper that returns the underlying parseddcat:distribution
array for each test (greatly simplifies the expect statements for each test) - Verify order of all distributions explicitly (since we were implicitly checking before)
- Add tests around appending custom distributions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, well thought out
@@ -46,9 +46,10 @@ export function formatDcatDataset(dcatDataset: any, template: DatasetFormatTempl | |||
|
|||
const formattedDataset = adlib(template, dcatDataset, transforms); | |||
|
|||
setLeftoverInterpolations(formattedDataset); | |||
// reset uninterpolated, non-editable fields since customers cannot remove them | |||
resetUninterpolatedPaths(formattedDataset, nonEditableFieldPaths); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I revisited setLeftoverInterpolations
for the first time, I could not for the life of me remember why we had this function. I eventually figured it out, but if I (who approved the original PR) had a hard time remembering the purpose of the function, I guarantee you that others will as well.
Changing the name to something like resetUninterpolatedPathsOfUneditableFields
seemed way too verbose, so I opted to create a generic function name, explicitly pass in nonEditableFieldPaths
and add in a clarifying comment. I'm hoping this semantic change will be a little more friendly for future devs (including ourselves).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine by me
@@ -46,9 +46,10 @@ export function formatDcatDataset(dcatDataset: any, template: DatasetFormatTempl | |||
|
|||
const formattedDataset = adlib(template, dcatDataset, transforms); | |||
|
|||
setLeftoverInterpolations(formattedDataset); | |||
// reset uninterpolated, non-editable fields since customers cannot remove them | |||
resetUninterpolatedPaths(formattedDataset, nonEditableFieldPaths); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine by me
@@ -203,91 +195,154 @@ describe('formatDcatDataset', () => { | |||
'dct:title': 'OGC WMS', | |||
}, | |||
}; | |||
const result = JSON.parse(formatDcatDataset(distDataset, defaultFormatTemplate)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, well thought out
Part of https://devtopia.esri.com/dc/hub/issues/1188.
To allow customers to add custom distributions to their feed via their dcat config, I made a few changes:
dcat:distribution
from the list of non-editable fieldsdcat:distribution
through adlibdcat:distribution
array IFF the adlib result is an arrayWe are not adding any validation as part of this PR. If the dcat config's
dcat:distribution
is an array, we just throw it in there.