-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mijn-1316/electrische laadpalen #1117
Conversation
7ca8394
to
7037405
Compare
77cdf40
to
13a79c1
Compare
Transform Laadpaal detail response. Add detailpanel oplaadpunten. Do a detail loopup after composing the urls content with the next urls content. Add transformers, nextUrls capabilities. Composed detail lookup still not working. Electrische laadpalen toegevoed aan mijn buurtkaart. Add charge-point.svg icon. Different name for beschikbaar and snel beschikbaar Remove unnecessary config in buurt.ts Refactor source api request. Refactor multiple request interceptors, next request logic.
…ig request functionality.
13a79c1
to
f530f03
Compare
src/server/config.ts
Outdated
@@ -62,6 +62,7 @@ export interface DataRequestConfig extends AxiosRequestConfig { | |||
cancelTimeout?: number; | |||
postponeFetch?: boolean; | |||
urls?: Record<string, string>; | |||
nextUrls?: string[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kun je deze weghalen? In source-api-request doen we niks met nextUrls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -426,24 +425,10 @@ export const datasetEndpoints: Record< | |||
'https://map.data.amsterdam.nl/maps/oplaadpunten?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAMES=ms:snel_beschikbaar&OUTPUTFORMAT=geojson&SRSNAME=urn:ogc:def:crs:EPSG::4326', | |||
], | |||
}, | |||
disabled: IS_AP, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry Oscar, zo kunnen we het alleen op test bekijken. Beter is disabled: IS_PRODUCTION
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bijna! :-)
src/server/services/buurt/buurt.ts
Outdated
requestConfig.request = config.requestConfig.request; | ||
} | ||
|
||
const response: any = await requestData(requestConfig, requestID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requestConfig.url, | ||
'https://map.data.amsterdam.nl/maps/oplaadpunten?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAMES=ms:snel_beschikbaar&OUTPUTFORMAT=geojson&SRSNAME=urn:ogc:def:crs:EPSG::4326', | ||
]; | ||
const requests = urls?.map((url) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const requests = urls?.map((url) => { | |
const requests = urls.map((url) => { |
Optional chaining is hier niet vereist aangezien urls altijd bestaat.
let responses: any; | ||
|
||
try { | ||
responses = await Promise.all(requests); | ||
} catch (error) { | ||
return error; | ||
} | ||
|
||
responses = responses.filter((res: any) => res.data); | ||
|
||
// If transformDetail is called return the first response for the detail view | ||
if (responses[0].data._embedded) return responses[0]; | ||
|
||
// Combine all responses into one for the list view | ||
if (responses.length > 1) { | ||
responses[0].data = responses.slice(1).reduce((acc: any, response: any) => { | ||
return acc.concat(response.data); | ||
}, responses[0].data); | ||
} | ||
return responses[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je kent de type hier dus any is niet nodig. Je hoeft de Promise.all ook niet te wrappen in try/catch, dat gebeurt al in source-api-request.
En ipv reduce, kun je niet beter iets doen als:
const responses = await Promise.all(requests);
responses[0].data = responses.map((response)=>response.data).flat();
return responses[0];
c4cd305
to
3976d07
Compare
No description provided.