From e59c3f6902717d75a5d1a319d624331c074fcea6 Mon Sep 17 00:00:00 2001 From: e-halinen <54105602+e-halinen@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:15:37 +0200 Subject: [PATCH] undefined trunkRoute error handling (#433) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix combining rows * MM-484: Allow launching separate services as different instances (#363) * MM-484: Allow launching separate services as different instances * Add default value to PUBLISHER_RENDER_URL * MM-497: Endpoint for render URL generation, Update README about service splitting (#364) * MM-497: Endpoint for render URL generation * Update README about the sectioning of the service, new start commands and explanations. * Remove extra slash from fallback url * Allow route title to enter the padding area This allow rendering to continue and not to fail if the route title is too long. * MM-495: Rename ticket-zones.json, update README (#365) * MM-502: Add more functionality to generateRenderUrl endpoint and rendering (#366) * MM-502: Add current date by default unless date is included in generateRenderUrl params * Tweak order of local setup commands, add moment to dependencies * MM-502: Add parameter to hide address info from timetable render * MM-502: Add print button to rendered document, and a parameter to hide it from document * Update yarn.locl --------- Co-authored-by: Juho Hänninen * Fix url env variables for server (#368) * Fix url env variables for server * Fix webpack errors due to fs reference in browser app * Fix build and type errors * Fix server host checking * Add link to publisher-server for worker * MM-504: Add redirect parameter to generateRenderUrl endpoint * Remove forever from deployment * Add publisher server url to env to be build in the image * Fix and enhance puppeteer console logging * Remove trailing slash from server url env * Upgrade hsl-map-style * Fix single departure grouping with same minutes * Add filtering for duplicate departures * Drop console statement * day specific a4 timetable departures * bug fixes * l_rail color added * legend updated * translations * style reference update * yarn.lock * revert package.json and yarn.lock * new color and background color for stopPoster * yarn.lock update * L-rail icon and color update * MM-507: Add Docker Compose setup for development (#383) * MM-507: Add docker compose configuration for development * MM-507: Add setup instructions in README * Add font instructions to README, tidy up * Persist postgresql volume, add db dependency for startup sequence * Use tram diagram also on light rail stops (cherry picked from commit d0932d1335fc7c00911c6465bef0c9dd53908119) * Resize Pikaratikka's icon to render it correctly * fixed StopPoster timetable columns * removed redundant prop * #26114: language change for print button (#388) * #26114: Add language choices into the print button on timetable rendering * #26236: Fix StopPosterA3 generating error (#391) * Fix StopPosterA3 generating error * Refactor stopId property from A3Timetable to prevent same error * Merge conflict fix * empty day columns fixed * AB#27362: Scripted test stops (#393) * AB#27362: Script test stop posters * Fix typo in component name * Add poster download to test script * Remove comments * Add test results folder to gitignore * AB#27362: Script test stop posters Fix typo in component name Add poster download to test script Remove comments Add test results folder to gitignore * yarn.lock and dockerfile updates * update react * deprecated lifecycles removed * WIP: Create line timetable component * Include app.js for new component * AB#32085: WIP: Add LineTimetable component * Change routeIdentifier property * AB#32085: Add LineTimetable to test script * Add font styling, tweak font sizes and date formatting * AB#33201: Fix wrong route color in StopPoster * Add build command to compose and fix output folder location * Revert "Merge pull request #397 from HSLdevcom/AB#32085_line_timetable" This reverts commit 91be8f2c9e7e5181f8d3aa6930d5911cee3da259, reversing changes made to 1bdc2b9484e84a8feb978c2b5c2923a6b1800162. * Revert "#AB25283 Node/React update" * Revert "Revert "Merge pull request #397 from HSLdevcom/AB#32085_line_timetable"" This reverts commit 89aa8907b73424eb493c3f2fb00bef66fe1838f0. * Revert "Revert "#AB25283 Node/React update"" * build fix * removing fast refresh from dev webpack * removing fast refresh from webpack.common * node env * AB#33966: Pass api key to client-side in env variables (#407) * Revert "AB#33966: Pass api key to client-side in env variables (#407)" This reverts commit da5eaf4994f9d9bed604db4974f123a2b2c58793. * AB#33966: Expose local env file in compose to pass apikey without extra commands (#408) * AB#32085: add print button (#409) * AB#33966: Expose local env file in compose to pass apikey without extra commands * AB#32085: Add missing print button to line timetable, cleanup unused code and components * AB#32085: Remove unused prop * AB#32667: Add smaller size variant to TerminalPoster component (#399) * Bump map-style version to 1.1.3 (#412) * WIP: Bug fix for stop poster * AB#37216: Fix horizontal overflow error on large terminal route lists (#413) * Fix trunk route color in route diagram (#414) * Fix trunk route color in route diagram * Add coloring to terminalAreaRoutes * AB#39315: remove opening times from SVG (#416) * AB#39315: Remove opening times from SVG * AB#39315: Resize new SVG * AB#39315: Revert resize * AB#32085: Refactor generateRenderUrl endpoint to accept LineTimetable requests (#410) * AB#32085: Show both directions in same timetable (#411) * AB#32085: Show both directions in same timetable, include variants * Add different layout when querying for routes that don't have timed stops * Tweak styling * WIP: Variants and new GraphQL queries * Add new test stops and LineTimetable test runs * Refactor queries and line timetable rendering logic * AB#32085: WIP: Refactored line timetables * AB#32085: WIP - Refactor LineTimetable logic, grouping bug to be fixed * Remove unused code, add latest test script * AB#32085: Add padding, limit number of timed stops * AB#32085: Tweak styling, refactor render logic (#419) * AB#32085: Tweak styling, refactor render logic * Tweak styling, merge separate friday departures to weekday departures * Add fix for partial departures along a route * Partial departure fix continues * Shorten train IDs so they display correctly * AB#32085: Change LineTimetable print layout to A5 (#420) * AB#32085: Change print layout to A5, tweak styling * Variant logic for tram routes * Add empty array checks to timetable rendering * AB#44831: Add font styling to StopPoster map legend texts (#421) * AB#44831: Add italics to Stop Poster TableHeaders (#422) * AB#46862: Refactor route filtering logic (#425) * AB#32085: Add page numbering (#424) * AB#32085: Add page numbers * Add page numbering to other rendering state * Add styling tweaks and note filtering * WIP: tweak styling for better page breaks * Add tweaked test script * Fix duplicate hour cutoff bug * WIP: Latest tweaks for linetimetable printing * Fix page break issues when printing * Remove unused code for LineTimetable * Add footnote styling * AB#32085: Tweak print parameters, clean up (#428) * AB#32085: Tweak LineTimetable font styles (#429) * AB#48147: Improve missing line data error handling (#431) * AB#48147: Improve empty line node array error handling (#432) --------- Co-authored-by: Anton Co-authored-by: Juho Hänninen Co-authored-by: Juho Hänninen Co-authored-by: Anton Jyrkiäinen --- src/components/map/stopMapContainer.js | 13 +++++++++++-- src/util/routes.js | 9 ++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/components/map/stopMapContainer.js b/src/components/map/stopMapContainer.js index cb3bb8d0..f86c98d1 100644 --- a/src/components/map/stopMapContainer.js +++ b/src/components/map/stopMapContainer.js @@ -121,6 +121,16 @@ const stopsMapper = stopGroup => ({ const destinationSe = mergedRouteSegment.destinationSe ? mergedRouteSegment.destinationSe : get(mergedRouteSegment, 'route.nodes[0].destinationSe'); + + let trunkRoute; + + try { + trunkRoute = + mergedRouteSegment.line.nodes && mergedRouteSegment.line.nodes[0].trunkRoute === '1'; + } catch (e) { + trunkRoute = false; + } + return { routeId: trimRouteId(mergedRouteSegment.routeId), destinationFi, @@ -128,8 +138,7 @@ const stopsMapper = stopGroup => ({ viaFi: mergedRouteSegment.viaFi, viaSe: mergedRouteSegment.viaSe, mode: mergedRouteSegment.route.nodes[0].mode, - trunkRoute: - mergedRouteSegment.line.nodes && mergedRouteSegment.line.nodes[0].trunkRoute === '1', + trunkRoute, }; }), ).sort(routeCompare), diff --git a/src/util/routes.js b/src/util/routes.js index 8114c6cf..7a1dbd28 100644 --- a/src/util/routes.js +++ b/src/util/routes.js @@ -65,7 +65,14 @@ function routesToTree(routes, { stopZone, shortId }, height = 'auto', width = MA type: 'stop', zone: stop.stopZone, routeSegments: stop.routeSegments.nodes.map(segment => { - const trunkRoute = segment.line.nodes[0].trunkRoute === '1'; + + let trunkRoute; + try { + trunkRoute = segment.line.nodes[0].trunkRoute === '1'; + } catch (e) { + trunkRoute = false; + } + return { ...segment, trunkRoute,