Skip to content
Snippets Groups Projects
Commit 66692006 authored by Aurélie HAUTBOIS's avatar Aurélie HAUTBOIS
Browse files

Merge branch 'master' of...

parents 0824c499 f1969fc3
No related branches found
No related tags found
No related merge requests found
Pipeline #9979 passed
......@@ -8,11 +8,11 @@ This section explain all the functionnalities in the challenge part
A quiz includes 4 basic questions and one custom question.
### Basic Question
All basics Questions are created in the quizEntity.json. We have to add :
- questionLabel => Label of the question
- Answers => An array of three answers (answerLabel, isTrue)
- description => Explain the question
- source => Source of the explanaition
All basics Questions are created in the quizEntity.json. We have to add :
- questionLabel => Label of the question
- Answers => An array of three answers (answerLabel, isTrue)
- description => Explain the question
- source => Source of the explanaition
This questions and answers are in random order.
......@@ -23,10 +23,10 @@ If it is a right answer, the quiz result is incremented by one.
### Custom Question
At the end of every quiz, we're creating a custom question. During the creation of the quiz, we have to add :
- type => data or calculation
- period => the period selected for the calcul
- timestep => the interval of the calcul (Day, Month, Year)
At the end of every quiz, we're creating a custom question. During the creation of the quiz, we have to add :
- type => data or calculation
- period => the period selected for the calcul
- timestep => the interval of the calcul (Day, Month, Year)
We get all this information to determine the custom question (All information are in the quizEntity.json). Depending of the question type, the system calcul a maximum or an average data.
Then, he generate two randoms answers following the right answer.
......
......@@ -110,7 +110,8 @@ yarn winstack
```
A Powershell window will open. Wait until the success message:
**TO BE COMPLETED**
> Everything is setup. Go to http://ecolyo.cozy.tools:8080/
> To exit, press ^C
Once successfull you can launch your local cozy with following url: [Cozy local url](http://cozy.tools:8080/)
Local database can also be consulted at the following url: [Cozy local DB](http://localhost:5984/_utils/)
......@@ -124,7 +125,8 @@ yarn linuxstack
```
Wait until the success message:
**TO BE COMPLETED**
> Everything is setup. Go to http://ecolyo.cozy.tools:8080/
> To exit, press ^C
Once successfull you can launch your local cozy with following url [Cozy local url](http://cozy.tools:8080/) and connect with the password '**cozy**'.
Local database can also be consulted at the following url: [Cozy local DB](http://localhost:5984/_utils/)
......@@ -140,10 +142,10 @@ First install ACH using yarn :
yarn global add cozy-ach
```
Next launch the script **createDayDataFiles.js** available into **test** folder
Next launch the script **createDayDataFiles.js** available into **scripts** folder
```
cd test
cd scripts
node createDayDataFiles.js
```
......@@ -161,11 +163,11 @@ You can change the period of data generated by changing the following lines:
Just replace -120 by the value needed
Json files with data will be created into **test/data** folder.
Json files with data will be created into **scripts/data** folder.
ACH script "importData.bat" will load the content of the file into your couchDB (database of your dev stack). Launch it using following commands:
```
cd test
cd scripts
./importData.bat
```
......@@ -174,4 +176,31 @@ You'll be prompted for a cozysessid, you can get it in the web console ; in the
A new browser windows will open and asking you approval to import data. Just click on **Approve**
Finally your data is loaded and ready to be displayed in the Ecolyo Application !
Finally your data is loaded in the Ecolyo Application !
## Simulate konnectors connection
!!! info "Requirement"
Your dev stack should be running to import data needed to simulate konnectors connection
When using local environment, konnectors are not able to connect.
To simulate the connection you can use the script **createConnection.js** available in **scripts** folder.
First update the Bearer and cozysessid information from the script:
```
Authorization:
'Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
Cookie: 'cozysessid=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
```
To obtain your own Bearer and cozysessid you need to have the application launched and display the web console (F12) in your navigator and select the Network tab. Just select one request and retrieve information for Request Header:
![Bearer&cozysessid](bearer_cozyssesid.png)
Next launch the script :
```
cd scripts
node createConnection.js
```
Your data is now loaded and you can refresh the application to see your konnector connected.
\ No newline at end of file
......@@ -125,6 +125,19 @@ You'll have to subtract a day value with the previous's to get a consumption for
If you're looking for more information about the API, checkout the [complete API documentation](/documents/egl-api-doc.pdf)
### Usage
TODO : add explanation of how we manage data in the konnector
### Konnector Methods
| Method | Description |
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| start | Init Function |
| getData | Retrieve data from API |
| processData | Parse data. Remove existing data from DB using hydrateAndFilter, store filtered data and return the list of filtered data |
| authenticate | Authentication method. Requires login, password, baseUrl and ApiAuthKey. |
| storeData | Save data in the right doctype db and prevent duplicated keys |
| format | Format data for DB storage and remove bad data |
| processYearAgregation | |
| processMonthlyAgregation | |
| groupBy | |
| reduceYearFunction | |
| reduceMonthFunction | |
| resetInProgressAggregatedData | Function handling special case.The temporary aggregated data need to be remove in order for the most recent one te be saved. Ex for com.grandlyon.egl.year : `{ load: 76.712, year: 2020, ... }` need to be replace by `{ load: 82.212, year: 2020, ... }` after egl data reprocess |
......@@ -19,15 +19,11 @@ On its first launch, following the Oauth Client Connect authentification.
- The account has now an access_token and an id_token from the oauth call
!!! info ""
id*token is only given when requesting the token endpoint in \_authorization_code* grant_type.
This token holds several meta datas, including the pce_id (id of user's meter) that will be needed further to fetch user's datas.
id token is only given when requesting the token endpoint in \_authorization_code grant_type.
This token holds several meta datas, including the usage_point_id (id of user's meter) that will be needed further to fetch user's datas.
- Konnector starts, fails to find a pce_id in database on first launch therefore decodes the id_token to store the pce_id in db (see [addData](https://docs.cozy.io/en/cozy-konnector-libs/api/#adddata_1)).
- Konnector restarts, this time knowing a pce_id, it fails to fetch datas because the access_token from oauth call has a reduced scope (only scoping for meta data requests).
- Konnector launches a refresh call, the proxy knows to answer it with a _client_credentials_ grant_type call to grdf /access_token.
- Konnector restarts with everyting needed in database to fetch datas and store them in couchdb.
- Further jobs will not need to change scope again and will only ask for refresh tokens.
- Konnector starts, if no usage_point_id are found in database or fields then proceed as a first launch. Store the usage_point_id in oauth_callback_result in db (see [addData](https://docs.cozy.io/en/cozy-konnector-libs/api/#adddata_1)).
- Konnector finds usage_point_id when starting but token is expired. Proceed to refresh token and restart konnector with usage_point_id in fields params (see *Troubleshooting when asking for refresh token* section at the end of the page).
## Enedis API
......
......@@ -22,7 +22,7 @@ On its first launch, following the Oauth Client Connect authentification.
- The account has now an access_token and an id_token from the oauth call
!!! info ""
id_token is only given when requesting the token endpoint in _authorization_code_ grant_type.
id*token is only given when requesting the token endpoint in \_authorization_code* grant_type.
This token holds several meta datas, including the pce_id (id of user's meter) that will be needed further to fetch user's datas.
- Konnector starts, fails to find a pce_id in database on first launch therefore decodes the id_token to store the pce_id in db (see [addData](https://docs.cozy.io/en/cozy-konnector-libs/api/#adddata_1)).
......@@ -58,3 +58,16 @@ Build the konnector with `yarn build`.
Type `yarn deploy` to build on a dedicated branch.
Build branch is stored as a docker image in a registry : [Container Registry](https://forge.grandlyon.com/web-et-numerique/llle_project/grdf-adict-konnector/container_registry).
### Konnector Methods
| Method | Description |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| start | Init Function |
| getData | Retrieve data from API |
| processData | Parse data. Remove existing data from DB using hydrateAndFilter, store filtered data and return the list of filtered data |
| storeData | Save data in the right doctype db and prevent duplicated keys |
| formateData | Format data for DB storage and remove bad data |
| buildAgregatedData | Retrieve and remove old data for a specific doctype and return an array of agregated data |
| buildDataFromKey | Format an entry for DB storage using key and value. For year doctype: key = "YYYY". For month doctype: key = "YYYY-MM" |
| resetInProgressAggregatedData | Function handling special case.The temporary aggregated data need to be remove in order for the most recent one te be saved. Ex for com.grandlyon.grdf.year : `{ load: 76.712, year: 2020, ... }` need to be replace by `{ load: 82.212, year: 2020, ... }` after grdf data reprocess |
docs/img/bearer_cozysessid.png

165 KiB

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