Skip to content

Commit

Permalink
Data update
Browse files Browse the repository at this point in the history
  • Loading branch information
carlaiau committed Apr 16, 2020
1 parent 6b6bbc7 commit 420ce35
Show file tree
Hide file tree
Showing 8 changed files with 11,808 additions and 10,563 deletions.
4,170 changes: 3,664 additions & 506 deletions client/data/advanced.json

Large diffs are not rendered by default.

1,784 changes: 1,476 additions & 308 deletions client/data/countries.json

Large diffs are not rendered by default.

3,539 changes: 3,323 additions & 216 deletions client/data/cumulative.json

Large diffs are not rendered by default.

12,765 changes: 3,305 additions & 9,460 deletions client/data/nz-advanced.json

Large diffs are not rendered by default.

52 changes: 21 additions & 31 deletions client/src/components/regional-new-zealand/nz-regional-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,16 @@ const NZRegionalView = ({width, height}) => {
dateObject
ages {
_1
_10_to_14
_15_to_19
_1_to_4
_20_to_29
_30_to_39
_40_to_49
_50_to_59
_5_to_9
_60_to_69
_70_
}
genders {
Female
Male
Undefined
_70_
_10_to_14
_15_to_19
_1_to_4
_20_to_29
_30_to_39
_40_to_49
_50_to_59
_5_to_9
_60_to_69
}
}
highest {
Expand All @@ -43,23 +38,18 @@ const NZRegionalView = ({width, height}) => {
confirmed
dateForSort
dateObject
genders {
Female
Male
Undefined
}
ages {
_1
_10_to_14
_15_to_19
_20_to_29
_1_to_4
_30_to_39
_40_to_49
_50_to_59
_60_to_69
_5_to_9
_70_
_70_
_10_to_14
_15_to_19
_1_to_4
_20_to_29
_30_to_39
_40_to_49
_50_to_59
_5_to_9
_60_to_69
}
}
}
Expand Down Expand Up @@ -104,7 +94,7 @@ const NZRegionalView = ({width, height}) => {
<strong className="has-text-white">
here
</strong>
</a>. Click on a row to see the data for that region.</p>
</a>. <strong className="has-text-white">There is an issue with this data</strong>. Click on a row to see the data for that region.</p>


<p className="has-text-white is-size-7" style={{marginTop: '10px'}}>
Expand Down
8 changes: 4 additions & 4 deletions client/src/context/GlobalContextProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ const GlobalContextProvider = ({ children }) => {
500: deaths.map((node) => mapFn( node, 'deaths', 4)),
},
update_times:{
global: "12:00am 15 April UTC",
us: "4:00pm 14 April ET",
nz: "1:00pm 15 April NZT",
nz_regional: "2:10pm 12 April NZT",
global: "12:00am 16 April UTC",
us: "4:00pm 15 April ET",
nz: "1:00pm 16 April NZT",
nz_regional: "2:10pm 16 April NZT",
}
});

Expand Down
15 changes: 12 additions & 3 deletions processing/data/new-zealand.json
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,21 @@
"deaths_per_mil": 1.842186061,
"tests": 66499,
"recovered": 728
},
{
"date": "2020-04-15T00:00:00.000Z",
"confirmed": 1401,
"confirmed_per_mil": 286.766963463,
"deaths": 9,
"deaths_per_mil": 1.842186061,
"tests": 70160,
"recovered": 770
}

],
"highest_confirmed": 1386,
"highest_confirmed": 1401,
"highest_deaths": 9,
"highest_tests": 66499,
"highest_recovered": 728,
"highest_tests": 70160,
"highest_recovered": 770,
"population": 4885500
}
38 changes: 3 additions & 35 deletions processing/get-nz-advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const getCases = (html) => {
const rows = $(this).children('tr')
// Prevent duplication when MoH adds same table twice, this will obviously break if
// confirmed count == probable count
console.log(rows.length)
if(! row_counts_encountered.includes(rows.length)){
$(rows).each(function(){

Expand All @@ -29,12 +28,9 @@ const getCases = (html) => {

cases.push({
original_date: cells[0].trim(),
gender: cells[1].trim(),
age: cells[2].trim(),
district: cells[3].trim(),
travel: cells[4].trim(),
type: i == 0 ? 'confirmed' : 'probable',

})

})
Expand All @@ -48,7 +44,7 @@ const getCases = (html) => {
}

})
console.log(cases.length)
console.log("all cases", cases.length)
return cases
}

Expand All @@ -72,11 +68,6 @@ const createStructuredCases = (cases_by_district) => {
day.total += 1
day.confirmed += c.type == 'confirmed' ? 1 : 0
day.probable += c.type != 'confirmed' ? 1 : 0
if(day.genders.hasOwnProperty(c.gender))
day.genders[c.gender] += 1
else
day.genders[c.gender == "" ? 'Undefined' : c.gender] = 1

if(c.age != ""){
if(day.ages.hasOwnProperty(c.age))
day.ages[c.age] += 1
Expand All @@ -90,10 +81,7 @@ const createStructuredCases = (cases_by_district) => {
dateForSort: c.dateForSort,
total: 1,
confirmed: c.type == 'confirmed' ? 1 : 0,
probable: c.type != 'confirmed' ? 1 : 0,
genders: {
[c.gender == "" ? 'Undefined' : c.gender]: 1
},
probable: c.type != 'confirmed' ? 1 : 0
}
if(c.age != ""){
d.structured_cases[c.dateForSort].ages = {
Expand Down Expand Up @@ -126,16 +114,12 @@ const createTimeSeries = (cases_by_district) => {
dateForSort: format(parseISO(day.dateObject),'yyyyMMdd'),
total: day.total + previous.total,
probable: day.probable + previous.probable,
confirmed: day.confirmed + previous.confirmed,
genders: {},
confirmed: day.confirmed + previous.confirmed,
ages: {}
}
_.forEach(day.ages, (val, key) => {
new_day.ages[key] = val
})
_.forEach(day.genders, (val, key) => {
new_day.genders[key] = val
})

_.forEach(previous.ages, (val, key) => {
if(new_day.ages.hasOwnProperty(key))
Expand All @@ -144,12 +128,6 @@ const createTimeSeries = (cases_by_district) => {
new_day.ages[key] = val
})

_.forEach(previous.genders, (val, key) => {
if(new_day.genders.hasOwnProperty(key))
new_day.genders[key] += val
else
new_day.genders[key] = val
})

let since_last = differenceInCalendarDays(parseISO(new_day.dateObject), parseISO(previous.dateObject))
if(since_last > 0){
Expand Down Expand Up @@ -230,9 +208,6 @@ const createTimeSeries = (cases_by_district) => {
_.forEach(today.ages, (val, key) => {
yesterday.ages[key] = val
})
_.forEach(today.genders, (val, key) => {
yesterday.genders[key] = val
})
d.time_series = d.time_series.slice(0, d.time_series.length - 1)
}
})
Expand All @@ -254,7 +229,6 @@ const createTimeSeries = (cases_by_district) => {
total: 0,
probable: 0,
ages: {},
genders: {}
}
cases_by_district.forEach(d => {
d.time_series.filter(d => d.dateForSort == date).forEach(d => {
Expand All @@ -270,12 +244,6 @@ const createTimeSeries = (cases_by_district) => {
time_series_obj.ages[key] = val
})

_.forEach(d.genders, (val, key) => {
if(time_series_obj.genders.hasOwnProperty(key))
time_series_obj.genders[key] += val
else
time_series_obj.genders[key] = val
})
})
})

Expand Down

0 comments on commit 420ce35

Please sign in to comment.