-
Notifications
You must be signed in to change notification settings - Fork 30
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
Export endpoint for ds-s #68
base: develop
Are you sure you want to change the base?
Conversation
…veAll call for controller
…object; need to write to file
Is there a known reason that the CI hangs on |
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 LGTM. We also talked at one point about some runtime parameter when starting up datasheet-server (i.e. npm run dev -- --headless
) which bypasses the loop that keeps the server available, and just pulls the data, saves it to disk, and then completes. It would make sense to me if that logic were added to this PR, along with a modification to the test suite that checks it works as expected when passed the flag.
src/api/index.js
Outdated
@@ -4,6 +4,7 @@ import copy from '../copy/en' | |||
|
|||
export default ({ config, controller }) => { | |||
let api = Router() | |||
const fileDest = config.EXPORT_FILE_DEST || "" |
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.
What is the logic behind the default here being an empty string? Would it be better as 'data_export.json' or something similarly generic?
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.
Ah I see down below that the empty string is being used as a 'null' value. Maybe we explicitly use null
instead?
Nice work @ebefarooqui, this looks good to me code-wise. I can't seem to export when running To echo @breezykermo's comment, personally I would find it very useful if we were able to invoke datasheet as a globally installed-CLI tool (eg |
|
Didn't mean to close the above ^ |
@zacoppotamus I'm in favor of trying to modify ds-s to be a CLI-esque tool that is dynamic and compatible with these exported json files. This I feel would exist as an alternative way of using ds-s but wouldnt necessarily require rehashing everything. I'm going to pull down and see if everything checks out, not sure why youre having that issue. Could be because the server is looking for the config and .env files and they might not be in the right locations? We'll see |
@breezykermo I can take a look at making the logic run as an |
I think the startup for datasheet already runs via npm scripts, |
I initially went about it this way but wanted to expose an endpoint for researchers to use as well instead of having to run it as an npm script. I could write an additional npm script as well, not opposed. |
@zacoppotamus I believe you need to run the command as so |
@ebefarooqui thanks Ebe, works great. |
This PR creates an endpoint /api/export which retrieves all resources in the sheet and writes them to a singular file specified by the env var EXPORT_FILE_DEST
The data in the file is a JSON object indexed like the following:
Ping me and I'll send you an example file