mirror of
https://github.com/bellingcat/datasheet-server.git
synced 2026-06-11 21:08:33 +03:00
Compare commits
1 Commits
topic/cust
...
grenfell
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9455348001 |
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
@@ -10,16 +10,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
|
||||||
ref: ${{ github.head_ref }}
|
|
||||||
- uses: actions/setup-node@v2-beta
|
- uses: actions/setup-node@v2-beta
|
||||||
with:
|
with:
|
||||||
node-version: '12'
|
node-version: '12'
|
||||||
|
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- run: npm test
|
- run: npm test
|
||||||
env:
|
|
||||||
CI: true
|
|
||||||
- run: npm run lint
|
- run: npm run lint
|
||||||
env:
|
|
||||||
CI: true
|
|
||||||
|
|||||||
@@ -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) => {
|
||||||
|
|||||||
1
src/datasheet.config.js
Symbolic link
1
src/datasheet.config.js
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
CONFIG=../configs/timemap/grenfell/datasheet.config.js
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import copy from '../copy/en'
|
import copy from '../copy/en'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller class
|
* Controller
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Controller {
|
class Controller {
|
||||||
|
|||||||
@@ -217,10 +217,7 @@ class GsheetFetcher extends Fetcher {
|
|||||||
})
|
})
|
||||||
.then(this._buildBlueprintsAsync())
|
.then(this._buildBlueprintsAsync())
|
||||||
.then(() => true)
|
.then(() => true)
|
||||||
.catch((err) => {
|
.catch(() => false)
|
||||||
console.log(`Error fetching gsheets: ${err.message} `)
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import path from 'path'
|
|||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import R from 'ramda'
|
import R from 'ramda'
|
||||||
|
|
||||||
const defaultBlueprint = {
|
export const defaultBlueprint = {
|
||||||
name: null,
|
name: null,
|
||||||
sheet: {
|
sheet: {
|
||||||
name: null,
|
name: null,
|
||||||
@@ -11,11 +11,11 @@ const defaultBlueprint = {
|
|||||||
resources: {}
|
resources: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultResource = {
|
export const defaultResource = {
|
||||||
data: []
|
data: []
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildDesaturated (sheetId, sheetName, tab, resources) {
|
export 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,25 +50,10 @@ 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)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ 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)
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ 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: {
|
||||||
|
|||||||
Reference in New Issue
Block a user