Skip to content

Commit

Permalink
add sub-sector-descends query param to the request body for exporting…
Browse files Browse the repository at this point in the history
… data
  • Loading branch information
Richard Pentecost committed Mar 1, 2024
1 parent 8a5fc6e commit e1b4bfc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/apps/companies/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const QUERY_FIELDS_MAP = {
archived: 'archived',
name: 'name',
sectorDescends: 'sector_descends',
subSectorDescends: 'sub_sector_descends',
country: 'country',
ukRegion: 'uk_region',
headquarterType: 'headquarter_type',
Expand Down
16 changes: 15 additions & 1 deletion src/modules/search/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ const buildOptions = (isAggregation, searchUrl, body, entity) => {
}
}

const mergeSectorAndSubSectorParams = (requestBody) => {
const { sub_sector_descends, sector_descends, ...reqBody } = requestBody
const mergedSectors = [
...(sector_descends ? sector_descends : []),
...(sub_sector_descends ? sub_sector_descends : []),
]

return {
...reqBody,
sector_descends: mergedSectors,
}
}

function search({
req,
searchTerm: term = '',
Expand Down Expand Up @@ -68,7 +81,7 @@ function exportSearch({ req, searchTerm = '', searchEntity, requestBody }) {
if (searchEntity == 'investment_project') {
transformedRequestBody = transformLandDateFilters(requestBody)
} else {
transformedRequestBody = requestBody
transformedRequestBody = mergeSectorAndSubSectorParams(requestBody)
}
const searchUrl = `${config.apiRoot}/${apiVersion}/search`
// If the requested CSV export should contain policy feedback, we need to call
Expand Down Expand Up @@ -125,4 +138,5 @@ module.exports = {
exportSearch,
searchAutocomplete,
searchDnbCompanies,
mergeSectorAndSubSectorParams,
}

0 comments on commit e1b4bfc

Please sign in to comment.