Skip to content

Commit

Permalink
fixing NI logs for bookmarking.
Browse files Browse the repository at this point in the history
  • Loading branch information
ulysses-cognizant committed Feb 7, 2025
1 parent dd2e79a commit 6e7bcc2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/server/locations/helpers/location-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ function convertPointToLonLat(matches, location, index) {
if (matches || matches[index]) {
if (location === 'uk-location') {
point = new OsGridRef(
matches[index].GAZETTEER_ENTRY.GEOMETRY_X,
matches[index].GAZETTEER_ENTRY.GEOMETRY_Y
matches[index].GAZETTEER_ENTRY?.GEOMETRY_X,
matches[index].GAZETTEER_ENTRY?.GEOMETRY_Y
)
const latlon = OsGridRef.osGridToLatLong(point)
lat = latlon._lat
Expand Down
48 changes: 28 additions & 20 deletions src/server/locations/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { getNearestLocation } from '~/src/server/locations/helpers/get-nearest-l
import { sentenceCase } from '~/src/server/common/helpers/sentence-case'
import { convertFirstLetterIntoUppercase } from '~/src/server/locations/helpers/convert-first-letter-into-upper-case'
import { transformKeys } from '~/src/server/locations/helpers/generate-daily-summary-with-calendar-day'
import { airQualityValues } from '~/src/server/locations/helpers/air-quality-values.js'

const logger = createLogger()

Expand Down Expand Up @@ -124,14 +123,15 @@ const searchMiddleware = async (request, h) => {
String(urlRoute)
)
const titleRoute = convertStringToHyphenatedLowercaseWords(String(title))
const { forecastNum, nearestLocationsRange } = getNearestLocation(
selectedMatches,
getForecasts?.forecasts,
getMeasurements?.measurements,
LOCATION_TYPE_UK,
0,
lang
)
const { forecastNum, nearestLocationsRange, airQuality } =
getNearestLocation(
selectedMatches,
getForecasts?.forecasts,
getMeasurements?.measurements,
LOCATION_TYPE_UK,
0,
lang
)
if (selectedMatches.length === 1) {
return handleSingleMatch(h, request, {
searchTerms,
Expand All @@ -157,9 +157,7 @@ const searchMiddleware = async (request, h) => {
selectedMatches.length > 1 &&
locationNameOrPostcode.length > 3
) {
const { airQuality } = airQualityValues(forecastNum, lang)
return handleMultipleMatches(h, request, {
forecastNum,
selectedMatches,
headerTitleRoute,
titleRoute,
Expand Down Expand Up @@ -213,20 +211,31 @@ const searchMiddleware = async (request, h) => {
)
return h.redirect('/location-not-found').takeover()
}
const { forecastNum, nearestLocationsRange, latlon } = getNearestLocation(
getNIPlaces?.results,
getForecasts?.forecasts,
getMeasurements?.measurements,
LOCATION_TYPE_UK,
0,
lang
)

logger.info(
`::::::::::: getNIPlaces results passed to getNearestLocation en ::::::::::: ${JSON.stringify(getNIPlaces?.results)}`
)
const { forecastNum, nearestLocationsRange, latlon, airQuality } =
getNearestLocation(
getNIPlaces?.results,
getForecasts?.forecasts,
getMeasurements?.measurements,
LOCATION_TYPE_NI,
0,
lang
)
logger.info(
`::::::::::: getNIPlaces 1 forecastNum stringify ::::::::::: ${JSON.stringify(forecastNum)}`
)
logger.info(
`::::::::::: getNIPlaces 1 latlon ::::::::::: ${JSON.stringify(latlon)}`
)
logger.info(
`::::::::::: getNIPlaces 1 result stringify ::::::::::: ${JSON.stringify(getNIPlaces?.results)}`
)
logger.info(
`::::::::::: getNIPlaces 1 airQuality stringify ::::::::::: ${JSON.stringify(airQuality)}`
)
logger.info(
`::::::::::: getNIPlaces 1 nearestLocationsRange stringify ::::::::::: ${JSON.stringify(nearestLocationsRange)}`
)
Expand Down Expand Up @@ -257,7 +266,6 @@ const searchMiddleware = async (request, h) => {
}
}
]
const { airQuality } = airQualityValues(forecastNum, lang)
request.yar.set('locationData', {
results: resultNI,
airQuality,
Expand Down

0 comments on commit 6e7bcc2

Please sign in to comment.