Add buttons, zip, and csv files to be downloaded
Closes #57
Two ways to generate CSV and zip files. One by launching convert_data.js (work if .json are present), the other in query.js (not tested)
The downloading of zip file doesn't work. I don't know what URI I need to use.
I also didn't added data zipped and data in csv, but I can add them if you want.
Thanks for your effort. Would it be possible to generate csv and zip files on-the-fly when you press the download button without pushing it to the server (to put it in git)?
Maybe I didn't understand, but I think that generating a new zip file each time that someone clicks on "Download" is a bad idea if JSON files are not dynamic and uploaded manually. Instead, we can launch the convert_data.js script. If they are dynamic and loaded each time that someone connects on the website, I can generate zip and CSV files on-the-fly.
The json files are currently not dynamic, but I can think of a future feature like download the json or csv only for a few selected languages. We already have the possibility to filter languages in the chart and to share a URL with pre-selected languages. So in this case it would be better to generate the csv and zip file on-the-fly, when a user hits the download button. Another reason is that I want to avoid to commit zip files into git. We already have a single source of truth, that's the json files, all other formats could be converted dynamically. This way it's also not possible to get inconsistent datasets (e.g. different values in csv vs json).
I understand the problem of consistency. Two choices are possible from my mind:
- Generate on the fly the file that asks the user for each file request
- Generate files one time by Github actions
If possible, e.g. it doesn't take too much time, then I would prefer to generate the csv and zip on-the-fly as soon as the user hits the download button. If it takes more than let's say 10 seconds to generate these files, then I would prefer GitHub actions.
I think it's ok to generate it on-the-fly so :smile:
$ time node convert_data.js
real 0m0,124s
user 0m0,121s
sys 0m0,026s
Just, what do I do if the file exists?
Could you elaborate?
Yes, I will try. I don't know if JSON files are sent to the client/navigator but if they aren't, that means that the conversion needs to be made on the server-side. If it is, the question is should I launch a generating or not if files CSV or zip are already generated? And if yes, how can I handle the fact that two users ask for files at the same time?
Isn't it possible to convert json to csv clientside only? So user hits the download button, fetch(json_url) -> store as blob -> convert to csv -> start download, something like this:
https://stackoverflow.com/a/63965930
It could be possible if JSON files were exposed. I don't know how to expose them.
@madnight Hi, I'm back ! (sorry for the delay) . I wanted to try to launch the project and i didn't achieve when I did the yarn install and npm run dev command, I caught an error, maybe due to node version, what is the node version that you support ?
Welcome back,
I develop under Arch Linux which has quite recent node versions. Have you tried "yarn dev" instead of "npm run dev"? Can you provide the error message?
I did a yarn dev but I got the same error message
Starting the development server...
/home/jerem/projects/githut/node_modules/react-scripts/scripts/start.js:19
throw err;
^
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:71:19)
at Object.createHash (node:crypto:140:10)
at module.exports (/home/jerem/projects/githut/node_modules/webpack/lib/util/createHash.js:135:53)
at NormalModule._initBuildHash (/home/jerem/projects/githut/node_modules/webpack/lib/NormalModule.js:417:16)
at /home/jerem/projects/githut/node_modules/webpack/lib/NormalModule.js:452:10
at /home/jerem/projects/githut/node_modules/webpack/lib/NormalModule.js:323:13
at /home/jerem/projects/githut/node_modules/loader-runner/lib/LoaderRunner.js:367:11
at /home/jerem/projects/githut/node_modules/loader-runner/lib/LoaderRunner.js:233:18
at context.callback (/home/jerem/projects/githut/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
at /home/jerem/projects/githut/node_modules/react-scripts/node_modules/babel-loader/lib/index.js:59:103 {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
Node.js v19.1.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Can you tell me the result of your node --version ?
Node 16
it works on node 16, maybe it could be cool to be specified. I will finish this PR so :)
Hello, I went to finished and rebase, I think that all is ready. Let me know if there is something wrong, if you want to add something else or if you have any questions
@madnight still up ?
Merged
Thanks for your work. I moved the button below the table for aesthetical reasons.
There is no problem. Was cool to contribute to this helpful project :)