Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
grdf_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
Show more breadcrumbs
web-et-numerique
Factory
LLLE_Project
grdf_konnector
Commits
d3d444c9
Commit
d3d444c9
authored
3 years ago
by
Bastien DUMONT
Browse files
Options
Downloads
Patches
Plain Diff
feat: standalone mode
parent
9097cdbb
No related branches found
No related tags found
1 merge request
!8
feat : standalone mode
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+4
-1
4 additions, 1 deletion
README.md
src/index.js
+28
-14
28 additions, 14 deletions
src/index.js
with
32 additions
and
15 deletions
README.md
+
4
−
1
View file @
d3d444c9
...
@@ -28,7 +28,10 @@ Create a `konnector-dev-config.json` file at the root with your test credentials
...
@@ -28,7 +28,10 @@ Create a `konnector-dev-config.json` file at the root with your test credentials
```
javascript
```
javascript
{
{
"
COZY_URL
"
:
"
http://cozy.tools:8080
"
,
"
COZY_URL
"
:
"
http://cozy.tools:8080
"
,
"
fields
"
:
{
"
login
"
:
"
zuck.m@rk.fb
"
,
"
password
"
:
"
123456
"
}
"
fields
"
:
{
"
access_token
"
:
,
"
id_pce
"
:
}
}
}
```
```
Then :
Then :
...
...
This diff is collapsed.
Click to expand it.
src/index.js
+
28
−
14
View file @
d3d444c9
...
@@ -40,6 +40,12 @@ module.exports = new BaseKonnector(start)
...
@@ -40,6 +40,12 @@ module.exports = new BaseKonnector(start)
async
function
start
(
fields
)
{
async
function
start
(
fields
)
{
log
(
'
debug
'
,
'
Starting grdf adict konnector
'
)
log
(
'
debug
'
,
'
Starting grdf adict konnector
'
)
if
(
process
.
env
.
NODE_ENV
===
"
standalone
"
)
{
const
grdfData
=
await
getData
(
fields
.
access_token
,
fields
.
id_pce
);
processAndAggregateData
(
grdfData
)
return
}
const
accountId
=
getAccountId
()
const
accountId
=
getAccountId
()
let
body
=
''
let
body
=
''
let
id_pce
=
''
let
id_pce
=
''
...
@@ -60,18 +66,7 @@ async function start(fields) {
...
@@ -60,18 +66,7 @@ async function start(fields) {
log
(
'
debug
'
,
'
THE ID_PCE SENDING TO GETDATA :
'
+
id_pce
)
log
(
'
debug
'
,
'
THE ID_PCE SENDING TO GETDATA :
'
+
id_pce
)
const
grdfData
=
await
getData
(
fields
.
access_token
,
id_pce
)
const
grdfData
=
await
getData
(
fields
.
access_token
,
id_pce
)
if
(
grdfData
)
{
processAndAggregateData
(
grdfData
)
log
(
'
debug
'
,
'
Process grdf daily data
'
)
const
processedLoadData
=
await
processData
(
grdfData
,
'
com.grandlyon.grdf.day
'
,
[
'
year
'
,
'
month
'
,
'
day
'
]
)
log
(
'
debug
'
,
'
Agregate grdf load data for month and year
'
)
await
agregateMonthAndYearData
(
processedLoadData
)
}
else
{
log
(
'
debug
'
,
'
No consent or data for load curve
'
)
}
}
else
{
}
else
{
log
(
'
debug
'
,
'
no id_token found in oauth_callback_results
'
)
log
(
'
debug
'
,
'
no id_token found in oauth_callback_results
'
)
log
(
log
(
...
@@ -166,7 +161,7 @@ async function getData(token, idPCE) {
...
@@ -166,7 +161,7 @@ async function getData(token, idPCE) {
* Return the list of filtered data
* Return the list of filtered data
*/
*/
async
function
processData
(
data
,
doctype
,
filterKeys
)
{
async
function
processData
(
data
,
doctype
,
filterKeys
)
{
const
formatedData
=
await
format
e
Data
(
data
)
const
formatedData
=
await
formatData
(
data
)
log
(
'
debug
'
,
'
processData - data formated
'
)
log
(
'
debug
'
,
'
processData - data formated
'
)
// Remove data for existing days into the DB
// Remove data for existing days into the DB
const
filteredData
=
await
hydrateAndFilter
(
formatedData
,
doctype
,
{
const
filteredData
=
await
hydrateAndFilter
(
formatedData
,
doctype
,
{
...
@@ -193,7 +188,7 @@ async function storeData(data, doctype, filterKeys) {
...
@@ -193,7 +188,7 @@ async function storeData(data, doctype, filterKeys) {
* Format data for DB storage
* Format data for DB storage
* Remove bad data
* Remove bad data
*/
*/
async
function
format
e
Data
(
data
)
{
async
function
formatData
(
data
)
{
log
(
'
debug
'
,
'
Formating data
'
)
log
(
'
debug
'
,
'
Formating data
'
)
return
data
.
map
(
record
=>
{
return
data
.
map
(
record
=>
{
let
date
=
moment
(
record
.
date_debut_consommation
,
'
YYYY/MM/DD h:mm:ss
'
)
let
date
=
moment
(
record
.
date_debut_consommation
,
'
YYYY/MM/DD h:mm:ss
'
)
...
@@ -344,3 +339,22 @@ async function resetInProgressAggregatedData(data, doctype) {
...
@@ -344,3 +339,22 @@ async function resetInProgressAggregatedData(data, doctype) {
}
}
return
0.0
return
0.0
}
}
/**
* 1. Processes data.
* 2. Aggregates data.
*/
async
function
processAndAggregateData
(
data
)
{
if
(
data
)
{
log
(
"
debug
"
,
"
Process grdf daily data
"
);
const
processedLoadData
=
await
processData
(
data
,
"
com.grandlyon.grdf.day
"
,
[
"
year
"
,
"
month
"
,
"
day
"
]
);
log
(
"
debug
"
,
"
Agregate grdf load data for month and year
"
);
await
agregateMonthAndYearData
(
processedLoadData
);
}
else
{
log
(
"
debug
"
,
"
No consent or data for load curve
"
);
}
}
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