diff --git a/server/routes/water-quality/extent-three.route.js b/server/routes/water-quality/extent-three.route.js index 78c5c6f3..0f3c41fd 100644 --- a/server/routes/water-quality/extent-three.route.js +++ b/server/routes/water-quality/extent-three.route.js @@ -1,6 +1,7 @@ 'use strict' -const { Paths, Views } = require('../../utils/constants') +const { Paths, Views, WQSirpRedisKeys } = require('../../utils/constants') +const RedisService = require('../../services/redis.service') const handlers = { get: (request, h) => { @@ -11,12 +12,29 @@ const handlers = { }, post: (request, h) => { const context = _getContext() + const payload = request.payload + + _generateSirpData(request, payload) + return h.view(Views.WATER_TYPE_AQUATICLIFE, { ...context }) } } +const _generateSirpData = async (request, payload) => { + const pollutionWidth = payload['event-name'] + + // set it only if defined + if (pollutionWidth) { + RedisService.set( + request, + WQSirpRedisKeys.WQ_SIRP_HOW_FAR_ALONG, + pollutionWidth + ) + } +} + const _getContext = () => { return { pageTitle: 'Report an environmental incident', diff --git a/server/services/incident.service.js b/server/services/incident.service.js index cb301912..f38940cd 100644 --- a/server/services/incident.service.js +++ b/server/services/incident.service.js @@ -270,8 +270,18 @@ module.exports = class IncidentService { incidentObj.sirp_WaterQuality.sirp_Howfaracrossthewaterfeaturecanyouseethe = howFarAcrossArray } - incidentObj.sirp_WaterQuality.sirp_Howfaralongthewaterfeaturedoesthepollutio = - [100] + + // howFarAlong - TEST + + const howFarAlong = await RedisService.get( + request, + WQSirpRedisKeys.WQ_SIRP_HOW_FAR_ALONG + ) + + if (howFarAlong !== undefined) { + incidentObj.sirp_WaterQuality.sirp_Howfaralongthewaterfeaturedoesthepollutio = + howFarAlong + } // Seen dead fish Done const seenDeadFish = await RedisService.get( diff --git a/server/utils/constants.js b/server/utils/constants.js index 716a9994..d2879569 100644 --- a/server/utils/constants.js +++ b/server/utils/constants.js @@ -211,8 +211,15 @@ const WQSirpRedisKeys = { WQ_SIRP_POLLUTION_SOURCE: 'WQ_sirp_Doyouthinkyouknowwherethepollutioniscomin', WQ_SIRP_POLLUTION_SOURCE_OTHER: 'WQ_sirp_pollutionSourceOther', + WQ_SIRP_HOW_FAR_ACROSS: 'WQ_sirp_Howfaracrossthewaterfeaturecanyouseethe', + + WQ_SIRP_HOW_FAR_ALONG: 'WQ_sirp_Howfaralongthewaterfeaturedoesthepollutio', + + + WQ_SIRP_HOW_FAR_ALONG: 'WQ_', + WQ_SIRP_SEEN_DEAD_FISH: 'WQ_sirp_Haveyouseendeadfishnearby', WQ_SIRP_HOW_MANY_DEAD_FISH: 'WQ_sirp_Howmanydeadfishhaveyouseen', ANONYMOUS_PAYLOAD: 'anonymous.payload',