fix differential args for fetchers

This commit is contained in:
Lachlan Kermode
2020-04-26 17:17:34 +02:00
parent f34b9224aa
commit d113181bb4
3 changed files with 21 additions and 11 deletions

View File

@@ -15,10 +15,15 @@ export default callback => {
// skip config attrs that don't have corresponding fetchers
if (!(fType in fetchers)) return null
const FFetcher = fetchers[fType]
return config[fType].map(sheet => ({
name: sheet.name,
fetcher: new FFetcher(new StoreJson(), ...Object.values(sheet))
}))
return config[fType].map(sheet => {
const otherArgs = { ...sheet }
delete otherArgs.name
delete otherArgs.tabs
return {
name: sheet.name,
fetcher: new FFetcher(new StoreJson(), sheet.name, sheet.tabs, ...Object.values(otherArgs))
}
})
})
})
.then(res => {

View File

@@ -22,7 +22,6 @@ class Controller {
update () {
return Promise.all(
Object.keys(this.fetchers).map(sheet => {
console.log(sheet)
return this.fetchers[sheet].update()
})
).then(results => {

View File

@@ -1,18 +1,24 @@
import BP from './lib/blueprinters'
const timemapStructure = {
teuruwera_export_events: BP.deeprows,
teuruwera_export_categories: [BP.groups, BP.rows],
export_events: BP.deeprows,
export_categories: [BP.groups, BP.rows],
export_narratives: BP.rows,
teuruwera_export_sources: BP.deepids,
export_sources: BP.deepids,
export_sites: BP.rows,
export_tags: BP.tree
}
export default {
gsheets: [{
name: 'example',
id: '1UC7DkCFeUXHfpUxUGruExwFbP4pqVBdJLOKfo6wDDGk',
tabs: timemapStructure
name: 'nzacts',
tabs: timemapStructure,
id: '1ej3kEtANGYsEBUCTfWsIR0UhTSJIuXFHLYspti2sgHo'
}],
xlsx: [{
name: 'morocco_pushbacks',
tabs: timemapStructure,
path: 'temp/morocco_pushbacks.xlsx'
}]
}