Skip to content
Snippets Groups Projects
Commit cfc2658d authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

Merge branch 'feat/insee-code' of...

Merge branch 'feat/insee-code' of https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector into feat/insee-code
parents c77b8f2e 9aa7d1ae
No related branches found
No related tags found
1 merge request!9Feat/insee code
Pipeline #39578 passed
......@@ -4,4 +4,58 @@ describe('buildAgregatedData', () => {
const reply = await buildAgregatedData([], 'com.enedis.day')
expect(reply).toEqual([])
})
it('should return year value', async () => {
const reply = await buildAgregatedData(
{
'2022': 36,
},
'com.grandlyon.enedis.year'
)
expect(reply).toEqual([
{
day: 0,
hour: 0,
load: 36,
minute: 0,
month: 1,
year: 2022,
},
])
})
it('should return month value', async () => {
const reply = await buildAgregatedData(
{
'2022-08': 36,
},
'com.grandlyon.enedis.month'
)
expect(reply).toEqual([
{
day: 0,
hour: 0,
load: 36,
minute: 0,
month: 8,
year: 2022,
},
])
})
it('should return daily value', async () => {
const reply = await buildAgregatedData(
{
'2022-08-01-13:39:25+00:00': 36,
},
'com.grandlyon.enedis.minute'
)
expect(reply).toEqual([
{
day: 1,
hour: 13,
load: 36,
minute: 0,
month: 8,
year: 2022,
},
])
})
})
......@@ -9,7 +9,7 @@ async function buildAgregatedData(data, doctype) {
let agregatedData = []
// eslint-disable-next-line no-unused-vars
for (let [key, value] of Object.entries(data)) {
const data = await buildDataFromKey(doctype, key, value)
const data = buildDataFromKey(doctype, key, value)
const oldValue = await resetInProgressAggregatedData(data, doctype)
data.load += oldValue
agregatedData.push(data)
......@@ -23,7 +23,7 @@ async function buildAgregatedData(data, doctype) {
* For year doctype: key = "YYYY"
* For month doctype: key = "YYYY-MM"
*/
async function buildDataFromKey(doctype, key, value) {
function buildDataFromKey(doctype, key, value) {
let year, month, day, hour
if (doctype === 'com.grandlyon.enedis.year') {
year = key
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment