mirror of
https://github.com/bellingcat/datasheet-server.git
synced 2026-06-11 12:58:32 +03:00
New export route working to query all blueprints and add to one data object; need to write to file
This commit is contained in:
@@ -39,8 +39,29 @@ class Controller {
|
||||
})
|
||||
}
|
||||
|
||||
retrieveAll (blueprints) {
|
||||
// index through bps, grab data and add to existing data object with value for url name and data points for data object, write to file and return success msg; catch errors appropriately
|
||||
retrieveAll (fileDest) {
|
||||
if (fileDest === '') throw new Error(copy.errors.export)
|
||||
|
||||
const indexedData = {}
|
||||
const urls = []
|
||||
|
||||
const bps = this.blueprints()
|
||||
return Promise.all(
|
||||
bps.map(bp => {
|
||||
const resource = Object.keys(bp.resources)[0]
|
||||
urls.push(bp.urls[0])
|
||||
return this.retrieve(bp.sheet.name, bp.name, resource)
|
||||
})
|
||||
).then(results => {
|
||||
if (results.every(res => res)) {
|
||||
urls.forEach((item, idx) => {
|
||||
indexedData[item] = results[idx]
|
||||
})
|
||||
return 'Success'
|
||||
} else {
|
||||
throw new Error(copy.errors.export)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
retrieve (sheet, tab, resource) {
|
||||
|
||||
Reference in New Issue
Block a user