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

fix(removeAberrantData): removal of data executes last

parent 04567a6d
Branches
Tags
No related merge requests found
...@@ -28,8 +28,9 @@ async function start(fields) { ...@@ -28,8 +28,9 @@ async function start(fields) {
log('info', 'Getting data') log('info', 'Getting data')
const loadProfile = await getData() const loadProfile = await getData()
log('info', 'Saving data to Cozy') log('info', 'Saving data to Cozy')
storeLoadProfile(loadProfile) await storeLoadProfile(loadProfile)
await removeAberrantData() log('info', 'Removing aberrant data')
removeAberrantData()
} catch (error) { } catch (error) {
throw new Error(error.message) throw new Error(error.message)
} }
...@@ -100,12 +101,16 @@ async function getData() { ...@@ -100,12 +101,16 @@ async function getData() {
} }
} }
function storeLoadProfile(loadProfile) { async function storeLoadProfile(loadProfile) {
return hydrateAndFilter(loadProfile, 'enedis.loadprofile', { const filteredDocuments = await hydrateAndFilter(
keys: ['time'] loadProfile,
}).then(filteredDocuments => { 'enedis.loadprofile',
addData(filteredDocuments, 'enedis.loadprofile') {
}) keys: ['time']
}
)
const data = await addData(filteredDocuments, 'enedis.loadprofile')
return data
} }
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment