Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ecolyo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
web-et-numerique
Factory
LLLE_Project
Ecolyo
Commits
d25e7d32
Commit
d25e7d32
authored
4 years ago
by
Yoan VALLET
Browse files
Options
Downloads
Patches
Plain Diff
set NOSONAR for random in test file
parent
4a376822
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/createDayDataFiles.js
+1
-0
1 addition, 0 deletions
test/createDayDataFiles.js
test/createMockFile.js
+0
-169
0 additions, 169 deletions
test/createMockFile.js
with
1 addition
and
169 deletions
test/createDayDataFiles.js
+
1
−
0
View file @
d25e7d32
...
...
@@ -8,6 +8,7 @@ const { DateTime } = require('luxon')
function
getRandomInt
(
min
,
max
)
{
const
minValue
=
Math
.
ceil
(
min
*
100
)
const
maxValue
=
Math
.
floor
(
max
*
100
)
// NOSONAR
const
result
=
(
Math
.
floor
(
Math
.
random
()
*
(
maxValue
-
minValue
))
+
minValue
)
/
100
return
result
...
...
This diff is collapsed.
Click to expand it.
test/createMockFile.js
deleted
100644 → 0
+
0
−
169
View file @
4a376822
const
fs
=
require
(
'
fs
'
)
const
{
DateTime
}
=
require
(
'
luxon
'
)
const
generateData
=
(
startingdate
,
endingDate
)
=>
{
let
parsingDate
=
DateTime
.
local
(
startingdate
.
year
,
startingdate
.
month
,
startingdate
.
day
)
let
lastDay
=
parsingDate
.
day
const
dayDumpArray
=
[]
let
lastMonth
=
parsingDate
.
month
const
monthDumpArray
=
[]
let
lastYear
=
parsingDate
.
year
const
yearDumpArray
=
[]
let
dailyLoad
=
0
let
monthlyLoad
=
0
let
yearlyLoad
=
0
const
dumpArray
=
[]
while
(
parsingDate
<=
endingDate
)
{
const
load
=
parseInt
(
Math
.
random
()
*
1000
)
/
100
dailyLoad
+=
load
monthlyLoad
+=
load
yearlyLoad
+=
load
dumpArray
.
push
({
load
:
load
,
year
:
parsingDate
.
year
,
month
:
parsingDate
.
month
,
day
:
parsingDate
.
day
,
hour
:
parsingDate
.
hour
,
minute
:
parsingDate
.
minute
,
})
if
(
parsingDate
.
day
!==
lastDay
)
{
dayDumpArray
.
push
({
load
:
Math
.
round
(
dailyLoad
*
100
)
/
100
,
year
:
parsingDate
.
year
,
month
:
lastMonth
,
day
:
lastDay
,
hour
:
0
,
minute
:
0
,
})
dailyLoad
=
0
lastDay
=
parsingDate
.
day
}
if
(
parsingDate
.
month
!==
lastMonth
)
{
monthDumpArray
.
push
({
load
:
Math
.
round
(
monthlyLoad
*
100
)
/
100
,
year
:
lastYear
,
month
:
lastMonth
,
day
:
0
,
hour
:
0
,
minute
:
0
,
})
monthlyLoad
=
0
lastMonth
=
parsingDate
.
month
}
if
(
parsingDate
.
year
!==
lastYear
)
{
yearDumpArray
.
push
({
load
:
Math
.
round
(
yearlyLoad
*
100
)
/
100
,
year
:
lastYear
,
month
:
0
,
day
:
0
,
hour
:
0
,
minute
:
0
,
})
yearlyLoadLoad
=
0
lastYear
=
parsingDate
.
year
}
parsingDate
=
parsingDate
.
plus
({
minutes
:
30
})
}
return
{
hourlyLoad
:
dumpArray
,
dailyLoad
:
dayDumpArray
,
monthlyLoad
:
monthDumpArray
,
yearlyLoad
:
yearDumpArray
,
}
}
const
startingdate
=
DateTime
.
local
(
2020
,
1
,
1
)
const
endingDate
=
DateTime
.
local
(
2020
,
4
,
15
)
const
Eelec
=
generateData
(
startingdate
,
endingDate
)
const
Gaz
=
generateData
(
startingdate
,
endingDate
)
const
Eau
=
generateData
(
startingdate
,
endingDate
)
//const dt2 = dt.plus({days:1})
/*
fetchData = (y1,y2,withHourlyDetail) =>
{
const dumpArray =[];
for (year = y1; year <= y2; year++) {
for (month = 1; month <= 12; month++) {
for (day = 1; day <= 30; day++) {
if (withHourlyDetail)
{
for(h = 0; h<=23;h++)
{
for(m=0;m<=1;m++)
{
const date =
{
year: year,
month: month,
day: day,
hour: h,
minute: m*30,
load: (parseInt(Math.random() * 10000) / 100)
}
dumpArray.push(date);
}
}
}
else
{
const date =
{
year: year,
month: month,
day: day,
hour: 0,
minute: 0,
load: (parseInt(Math.random() * 10000) / 100)
}
dumpArray.push(date);
}
}
}
}
return dumpArray;
}
*/
const
dump
=
{
'
com.grandlyon.enedis.minute
'
:
Eelec
.
hourlyLoad
,
'
com.grandlyon.enedis.day
'
:
Eelec
.
dailyLoad
,
'
com.grandlyon.enedis.month
'
:
Eelec
.
monthlyLoad
,
'
com.grandlyon.enedis.year
'
:
Eelec
.
yearlyLoad
,
'
com.grandlyon.grdf.hour
'
:
Gaz
.
hourlyLoad
,
'
com.grandlyon.grdf.day
'
:
Gaz
.
dailyLoad
,
'
com.grandlyon.grdf.month
'
:
Gaz
.
monthlyLoad
,
'
com.grandlyon.grdf.year
'
:
Gaz
.
yearlyLoad
,
//"com.grandlyon.egl.hour": Eau.hourlyLoad,
'
com.grandlyon.egl.day
'
:
Eau
.
dailyLoad
,
'
com.grandlyon.egl.month
'
:
Eau
.
monthlyLoad
,
'
com.grandlyon.egl.year
'
:
Eau
.
yearlyLoad
,
}
const
dumpString
=
JSON
.
stringify
(
dump
)
fs
.
writeFile
(
'
dayData.json
'
,
dumpString
,
function
(
err
)
{
if
(
err
)
console
.
log
(
'
error
'
,
err
)
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment