Skip to content
Snippets Groups Projects
Commit fc369cb6 authored by Rémi PAILHAREY's avatar Rémi PAILHAREY :fork_knife_plate:
Browse files

fix: skip days when load is negative or water meter changed

parent ef02d5b7
No related branches found
No related tags found
2 merge requests!33Merge dev into master,!32fix: skip days when load is negative or water meter changed
......@@ -308,23 +308,12 @@ function format(response) {
log('info', 'filtered size is: ' + data.length)
try {
return data.map(value => {
const time = DateTime.fromISO(value.DateReleve)
const processedLoad = value.ValeurIndex - refValue.ValeurIndex
if (processedLoad < 0) {
const errorMessage = `Processing load error for day ${time.toLocaleString(
DateTime.DATE_SHORT
)}, value is: ${processedLoad}`
log('debug', errorMessage)
throw errors.VENDOR_DOWN
}
// Change the index reference value
refValue = value
return {
return data.reduce((loads, value) => {
const processedLoad = value.ValeurIndex - refValue.ValeurIndex
const time = DateTime.fromISO(value.DateReleve)
// Check that load is positive and that water meter has not changed
if (processedLoad >= 0 && value.TypeAgregat !== 'D') {
loads.push({
load: processedLoad,
year: time.year,
month: time.month,
......@@ -332,15 +321,20 @@ function format(response) {
hour: 0,
minute: 0,
type: value.TypeAgregat,
}
})
} catch (error) {
log('debug', error.message)
Sentry.captureException(error, {
tags: {
section: 'format',
},
})
throw error
}
})
} else {
Sentry.captureMessage('New water meter or invalid load value', {
extra: {
processedLoad,
value,
},
tags: {
section: 'format',
},
})
}
// Change the index reference value
refValue = value
return loads
}, [])
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment