10 Commits

Author SHA1 Message Date
Lachlan Kermode
db2672b630 export as deeprowsWithSchema 2021-05-17 16:18:07 +12:00
Lachlan Kermode
69e54a6027 Update yarn lock 2021-05-17 16:01:24 +12:00
Lachlan Kermode
6c090549c7 Add blueprinterWithSchema exporter 2021-05-17 16:01:18 +12:00
efarooqui
0ee207dc75 Linting fixes 2021-04-30 19:34:29 -07:00
efarooqui
7e97c5c227 Minor comment to trigger job 2021-04-30 19:31:16 -07:00
efarooqui
978d572660 Minor comment to trigger job 2021-04-14 19:58:55 -07:00
efarooqui
8bd5f38ac4 Error logging for gsheet fetch 2021-04-14 18:07:48 -07:00
efarooqui
6ab37ccb70 Extraneous comment added to trigger job 2021-04-14 16:35:27 -07:00
efarooqui
4976bfd985 Merge branch 'develop' of https://www.github.com/forensic-architecture/datasheet-server into develop 2021-04-14 16:12:46 -07:00
efarooqui
d713a15879 Adding comment to trigger job 2021-04-14 16:11:40 -07:00
8 changed files with 5781 additions and 10 deletions

View File

@@ -30,10 +30,10 @@ export default ({ config, controller }) => {
success: msg success: msg
}) })
) )
.catch(err => .catch(err => {
res.status(404) res.status(404)
.send({ error: err.message, err }) .send({ error: err.message, err })
) })
}) })
api.get('/:sheet/:tab/:resource/:frag', (req, res) => { api.get('/:sheet/:tab/:resource/:frag', (req, res) => {

View File

@@ -6,7 +6,6 @@ function prefixedTabs (prefix, cfg) {
return { return {
[`${prf('events')}export_events`]: BP.deeprows, [`${prf('events')}export_events`]: BP.deeprows,
[`${prf('associations')}export_associations`]: BP.deeprows, [`${prf('associations')}export_associations`]: BP.deeprows,
[`${prf('editorials')}export_editorials`]: BP.deeprows,
[`${prf('sources')}export_sources`]: BP.deepids, [`${prf('sources')}export_sources`]: BP.deepids,
[`${prf('sites')}export_sites`]: BP.rows [`${prf('sites')}export_sites`]: BP.rows
} }

View File

@@ -1,7 +1,7 @@
import copy from '../copy/en' import copy from '../copy/en'
/** /**
* Controller * Controller class
* *
*/ */
class Controller { class Controller {

View File

@@ -217,7 +217,10 @@ class GsheetFetcher extends Fetcher {
}) })
.then(this._buildBlueprintsAsync()) .then(this._buildBlueprintsAsync())
.then(() => true) .then(() => true)
.catch(() => false) .catch((err) => {
console.log(`Error fetching gsheets: ${err.message} `)
return false
})
} }
} }

View File

@@ -2,7 +2,7 @@ import path from 'path'
import fs from 'fs' import fs from 'fs'
import R from 'ramda' import R from 'ramda'
export const defaultBlueprint = { const defaultBlueprint = {
name: null, name: null,
sheet: { sheet: {
name: null, name: null,
@@ -11,11 +11,11 @@ export const defaultBlueprint = {
resources: {} resources: {}
} }
export const defaultResource = { const defaultResource = {
data: [] data: []
} }
export function buildDesaturated (sheetId, sheetName, tab, resources) { function buildDesaturated (sheetId, sheetName, tab, resources) {
const bp = R.clone(defaultBlueprint) const bp = R.clone(defaultBlueprint)
bp.sheet.name = sheetName bp.sheet.name = sheetName
bp.sheet.id = sheetId bp.sheet.id = sheetId
@@ -50,10 +50,25 @@ fs.readdirSync(normalizedPath).forEach(file => {
allBps[bpName] = buildBlueprinter(bpName, datafier) allBps[bpName] = buildBlueprinter(bpName, datafier)
}) })
function deeprowsWithSchema (datafierName, schema) {
const datafier = data => {
const transformedData = allBps.deeprows('', '', '', data).resources.deeprows.data
return transformedData.map(row => {
Object.keys(schema).forEach(key => {
row[key] = schema[key](row[key])
})
return row
})
}
return buildBlueprinter(`deeprows_${datafierName}`, datafier)
}
// NB: revert to ES5 'module.exports' required to make blueprinters from // NB: revert to ES5 'module.exports' required to make blueprinters from
// each file in blueprinters folder available for granular import from here. // each file in blueprinters folder available for granular import from here.
module.exports = Object.assign({ module.exports = Object.assign({
defaultBlueprint, defaultBlueprint,
defaultResource, defaultResource,
buildDesaturated buildDesaturated,
deeprowsWithSchema
}, allBps) }, allBps)

View File

@@ -19,7 +19,6 @@ class StoreJson {
save (url, data) { save (url, data) {
const parts = url.split('/') const parts = url.split('/')
return fs.writeFile( return fs.writeFile(
`${STORAGE_DIRNAME}/${parts[0]}__${parts[1]}__${parts[2]}.json`, `${STORAGE_DIRNAME}/${parts[0]}__${parts[1]}__${parts[2]}.json`,
JSON.stringify(data) JSON.stringify(data)

View File

@@ -12,6 +12,8 @@ const egInput1 = [
[4, 5, 6] [4, 5, 6]
] ]
// Test default blueprint exports
// Smoke tests
test('defaultBlueprint exports', t => { test('defaultBlueprint exports', t => {
const expected = { const expected = {
sheet: { sheet: {

5753
yarn.lock Normal file

File diff suppressed because it is too large Load Diff