Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
enedis-konnector
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
web-et-numerique
Factory
LLLE_Project
enedis-konnector
Commits
b8a495b0
Commit
b8a495b0
authored
4 years ago
by
Yoan VALLET
Browse files
Options
Downloads
Patches
Plain Diff
update main.go - fix curve load data
parent
f86e9743
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/index.js
+10
-10
10 additions, 10 deletions
src/index.js
with
10 additions
and
10 deletions
src/index.js
+
10
−
10
View file @
b8a495b0
...
...
@@ -17,11 +17,9 @@ const startDailyDate = moment()
.
subtract
(
32
,
'
month
'
)
.
format
(
'
YYYY-MM-DD
'
)
const
startLoadDate
=
moment
()
.
subtract
(
8
,
'
day
'
)
.
format
(
'
YYYY-MM-DD
'
)
const
endDate
=
moment
()
.
subtract
(
1
,
'
day
'
)
.
subtract
(
7
,
'
day
'
)
.
format
(
'
YYYY-MM-DD
'
)
const
endDate
=
moment
().
format
(
'
YYYY-MM-DD
'
)
const
baseUrl
=
'
https://gw.hml.api.enedis.fr
'
/**
...
...
@@ -34,8 +32,8 @@ const baseUrl = 'https://gw.hml.api.enedis.fr'
async
function
start
(
fields
)
{
try
{
const
{
access_token
}
=
fields
const
{
info
}
=
fields
const
usage_point_id
=
info
.
usage_point_id
const
{
oauth_callback_results
}
=
fields
const
usage_point_id
=
oauth_callback_results
.
usage_point_id
log
(
'
info
'
,
'
Fetching enedis daily data
'
)
const
fetchedDailyData
=
await
getDailyData
(
access_token
,
usage_point_id
)
...
...
@@ -132,7 +130,7 @@ async function getLoadData(token, usagePointID) {
async
function
processData
(
data
,
doctype
,
filterKeys
)
{
const
parsedData
=
JSON
.
parse
(
data
)
const
intervalData
=
parsedData
.
meter_reading
.
interval_reading
const
formatedData
=
await
formateData
(
intervalData
)
const
formatedData
=
await
formateData
(
intervalData
,
doctype
)
// Remove data for existing days into the DB
const
filteredData
=
await
hydrateAndFilter
(
formatedData
,
doctype
,
{
keys
:
filterKeys
...
...
@@ -222,13 +220,15 @@ async function storeData(data, doctype, filterKeys) {
* Format data for DB storage
* Remove bad data
*/
async
function
formateData
(
data
)
{
async
function
formateData
(
data
,
doctype
)
{
log
(
'
info
'
,
'
Formating data
'
)
return
data
.
map
(
record
=>
{
const
date
=
moment
(
record
.
date
,
'
YYYY/MM/DD h:mm:ss
'
)
if
(
record
.
value
!=
-
2
)
{
const
load
=
doctype
===
'
io.enedis.minute
'
?
record
.
value
/
2
:
record
.
value
return
{
load
:
parseFloat
(
record
.
value
/
1000
),
load
:
parseFloat
(
load
/
1000
),
year
:
parseInt
(
date
.
format
(
'
YYYY
'
)),
month
:
parseInt
(
date
.
format
(
'
M
'
)),
day
:
parseInt
(
date
.
format
(
'
D
'
)),
...
...
@@ -281,7 +281,7 @@ async function buildDataFromKey(doctype, key, value) {
hour
=
split
[
3
]
}
return
{
load
:
Math
.
round
(
value
*
1000
)
/
1000
,
load
:
Math
.
round
(
value
*
1000
0
)
/
1000
0
,
year
:
parseInt
(
year
),
month
:
parseInt
(
month
),
day
:
parseInt
(
day
),
...
...
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