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
GitLab 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
2f73f3e7
Commit
2f73f3e7
authored
Jan 20, 2023
by
Bastien DUMONT
Browse files
Options
Downloads
Patches
Plain Diff
fix: handle communes with "St"
parent
58938747
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!30
Resolve "[SGE] Traiter les communes avec ST"
Pipeline
#50939
passed
Jan 20, 2023
Stage: test
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
__tests__/requests/insee.spec.js
+39
-0
39 additions, 0 deletions
__tests__/requests/insee.spec.js
src/requests/insee.js
+2
-0
2 additions, 0 deletions
src/requests/insee.js
with
41 additions
and
0 deletions
__tests__/requests/insee.spec.js
+
39
−
0
View file @
2f73f3e7
...
@@ -42,6 +42,45 @@ describe('getInseeCode', () => {
...
@@ -42,6 +42,45 @@ describe('getInseeCode', () => {
expect
(
await
getInseeCode
(
38080
,
"
L'isle d'abeau
"
)).
toEqual
(
'
38193
'
)
expect
(
await
getInseeCode
(
38080
,
"
L'isle d'abeau
"
)).
toEqual
(
'
38193
'
)
})
})
describe
(
'
should handle communes with "Saint" or "St"
'
,
()
=>
{
it
(
"
should return insee code for: Saint Romain au Mont d'Or
"
,
async
()
=>
{
expect
(
await
getInseeCode
(
69270
,
"
Saint Romain au Mont d'Or
"
)).
toEqual
(
'
69233
'
)
})
it
(
"
should return insee code for: St Romain au Mont d'Or
"
,
async
()
=>
{
expect
(
await
getInseeCode
(
69270
,
"
St Romain au Mont d'Or
"
)).
toEqual
(
'
69233
'
)
})
it
(
'
should return insee code for: Saint Genis les Ollières
'
,
async
()
=>
{
expect
(
await
getInseeCode
(
69290
,
'
Saint Genis les Ollières
'
)).
toEqual
(
'
69205
'
)
})
it
(
'
should return insee code for: St Genis les Ollières
'
,
async
()
=>
{
expect
(
await
getInseeCode
(
69290
,
'
St Genis les Ollières
'
)).
toEqual
(
'
69205
'
)
})
it
(
'
should return insee code for: St Priest
'
,
async
()
=>
{
// 69800 has only a single commune
expect
(
await
getInseeCode
(
69800
,
'
st priest
'
)).
toEqual
(
'
69290
'
)
})
// No regression test with replacement of st
it
(
'
should return insee code for: Puget-Rostang
'
,
async
()
=>
{
expect
(
await
getInseeCode
(
'
06260
'
,
'
Puget-Rostang
'
)).
toEqual
(
'
06098
'
)
})
it
(
'
should return insee code for: St léger
'
,
async
()
=>
{
expect
(
await
getInseeCode
(
'
06260
'
,
'
St léger
'
)).
toEqual
(
'
06124
'
)
})
})
describe
(
"
should return correct insee code for Couzon-au-Mont-d'Or
"
,
()
=>
{
describe
(
"
should return correct insee code for Couzon-au-Mont-d'Or
"
,
()
=>
{
it
(
"
should return insee code for: Couzon au mont d'or
"
,
async
()
=>
{
it
(
"
should return insee code for: Couzon au mont d'or
"
,
async
()
=>
{
expect
(
await
getInseeCode
(
69270
,
"
Couzon au mont d'or
"
)).
toEqual
(
expect
(
await
getInseeCode
(
69270
,
"
Couzon au mont d'or
"
)).
toEqual
(
...
...
...
...
This diff is collapsed.
Click to expand it.
src/requests/insee.js
+
2
−
0
View file @
2f73f3e7
...
@@ -26,6 +26,7 @@ async function getInseeCode(postalCode, city) {
...
@@ -26,6 +26,7 @@ async function getInseeCode(postalCode, city) {
const
filteredResponse
=
response
.
data
.
filter
(
const
filteredResponse
=
response
.
data
.
filter
(
town
=>
sanitizeCity
(
town
.
nomCommune
)
===
parsedCity
town
=>
sanitizeCity
(
town
.
nomCommune
)
===
parsedCity
)
)
return
filteredResponse
[
0
].
codeCommune
return
filteredResponse
[
0
].
codeCommune
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -44,6 +45,7 @@ async function getInseeCode(postalCode, city) {
...
@@ -44,6 +45,7 @@ async function getInseeCode(postalCode, city) {
function
sanitizeCity
(
city
)
{
function
sanitizeCity
(
city
)
{
return
city
return
city
.
toLowerCase
()
.
toLowerCase
()
.
replace
(
/st/g
,
'
saint
'
)
.
replace
(
/
[
âêîôûäëïü-
\s
ʼ'éèç
]
/g
,
match
=>
REPLACE_CHARS
[
match
])
.
replace
(
/
[
âêîôûäëïü-
\s
ʼ'éèç
]
/g
,
match
=>
REPLACE_CHARS
[
match
])
.
trim
()
.
trim
()
}
}
...
...
...
...
This diff is collapsed.
Click to expand it.
Ghost User
@ghost
mentioned in commit
98efb6c5
·
Jan 20, 2023
mentioned in commit
98efb6c5
mentioned in commit 98efb6c5ea2671f86307a004d33ffa296a93582f
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
sign in
to comment