-
Notifications
You must be signed in to change notification settings - Fork 6
External sources data cleaning #4
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
base: dev
Are you sure you want to change the base?
Conversation
| async function fetchById(mapDataset) { | ||
| try { | ||
| const response = await fetch(external[mapDataset]); | ||
| const response = await fetch(`${external[mapDataset].url}?${external[mapDataset].query}`); |
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.
Requires query to be defined on all the external datasets. We can run can JavaScript inside curly braces.
const response = await fetch(`${external[mapDataset].url}?${external[mapDataset].query || ''}`);| privatelyOwnedPublicOpenSpaces: { | ||
| url: "https://data.sfgov.org/resource/3ub7-d4yy.geojson", | ||
| query: | ||
| "$query=SELECT name AS title, descriptio AS description, the_geom WHERE the_geom IS NOT NULL", |
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 works and eliminates the need for author: 'DataSF'.
query: '$query=SELECT name AS title, "DataSF" as author, descriptio AS description, the_geom WHERE the_geom IS NOT NULL'
| const dataset = await response.json(); | ||
|
|
||
| return dataset; | ||
| const modifiedDataset = addAuthor(dataset, external[mapDataset].author); |
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.
If each dataset needs to be modified differently this might be a better choice.
return external[mapDataset].modifyDataset
? external[mapDataset].modifyDataset(dataset)
: dataset;| @@ -0,0 +1,8 @@ | |||
| function addAuthor(dataset, author) { | |||
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.
With the modified query string I don't think we'll need this function with the current external datasets.
|
We want to mirror the internal data as close as possible so the properties should include _id, title, description, author and asset. Also, it will make the code easier to read if you keep the same order on all of the query strings. Let's use single quotes for strings as well. |
Updated SOQL query strings for external data from DataSF. Formatted to be consistent with the same data model as internal data sources.