Skip to content

Commit

Permalink
fix: how far along value
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel78uk committed Nov 20, 2023
1 parent dbed860 commit 9a22c7c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
20 changes: 19 additions & 1 deletion server/routes/water-quality/extent-three.route.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand All @@ -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',
Expand Down
14 changes: 12 additions & 2 deletions server/services/incident.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 7 additions & 0 deletions server/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 9a22c7c

Please sign in to comment.