Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • web-et-numerique/factory/llle_project/enedis-sge-konnector
1 result
Select Git revision
Show changes
Commits on Source (6)
module.exports = {
extends: ['cozy-app', 'plugin:prettier/recommended'],
plugins: ['prettier'],
rules: {
'prettier/prettier': [
'error',
{ trailingComma: 'es5', arrowParens: 'avoid' },
],
},
}
......@@ -5,6 +5,7 @@ konnector-dev-config.json*
fixtures/*
data/*
.importedData.json
importedData.json
# NPM
node_modules/
......
......@@ -3,5 +3,6 @@
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5"
"trailingComma": "es5",
"arrowParens": "avoid"
}
......@@ -2,6 +2,14 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [1.3.1](https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector/compare/v1.3.0...v1.3.1) (2023-06-01)
### Bug Fixes
* **eslint:** upgrade packages & no unused vars ([7bcc8f3](https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector/commit/7bcc8f345ec8d3db9ceec4a5f936c321d0aac99f))
* **insee:** city name included in some communes ([03b094c](https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector/commit/03b094c39271916beda4e52eb6661cccaecc683a))
## [1.3.0](https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector/compare/v1.2.5...v1.3.0) (2023-04-06)
......
......@@ -9,7 +9,7 @@ describe('buildAggregatedData', () => {
it('should return year value', async () => {
const reply = await buildAggregatedData(
{
'2022': 36,
2022: 36,
},
'com.grandlyon.enedis.year'
)
......@@ -29,7 +29,7 @@ describe('buildAggregatedData', () => {
spy.mockResolvedValueOnce([{ year: 2022, month: 8, day: 1, load: 1 }])
const reply = await buildAggregatedData(
{
'2022': 36,
2022: 36,
},
'com.grandlyon.enedis.year'
)
......
......@@ -184,5 +184,19 @@ describe('getInseeCode', () => {
expect(await getInseeCode(95640, 'Breancon')).toEqual('95102')
})
})
describe('should return correct insee code when other communes contains the city', () => {
it('should return insee code for: Cluses', async () => {
expect(await getInseeCode(74300, 'Cluses')).toEqual('74081')
})
it('should return insee code for: Chatillon sur cluses', async () => {
expect(await getInseeCode(74300, 'Chatillon sur cluses')).toEqual(
'74064'
)
})
it('should return insee code for: Nancy sur cluses', async () => {
expect(await getInseeCode(74300, 'Nancy sur cluses')).toEqual('74196')
})
})
})
})
{
"version": "1.3.0",
"version": "1.3.1",
"name": "Enedis SGE",
"type": "konnector",
"language": "node",
......
{
"name": "enedissgegrandlyon",
"version": "1.3.0",
"version": "1.3.1",
"description": "",
"repository": {
"type": "https",
......@@ -62,8 +62,8 @@
"devDependencies": {
"cozy-jobs-cli": "2.0.0",
"cozy-konnector-build": "1.4.5",
"eslint-config-cozy-app": "1.3.3",
"eslint-plugin-prettier": "^4.0.0",
"eslint-config-cozy-app": "5.5.0",
"eslint-plugin-prettier": "^4.2.1",
"git-directory-deploy": "1.5.1",
"jest-junit": "^14.0.0",
"standard-version": "^9.5.0"
......
......@@ -68,9 +68,9 @@ async function activateContract(
`Enedis issue ${parsedReply.Envelope.Body.Fault.detail.erreur.resultat.$.code}: ${parsedReply.Envelope.Body.Fault.faultstring}`
)
}
//TODO: handle SGT4B8: Il existe déjà plusieurs demandes en cours sur le point ?
//TODO: handle SGT4H9: La demande ne porte pas sur un point équipé d'un compteur communicant ouvert aux services niveau 2.
//TODO: handle SGT589: La demande ne peut pas aboutir car le compteur n'est actuellement pas téléopérable.
// TODO: handle SGT4B8: Il existe déjà plusieurs demandes en cours sur le point ?
// TODO: handle SGT4H9: La demande ne porte pas sur un point équipé d'un compteur communicant ouvert aux services niveau 2.
// TODO: handle SGT589: La demande ne peut pas aboutir car le compteur n'est actuellement pas téléopérable.
throw errors.CAPTCHA_RESOLUTION_FAILED
}
}
......
......@@ -62,9 +62,10 @@ async function verifyUserIdentity(
fields.pointId
)
const escalierEtEtageEtAppartement = userAddress.escalierEtEtageEtAppartement
? removeMultipleSpaces(userAddress.escalierEtEtageEtAppartement)
: ''
const escalierEtEtageEtAppartement =
userAddress.escalierEtEtageEtAppartement
? removeMultipleSpaces(userAddress.escalierEtEtageEtAppartement)
: ''
pdl = await findUserPdl(
`${baseUrl}/enedis_SDE_recherche-point/1.0`,
......
......@@ -7,7 +7,6 @@ const { log, cozyClient } = require('cozy-konnector-libs')
*/
async function buildAggregatedData(data, doctype) {
let aggregatedData = []
// eslint-disable-next-line no-unused-vars
for (let [key, value] of Object.entries(data)) {
const data = buildDataFromKey(doctype, key, value)
const oldValue = await resetInProgressAggregatedData(data, doctype)
......@@ -69,17 +68,17 @@ async function resetInProgressAggregatedData(data, doctype) {
var filtered = []
if (doctype === 'com.grandlyon.enedis.year') {
// Yearly case
filtered = result.filter(function(el) {
filtered = result.filter(function (el) {
return el.year == data.year
})
} else if (doctype === 'com.grandlyon.enedis.month') {
// Monthly case
filtered = result.filter(function(el) {
filtered = result.filter(function (el) {
return el.year == data.year && el.month == data.month
})
} else {
// Hourly case
filtered = result.filter(function(el) {
filtered = result.filter(function (el) {
return (
el.year == data.year &&
el.month == data.month &&
......@@ -90,7 +89,6 @@ async function resetInProgressAggregatedData(data, doctype) {
}
// Remove data
let sum = 0.0
// eslint-disable-next-line no-unused-vars
for (const doc of filtered) {
sum += doc.load
log('debug', doc, 'Removing this entry for ' + doctype)
......
......@@ -45,7 +45,7 @@ const { version } = require('../package.json')
moment.locale('fr') // set the language
moment.tz.setDefault('Europe/Paris') // set the timezone
/*** Connector Constants ***/
/** Connector Constants **/
const manualExecution =
process.env.COZY_JOB_MANUAL_EXECUTION === 'true' ? true : false
let startDailyDate = manualExecution
......@@ -64,8 +64,7 @@ module.exports = new BaseKonnector(start)
* Sentry
*/
Sentry.init({
dsn:
'https://18747a93401447f2a81b83cd8c4bbbdf@grandlyon.errors.cozycloud.cc/5',
dsn: 'https://18747a93401447f2a81b83cd8c4bbbdf@grandlyon.errors.cozycloud.cc/5',
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
......
......@@ -89,7 +89,9 @@ async function onDeleteAccount() {
}
}
// eslint-disable-next-line promise/catch-or-return
onDeleteAccount().then(
// eslint-disable-next-line promise/always-return
() => {
log('info', `onDeleteAccount: Successfully delete consent and account.`)
},
......
......@@ -27,13 +27,20 @@ async function getInseeCode(postalCode, city) {
sanitizeCity(commune.nomCommune).includes(parsedCity)
)
if (filteredResponse.length === 1) {
return filteredResponse[0].codeCommune
}
if (filteredResponse.length > 1) {
throw new Error(
'Input city is not precise enough, more than one city was found'
)
// Try to get the same length of the city input
for (const commune of filteredResponse) {
if (commune.nomCommune.length === city.length) {
return commune.codeCommune
}
}
}
return filteredResponse[0].codeCommune
throw new Error('No match could be found')
}
} catch (error) {
const errorMessage = `Query getInseeCode failed for postalCode ${postalCode} / ${city}`
......
This diff is collapsed.