mirror of
https://github.com/bellingcat/datasheet-server.git
synced 2026-06-09 11:58:33 +03:00
Compare commits
13 Commits
grenfell
...
topic/cust
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db2672b630 | ||
|
|
69e54a6027 | ||
|
|
6c090549c7 | ||
|
|
0ee207dc75 | ||
|
|
7e97c5c227 | ||
|
|
978d572660 | ||
|
|
8bd5f38ac4 | ||
|
|
6ab37ccb70 | ||
|
|
4976bfd985 | ||
|
|
d713a15879 | ||
|
|
679407f421 | ||
|
|
3eebf811fb | ||
|
|
be03a3983a |
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
@@ -10,11 +10,16 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
- uses: actions/setup-node@v2-beta
|
||||
with:
|
||||
node-version: '12'
|
||||
|
||||
- run: npm install
|
||||
- run: npm test
|
||||
env:
|
||||
CI: true
|
||||
- run: npm run lint
|
||||
|
||||
env:
|
||||
CI: true
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
CONFIG=../configs/timemap/grenfell/datasheet.config.js
|
||||
@@ -1,7 +1,7 @@
|
||||
import copy from '../copy/en'
|
||||
|
||||
/**
|
||||
* Controller
|
||||
* Controller class
|
||||
*
|
||||
*/
|
||||
class Controller {
|
||||
|
||||
@@ -217,7 +217,10 @@ class GsheetFetcher extends Fetcher {
|
||||
})
|
||||
.then(this._buildBlueprintsAsync())
|
||||
.then(() => true)
|
||||
.catch(() => false)
|
||||
.catch((err) => {
|
||||
console.log(`Error fetching gsheets: ${err.message} `)
|
||||
return false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import path from 'path'
|
||||
import fs from 'fs'
|
||||
import R from 'ramda'
|
||||
|
||||
export const defaultBlueprint = {
|
||||
const defaultBlueprint = {
|
||||
name: null,
|
||||
sheet: {
|
||||
name: null,
|
||||
@@ -11,11 +11,11 @@ export const defaultBlueprint = {
|
||||
resources: {}
|
||||
}
|
||||
|
||||
export const defaultResource = {
|
||||
const defaultResource = {
|
||||
data: []
|
||||
}
|
||||
|
||||
export function buildDesaturated (sheetId, sheetName, tab, resources) {
|
||||
function buildDesaturated (sheetId, sheetName, tab, resources) {
|
||||
const bp = R.clone(defaultBlueprint)
|
||||
bp.sheet.name = sheetName
|
||||
bp.sheet.id = sheetId
|
||||
@@ -50,10 +50,25 @@ 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
|
||||
buildDesaturated,
|
||||
deeprowsWithSchema
|
||||
}, allBps)
|
||||
|
||||
@@ -19,7 +19,6 @@ class StoreJson {
|
||||
|
||||
save (url, data) {
|
||||
const parts = url.split('/')
|
||||
|
||||
return fs.writeFile(
|
||||
`${STORAGE_DIRNAME}/${parts[0]}__${parts[1]}__${parts[2]}.json`,
|
||||
JSON.stringify(data)
|
||||
|
||||
@@ -12,6 +12,8 @@ const egInput1 = [
|
||||
[4, 5, 6]
|
||||
]
|
||||
|
||||
// Test default blueprint exports
|
||||
// Smoke tests
|
||||
test('defaultBlueprint exports', t => {
|
||||
const expected = {
|
||||
sheet: {
|
||||
|
||||
Reference in New Issue
Block a user