Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/routes/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
path: '/results',
options: {
description: 'Results Page',
handler: async (request, h) => {

Check failure on line 32 in server/routes/results.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Function has a complexity of 11 which is greater than 10 authorized.

See more on https://sonarcloud.io/project/issues?id=DEFRA_fmp-app&issues=AZ2MsufOqk1axVHQa97T&open=AZ2MsufOqk1axVHQa97T&pullRequest=760
const { polygon, encodedPolygon } = checkParamsForPolygon(request.query)
const [contactData, floodData] = await Promise.all([
request.server.methods.getPsoContactsByPolygon(polygon),
Expand All @@ -46,8 +46,8 @@
floodData.isFZ1Andlt1ha = floodData.floodZone === '1' && floodData.areaInHectares < 1
floodData.isFZ1Andgt1ha = floodData.floodZone === '1' && floodData.areaInHectares >= 1
floodData.areaInHectares = floodData.areaInHectares !== '0' && floodData.areaInHectares !== 0 ? floodData.areaInHectares : 'less than 0.01'
floodData.riversAndSea = floodData.floodZone !== '1' || floodData.floodZoneClimateChange || floodData.floodZoneClimateChangeNoData
floodData.hasSurfaceWater = Boolean(floodData?.surfaceWater?.riskBand || floodData?.surfaceWaterClimateChange)
floodData.hasFloodRisk = floodData.surfaceWater?.riskBand || floodData.floodZone !== '1' || floodData.floodZoneClimateChange || floodData.floodZoneClimateChangeNoData
return h.view('results', { floodData, contactData, showOrderProduct4Button, encodedPolygon, polygon, pauseP1Data, over300Hectares })
}
}
Expand Down
11 changes: 9 additions & 2 deletions server/services/floodDataByPolygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@ const getFloodDataByPolygon = async (polygon) => {
getSurfaceWater({ geometryType: 'esriGeometryPolygon', polygon }),
// getSurfaceWaterClimateChange({ geometryType: 'esriGeometryPolygon', polygon }),
isRiskAdminArea(polygon)
]).then((responseArray) => {
return Object.assign(results, ...responseArray)
]).then(([floodZonesData, floodZonesCCData, surfaceWaterData, riskAdminData]) => {
return Object.assign(results, {
...floodZonesData,
...floodZonesCCData,
...surfaceWaterData,
...riskAdminData,
hasRiversSource: floodZonesData.hasRiversSource || floodZonesCCData.hasRiversSource,
hasSeaSource: floodZonesData.hasSeaSource || floodZonesCCData.hasSeaSource
})
})
return results
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion server/views/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h1 id="heading" class="govuk-heading-xl">{{ pageTitle }}</h1>
{% include "./partials/results-page/is-risk-admin-area.html" %}
{% endif %}

{% if floodData.surfaceWater.riskBand or floodData.riversAndSea %}
{% if floodData.hasFloodRisk %}
<p id="riskFloodingFrom" class="govuk-body">In your proposed development site there is a risk of flooding from:</p>
<ul class="govuk-list govuk-list--bullet">
{% if floodData.hasRiversSource and floodData.hasSeaSource %}<li id="riversAndSeaBulletPoint" data-testid="risk-list-rivers-sea">rivers and the sea (fluvial and tidal)</li>
Expand Down
Loading