Skip to content
Snippets Groups Projects
Commit b4f1b5ed authored by i-vall's avatar i-vall
Browse files

feat: remove aberrant data

parent aea148b5
Branches
No related tags found
No related merge requests found
...@@ -26,13 +26,14 @@ async function start(fields) { ...@@ -26,13 +26,14 @@ async function start(fields) {
const loadProfile = await getData() const loadProfile = await getData()
log('info', 'Saving data to Cozy') log('info', 'Saving data to Cozy')
storeLoadProfile(loadProfile) storeLoadProfile(loadProfile)
await removeAberrantData()
} catch (error) { } catch (error) {
throw new Error(error.message) throw new Error(error.message)
} }
} }
const startDate = moment() const startDate = moment()
.subtract(3, 'day') .subtract(30, 'day')
.format('DD/MM/YYYY') .format('DD/MM/YYYY')
const endDate = moment().format('DD/MM/YYYY') const endDate = moment().format('DD/MM/YYYY')
...@@ -115,3 +116,12 @@ async function resetData() { ...@@ -115,3 +116,12 @@ async function resetData() {
await cozyClient.data.delete('enedis.loadprofile', load) await cozyClient.data.delete('enedis.loadprofile', load)
} }
} }
async function removeAberrantData() {
const result = await cozyClient.data.findAll('enedis.loadprofile')
for (const load of result) {
if (load.load == -2) {
await cozyClient.data.delete('enedis.loadprofile', load)
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment