1 Commits

Author SHA1 Message Date
efarooqui
b65c4ad2e2 Adding export_editorials endpoint for vertical stories 2021-03-02 14:09:06 -08:00
8 changed files with 10 additions and 5781 deletions

View File

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

View File

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

View File

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

View File

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

View File

@@ -2,7 +2,7 @@ import path from 'path'
import fs from 'fs'
import R from 'ramda'
const defaultBlueprint = {
export const defaultBlueprint = {
name: null,
sheet: {
name: null,
@@ -11,11 +11,11 @@ const defaultBlueprint = {
resources: {}
}
const defaultResource = {
export const defaultResource = {
data: []
}
function buildDesaturated (sheetId, sheetName, tab, resources) {
export function buildDesaturated (sheetId, sheetName, tab, resources) {
const bp = R.clone(defaultBlueprint)
bp.sheet.name = sheetName
bp.sheet.id = sheetId
@@ -50,25 +50,10 @@ fs.readdirSync(normalizedPath).forEach(file => {
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
// each file in blueprinters folder available for granular import from here.
module.exports = Object.assign({
defaultBlueprint,
defaultResource,
buildDesaturated,
deeprowsWithSchema
buildDesaturated
}, allBps)

View File

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

View File

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

5753
yarn.lock

File diff suppressed because it is too large Load Diff