Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
enedis_sge_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
enedis_sge_konnector
Commits
fbbd5942
Commit
fbbd5942
authored
2 years ago
by
Hugo SUBTIL
Browse files
Options
Downloads
Patches
Plain Diff
fix: issue in env
parent
5a91d17c
No related branches found
No related tags found
1 merge request
!12
Feat/donnes tech debut contrat
Pipeline
#39871
failed
2 years ago
Stage: test
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/helpers/env.js
+5
-0
5 additions, 0 deletions
src/helpers/env.js
src/index.js
+9
-11
9 additions, 11 deletions
src/index.js
src/requests/cozy.js
+4
-1
4 additions, 1 deletion
src/requests/cozy.js
with
18 additions
and
12 deletions
src/helpers/env.js
0 → 100644
+
5
−
0
View file @
fbbd5942
function
iSLocal
()
{
return
process
.
env
.
NODE_ENV
===
'
development
'
||
process
.
env
.
NODE_ENV
}
module
.
exports
=
{
iSLocal
}
This diff is collapsed.
Click to expand it.
src/index.js
+
9
−
11
View file @
fbbd5942
...
...
@@ -34,6 +34,7 @@ const { activateContract } = require('./core/contractActivation')
const
{
verifyContract
}
=
require
(
'
./core/contractVerification
'
)
const
{
terminateContract
}
=
require
(
'
./core/contractTermination
'
)
const
{
getAccount
,
saveAccountData
}
=
require
(
'
./requests/cozy
'
)
const
{
iSLocal
}
=
require
(
'
./helpers/env
'
)
moment
.
locale
(
'
fr
'
)
// set the language
moment
.
tz
.
setDefault
(
'
Europe/Paris
'
)
// set the timezone
...
...
@@ -48,7 +49,7 @@ let startDailyDateString = startDailyDate.format('YYYY-MM-DD')
const
startLoadDate
=
moment
().
subtract
(
7
,
'
day
'
)
const
endDate
=
moment
()
const
endDateString
=
endDate
.
format
(
'
YYYY-MM-DD
'
)
const
ACCOUNT_ID
=
'
default_account_id
'
const
ACCOUNT_ID
=
iSLocal
()
?
'
default_account_id
'
:
'
enedis-sge-grandlyon
'
module
.
exports
=
new
BaseKonnector
(
start
)
module
.
exports
=
{
getContractStartDate
}
...
...
@@ -129,6 +130,11 @@ async function start(fields, cozyParameters) {
consent
=
await
updateBoConsent
(
consent
,
serviceId
)
// Save bo id into account
const
accountData
=
await
getAccount
(
ACCOUNT_ID
)
console
.
log
(
'
🚀 ~ file: index.js ~ line 132 ~ start ~ accountData
'
,
accountData
)
await
saveAccountData
(
this
.
accountId
,
{
...
accountData
.
data
,
consentId
:
consent
.
id
,
...
...
@@ -486,16 +492,8 @@ async function agregateMonthAndYearData(data) {
* @returns {boolean}
*/
function
isFirstStart
(
account
)
{
console
.
log
(
'
🚀 ~ file: index.js ~ line 490 ~ isFirstStart ~ account.data
'
,
account
.
data
)
console
.
log
(
'
🚀 ~ file: index.js ~ line 490 ~ isFirstStart ~ account.data
'
,
account
.
data
.
consentId
)
if
(
account
.
data
&&
account
.
data
.
consentId
)
{
console
.
log
(
account
)
if
(
account
&&
account
.
data
&&
account
.
data
.
consentId
)
{
log
(
'
info
'
,
'
Konnector not first start
'
)
return
false
}
...
...
This diff is collapsed.
Click to expand it.
src/requests/cozy.js
+
4
−
1
View file @
fbbd5942
const
{
log
,
updateOrCreate
}
=
require
(
'
cozy-konnector-libs
'
)
const
{
iSLocal
}
=
require
(
'
../helpers/env
'
)
const
cozyClient
=
require
(
'
cozy-konnector-libs/dist/libs/cozyclient
'
)
async
function
saveAccountData
(
accountId
,
accountData
)
{
...
...
@@ -17,7 +18,9 @@ async function getAccount(accountId) {
log
(
'
info
'
,
`getAccount:
${
accountId
}
`
)
//TODO: refactor with usageof cozy-libs. Not working during implementation
const
accounts
=
await
cozyClient
.
data
.
findAll
(
'
io.cozy.accounts
'
)
return
accounts
.
filter
(
account
=>
account
.
_id
===
accountId
)[
0
]
return
accounts
.
filter
(
account
=>
iSLocal
()
?
account
.
_id
===
accountId
:
account
.
account_type
===
accountId
)[
0
]
}
module
.
exports
=
{
getAccount
,
saveAccountData
}
This diff is collapsed.
Click to expand it.
Hugo SUBTIL
@ext.sopra.husubtil
mentioned in commit
5f61fdad
·
2 years ago
mentioned in commit
5f61fdad
mentioned in commit 5f61fdad76bebd2bd5b31bea9263f93dbc061fe6
Toggle commit list
Hugo SUBTIL
@ext.sopra.husubtil
mentioned in commit
20ec5bf4
·
2 years ago
mentioned in commit
20ec5bf4
mentioned in commit 20ec5bf49a869d67f0e338dbbaeefaa6e290f25a
Toggle commit list
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