diff --git a/api/src/paths/v2/iapp.ts b/api/src/paths/v2/iapp.ts index f3f4a220b..0d79a575d 100644 --- a/api/src/paths/v2/iapp.ts +++ b/api/src/paths/v2/iapp.ts @@ -220,6 +220,13 @@ function sanitizeIAPPFilterObject(filterObject: any, req: any) { body: JSON.stringify(sanitizedSearchCriteria, null, 2) }); + + if(filterObject?.CSVType) + { + sanitizedSearchCriteria.isCSV = true; + sanitizedSearchCriteria.CSVType = filterObject.CSVType; + } + return sanitizedSearchCriteria; } @@ -458,37 +465,36 @@ function selectStatement(sqlStatement: SQLStatement, filterObject: any) { function fromStatement(sqlStatement: SQLStatement, filterObject: any) { const from = sqlStatement.append(`from sites `); if (filterObject.isCSV) { - sqlStatement.append(` i `) switch (filterObject.CSVType) { case 'site_selection_extract': - sqlStatement.append(SQL` INNER JOIN site_selection_extract pe ON i.site_id = pe.site_id `); + sqlStatement.append(SQL` INNER JOIN site_selection_extract pe ON sites.site_id = pe.site_id `); break; case 'survey_extract': - sqlStatement.append(SQL` INNER JOIN survey_extract pe ON i.site_id = pe.site_id`); + sqlStatement.append(SQL` INNER JOIN survey_extract pe ON sites.site_id = pe.site_id`); break; case 'chemical_treatment_extract': - sqlStatement.append(SQL` INNER JOIN chemical_treatment_extract pe ON i.site_id = pe.site_id`); + sqlStatement.append(SQL` INNER JOIN chemical_treatment_extract pe ON sites.site_id = pe.site_id`); break; case 'mechanical_treatment_extract': - sqlStatement.append(SQL` INNER JOIN mechanical_treatment_extract pe ON i.site_id = pe.site_id`); + sqlStatement.append(SQL` INNER JOIN mechanical_treatment_extract pe ON sites.site_id = pe.site_id`); break; case 'chemical_monitoring_extract': - sqlStatement.append(SQL` INNER JOIN chemical_monitoring_extract pe ON i.site_id = pe.site_id`); + sqlStatement.append(SQL` INNER JOIN chemical_monitoring_extract pe ON sites.site_id = pe.site_id`); break; case 'mechanical_monitoring_extract': - sqlStatement.append(SQL` INNER JOIN mechanical_monitoring_extract pe ON i.site_id = pe.site_id`); + sqlStatement.append(SQL` INNER JOIN mechanical_monitoring_extract pe ON sites.site_id = pe.site_id`); break; case 'biological_treatment_extract': - sqlStatement.append(SQL` INNER JOIN biological_treatment_extract pe ON i.site_id = pe.site_id`); + sqlStatement.append(SQL` INNER JOIN biological_treatment_extract pe ON sites.site_id = pe.site_id`); break; case 'biological_monitoring_extract': - sqlStatement.append(SQL` INNER JOIN biological_monitoring_extract pe ON i.site_id = pe.site_id`); + sqlStatement.append(SQL` INNER JOIN biological_monitoring_extract pe ON sites.site_id = pe.site_id`); break; case 'biological_dispersal_extract': - sqlStatement.append(SQL` INNER JOIN biological_dispersal_extract pe ON i.site_id = pe.site_id`); + sqlStatement.append(SQL` INNER JOIN biological_dispersal_extract pe ON sites.site_id = pe.site_id`); break; default: - sqlStatement.append(SQL` INNER JOIN site_selection_extract pe ON i.site_id = pe.site_id `); + sqlStatement.append(SQL` INNER JOIN site_selection_extract pe ON sites.site_id = pe.site_id `); break; }} return from; diff --git a/appv2/src/state/sagas/map.ts b/appv2/src/state/sagas/map.ts index 36ed36749..437915798 100644 --- a/appv2/src/state/sagas/map.ts +++ b/appv2/src/state/sagas/map.ts @@ -499,22 +499,19 @@ function* handle_RECORD_SET_TO_EXCEL_REQUEST(action) { let networkReturn; let conditionallyUnnestedURL; if (set.recordSetType === 'POI') { - let filters = getSearchCriteriaFromFilters( - set?.advancedFilters ? set?.advancedFilters : null, - userSettings?.recordSets ? userSettings?.recordSets : null, - action.payload.id, - true, - set?.gridFilters ? set?.gridFilters : null, - 0, - null, // CSV limit - mapState?.layers?.[action.payload.id]?.filters?.sortColumns - ? mapState?.layers?.[action.payload.id]?.filters?.sortColumns - : null - ); - filters.isCSV = true; - filters.CSVType = action.payload.CSVType; - - networkReturn = yield InvasivesAPI_Call('GET', `/api/points-of-interest/`, filters, {}); + + const currentState = yield select(selectUserSettings); + const mapState = yield select(selectMap); + + let filterObject = getRecordFilterObjectFromStateForAPI(action.payload.id, currentState); + //filterObject.page = action.payload.page ? action.payload.page : mapState.recordTables?.[action.payload.recordSetID]?.page; + filterObject.limit = 200000; + filterObject.isCSV = true; + filterObject.CSVType = action.payload.CSVType; + + const networkReturn = yield InvasivesAPI_Call('POST', `/api/v2/iapp/`, { + filterObjects: [filterObject] + }); conditionallyUnnestedURL = networkReturn?.data?.result ? networkReturn.data.result : networkReturn?.data; } else {