This commit is contained in:
Konstantin Mamalakis 2018-03-16 17:54:44 +02:00 committed by Josh Harvey
parent 65f0e852d0
commit 577a85c9b1
3 changed files with 13 additions and 7 deletions

View file

@ -54,6 +54,12 @@ const parseSource = source => {
const readStream = fs.createReadStream(source)
const jsonStream = readStream.pipe(ndjson.parse())
jsonStream.on('data', individual => {
_.forEach(period => {
_.forEach(date => {
const {year, month, day} = date
date.date = new Date(year, month - 1, day)
}, [period.start, period.end])
}, individual.birthDatePeriods)
individuals.push(individual)
})

View file

@ -93,9 +93,7 @@ function processDate (dateNode) {
const year = parseInt(dateNode.Year)
const month = parseInt(dateNode.Month)
const day = parseInt(dateNode.Day)
const date = new Date(year, month - 1, day)
return {year, month, day, date}
return {year, month, day}
}
function processFeature (featureNode) {

View file

@ -114,8 +114,8 @@ const individualA = {id: '9', aliases: [{id: '5',
{value: 'john', phonetics: ['JN', 'AN']},
{value: 'doe', phonetics: ['T']}]}],
birthDatePeriods: [{
start: {year: 1955, month: 10, day: 5, date: new Date(1955, 9, 5)},
end: {year: 1955, month: 10, day: 5, date: new Date(1955, 9, 5)}}]
start: {year: 1955, month: 10, day: 5},
end: {year: 1955, month: 10, day: 5}}]
}
const individualB = {id: '11', aliases: [{id: '15',
@ -129,8 +129,8 @@ const individualB = {id: '11', aliases: [{id: '15',
{value: 'de', phonetics: ['T']},
{value: 'gaul', phonetics: ['KL']}]}],
birthDatePeriods: [{
start: {year: 1965, month: 11, day: 20, date: new Date(1965, 10, 20)},
end: {year: 1965, month: 11, day: 20, date: new Date(1965, 10, 20)}}]
start: {year: 1965, month: 11, day: 20},
end: {year: 1965, month: 11, day: 20}}]
}
@ -180,6 +180,8 @@ describe('OFAC', function () {
.then(([individuals]) => {
assert.ok(Array.isArray(individuals))
assert.equal(individuals.length, 2)
console.log(JSON.stringify(individuals[0]))
console.log(JSON.stringify(individualA))
assert.deepEqual(individuals, [individualA, individualB])
})
})