1
1
import Bottleneck from "bottleneck" ;
2
- import { RomeDto , SearchResultDto , SiretDto , castError } from "shared" ;
2
+ import { RomeDto , SearchResultDto , SiretDto } from "shared" ;
3
3
import { HttpClient } from "shared-routes" ;
4
- import { createLogger } from "../../../../utils/logger" ;
5
4
import { FranceTravailGateway } from "../../../convention/ports/FranceTravailGateway" ;
6
5
import { WithCache } from "../../../core/caching-gateway/port/WithCache" ;
7
6
import {
@@ -21,8 +20,6 @@ const lbbMaxQueryPerSeconds = 1;
21
20
22
21
const lbbV2App = "api_labonneboitev2" ;
23
22
24
- const logger = createLogger ( __filename ) ;
25
-
26
23
export class HttpLaBonneBoiteGateway implements LaBonneBoiteGateway {
27
24
#limiter = new Bottleneck ( {
28
25
reservoir : lbbMaxQueryPerSeconds ,
@@ -110,19 +107,7 @@ export class HttpLaBonneBoiteGateway implements LaBonneBoiteGateway {
110
107
: true ,
111
108
) ;
112
109
} )
113
- . catch ( ( error ) => {
114
- logger . error ( {
115
- error : castError ( error ) ,
116
- message : "searchCompanies_error" ,
117
- searchLBB : {
118
- distanceKm : searchCompaniesParams . distanceKm ,
119
- lat : searchCompaniesParams . lat ,
120
- lon : searchCompaniesParams . lon ,
121
- romeCode : searchCompaniesParams . romeCode ,
122
- romeLabel : searchCompaniesParams . romeLabel ,
123
- nafCodes : searchCompaniesParams . nafCodes ,
124
- } ,
125
- } ) ;
110
+ . catch ( ( ) => {
126
111
return [ ] ;
127
112
} ) ,
128
113
) ;
@@ -157,28 +142,18 @@ export class HttpLaBonneBoiteGateway implements LaBonneBoiteGateway {
157
142
} ,
158
143
} ) ;
159
144
return this . #limiter. schedule ( async ( ) =>
160
- cachedGetLbbResult ( siret )
161
- . then ( ( result ) => {
162
- const item = result
163
- . map (
164
- ( props : LaBonneBoiteApiResultV2Props ) =>
165
- new LaBonneBoiteCompanyDto ( props ) ,
166
- )
167
- . filter ( ( result ) => result . isCompanyRelevant ( ) )
168
- . map ( ( result ) => result . toSearchResult ( romeDto ) )
169
- . at ( 0 ) ;
145
+ cachedGetLbbResult ( siret ) . then ( ( result ) => {
146
+ const item = result
147
+ . map (
148
+ ( props : LaBonneBoiteApiResultV2Props ) =>
149
+ new LaBonneBoiteCompanyDto ( props ) ,
150
+ )
151
+ . filter ( ( result ) => result . isCompanyRelevant ( ) )
152
+ . map ( ( result ) => result . toSearchResult ( romeDto ) )
153
+ . at ( 0 ) ;
170
154
171
- return item ?? null ;
172
- } )
173
- . catch ( ( error ) => {
174
- logger . error ( {
175
- error : castError ( error ) ,
176
- message : "fetchCompanyBySiret_error" ,
177
- siret,
178
- romeLabel : romeDto . romeLabel ,
179
- } ) ;
180
- throw error ;
181
- } ) ,
155
+ return item ?? null ;
156
+ } ) ,
182
157
) ;
183
158
}
184
159
0 commit comments