Commit d22e6984 authored by Michał Woźniak's avatar Michał Woźniak
Browse files

bugfix for data gap filling

parent 6569965f
Pipeline #190 passed with stage
in 1 second
......@@ -849,18 +849,26 @@ let getSiteCases = (site) => {
while ( (cur_index < data.length) && (failsafe > 0) ) {
// decrement the failsafe
failsafe -= 1
// increment the date
cur_date.setDate(cur_date.getDate() + 1)
// check if it matches
if (new Date(data[cur_index].date) <= cur_date) {
gaps_filled.push(data[cur_index])
cur_index += 1
// get the date
var data_date = new Date(data[cur_index].date)
// check if it's a valid date
if (!isNaN(data_date)) {
// increment the date
cur_date.setDate(cur_date.getDate() + 1)
// check if it matches
if (data_date <= cur_date) {
gaps_filled.push(data[cur_index])
cur_index += 1
} else {
// presumably we're in a gap!
gaps_filled.push({
date: `${cur_date.getFullYear()}-${("0" + (cur_date.getMonth() + 1)).slice(-2)}-${("0" + cur_date.getDate()).slice(-2)}`,
confirmed: data[cur_index-1].confirmed
})
}
// if not a valid date, just ignore and move on
} else {
// presumably we're in a gap!
gaps_filled.push({
date: `${cur_date.getFullYear()}-${("0" + (cur_date.getMonth() + 1)).slice(-2)}-${("0" + cur_date.getDate()).slice(-2)}`,
confirmed: data[cur_index-1].confirmed
})
cur_index += 1
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment