diff --git a/api/src/paths/v2/activities.ts b/api/src/paths/v2/activities.ts
index c6ae7c856..6df410a3e 100644
--- a/api/src/paths/v2/activities.ts
+++ b/api/src/paths/v2/activities.ts
@@ -181,14 +181,15 @@ function sanitizeActivityFilterObject(filterObject: any, req: any) {
sanitizedTableFilters.push(filter);
break;
}
+ break;
case 'spatialFilterDrawn':
if (filter.filter) {
- clientFilterGeometries.push(filter.filter);
+ clientFilterGeometries.push(filter.filter?.geometry);
}
break;
case 'spatialFilterUploaded':
- if (!isNaN(filter?.filter?.geometry)) {
- serverFilterGeometries.push(filter.filter.geometry);
+ if (!isNaN(parseInt(filter?.filter))) {
+ serverFilterGeometries.push(parseInt(filter.filter));
}
break;
default:
@@ -197,11 +198,13 @@ function sanitizeActivityFilterObject(filterObject: any, req: any) {
});
}
+ sanitizedSearchCriteria.serverFilterGeometries = serverFilterGeometries;
+ sanitizedSearchCriteria.clientFilterGeometries = clientFilterGeometries;
sanitizedSearchCriteria.clientReqTableFilters = sanitizedTableFilters;
defaultLog.debug({
label: 'getActivitiesBySearchFilterCriteria',
message: 'sanitizedObject',
- body: sanitizedSearchCriteria
+ body: JSON.stringify(sanitizedSearchCriteria, null, 2)
});
return sanitizedSearchCriteria;
@@ -259,6 +262,9 @@ function getActivitiesBySearchFilterCriteria(): RequestHandler {
}
function getActivitiesSQLv2(filterObject: any) {
+ try
+ {
+
let sqlStatement: SQLStatement = SQL``;
sqlStatement = initialWithStatement(sqlStatement);
sqlStatement = additionalCTEStatements(sqlStatement, filterObject);
@@ -272,6 +278,12 @@ function getActivitiesSQLv2(filterObject: any) {
defaultLog.debug({ label: 'getActivitiesBySearchFilterCriteria', message: 'sql', body: sqlStatement });
return sqlStatement;
+ }
+
+ catch(e) {
+ defaultLog.debug({ label: 'getActivitiesBySearchFilterCriteria', message: 'error', body: e.message });
+ throw e
+ }
}
function initialWithStatement(sqlStatement: SQLStatement) {
@@ -308,7 +320,7 @@ CurrentNegativeObservations AS (
serverFilterGeometryIDs as (
- select unnest(array[79,80]) as id
+ select unnest(array[${filterObject?.serverFilterGeometries.join(',')}]) as id
),
serverFilterGeometries AS (
@@ -342,7 +354,7 @@ CurrentNegativeObservations AS (
clientFilterGeometries AS (
SELECT
unnest(array[${filterObject.clientFilterGeometries
- .map((geometry) => `st_setsrid(st_geomfromgeojson(${geometry.geometry}, 4326)`)
+ .map((geometry) => `st_setsrid(st_geomfromgeojson(${geometry?.geometry}, 4326)`)
.join(',')}]) AS geojson
),
@@ -372,7 +384,7 @@ activities as (
case when CurrentNegativeObservations.current_negative_species is null then false else true end as has_current_negative
`);
- if (filterObject?.serverFilterGeometries?.length > 0) {
+ /*if (filterObject?.serverFilterGeometries?.length > 0) {
sqlStatement.append(`
,case when ServerBoundariesToIntersect.geog is null then false else true end as intersects_server_boundary
`);
@@ -381,7 +393,7 @@ activities as (
sqlStatement.append(`
,case when ClientBoundariesToIntersect.geog is null then false else true end as intersects_client_boundary
`);
- }
+ }*/
sqlStatement.append(`
from not_deleted_activities a
diff --git a/appv2/src/UI/Overlay/Records/RecordSet.tsx b/appv2/src/UI/Overlay/Records/RecordSet.tsx
index 2f11b689f..de5b584a9 100644
--- a/appv2/src/UI/Overlay/Records/RecordSet.tsx
+++ b/appv2/src/UI/Overlay/Records/RecordSet.tsx
@@ -194,8 +194,8 @@ const RecordSetFooter = (props) => {
const Filter = (props) => {
const userSettingsState = useSelector((state: any) => state.UserSettings);
- const serverBoundariesToDisplay = useSelector((state: any) => state.Map.serverBoundaries).map((boundary) => {
- return { label: boundary.name, value: boundary.id };
+ const serverBoundariesToDisplay = useSelector((state: any) => state.Map.serverBoundaries)?.map((boundary) => {
+ return { label: boundary.title, value: boundary.id };
});
console.dir(userSettingsState);
@@ -269,7 +269,6 @@ const Filter = (props) => {
dispatch({
type: RECORDSET_UPDATE_FILTER,
payload: {
- filterType: 'tableFilter',
setID: props.setID,
filterID: props.id,
filter: e.target.value
@@ -333,7 +332,7 @@ const Filter = (props) => {
dispatch({
type: RECORDSET_UPDATE_FILTER,
payload: {
- filterType: 'tableFilter',
+ //filterType: 'tableFilter',
setID: props.setID,
filterID: props.id,
operator: e.target.value
@@ -354,21 +353,21 @@ const Filter = (props) => {
),
spatialFilterDrawn: (
<>
-
-
>
),
spatialFilterUploaded: (
<>
-
-
>
)
diff --git a/appv2/src/state/reducers/userSettings.ts b/appv2/src/state/reducers/userSettings.ts
index 5ba3be99f..4d6c49242 100644
--- a/appv2/src/state/reducers/userSettings.ts
+++ b/appv2/src/state/reducers/userSettings.ts
@@ -151,7 +151,7 @@ function createUserSettingsReducer(configuration: AppConfig): (UserSettingsState
id: getUuid(),
field: action.payload.field,
filterType: action.payload.filterType,
- operator: action.payload.operator,
+ operator: action.payload.operator ? action.payload.operator : 'CONTAINS',
filter: action.payload.filter ? action.payload.filter : ''
});
break;
@@ -180,25 +180,24 @@ function createUserSettingsReducer(configuration: AppConfig): (UserSettingsState
(filter) => filter.id !== action.payload.filterID
);
- if (action.payload.filterType) {
- const index = draftState.recordSets[action.payload.setID]?.tableFilters.findIndex(
- (filter) => filter.id === action.payload.filterID
- );
- if (index !== -1)
+ const index = draftState.recordSets[action.payload.setID]?.tableFilters.findIndex(
+ (filter) => filter.id === action.payload.filterID
+ );
+ if (index !== -1)
+ if (action.payload.filterType) {
draftState.recordSets[action.payload.setID].tableFilters[index].filterType = action.payload.filterType;
+ }
- if (
- action.payload.filterType === 'spatialFilterDrawn' ||
- action.payload.filterType === 'spatialFilterUploaded'
- ) {
- delete draftState.recordSets[action.payload.setID].tableFilters[index].field;
- if (!action.payload.operator) {
- draftState.recordSets[action.payload.setID].tableFilters[index].operator = 'CONTAINED IN';
- }
- delete draftState.recordSets[action.payload.setID].tableFilters[index].field;
- if (!action.payload.filter) {
- delete draftState.recordSets[action.payload.setID].tableFilters[index].filter;
- }
+ if (
+ action.payload.filterType === 'spatialFilterDrawn' ||
+ action.payload.filterType === 'spatialFilterUploaded'
+ ) {
+ delete draftState.recordSets[action.payload.setID].tableFilters[index].field;
+ if (!action.payload.operator) {
+ draftState.recordSets[action.payload.setID].tableFilters[index].operator = 'CONTAINED IN';
+ }
+ if (!action.payload.filter) {
+ delete draftState.recordSets[action.payload.setID].tableFilters[index].filter;
}
}
diff --git a/appv2/src/state/sagas/userSettings.ts b/appv2/src/state/sagas/userSettings.ts
index deab48722..6e2f86f22 100644
--- a/appv2/src/state/sagas/userSettings.ts
+++ b/appv2/src/state/sagas/userSettings.ts
@@ -299,7 +299,6 @@ function* handle_USER_SETTINGS_GET_INITIAL_STATE_REQUEST(action) {
const recordsExpandedState = JSON.parse(localStorage.getItem('records-expanded'));
const recordSets = oldAppState?.recordSets ? oldAppState.recordSets : defaultRecordSet;
- const recordsExpanded = recordsExpandedState ? recordsExpandedState : false;
yield put({ type: GET_API_DOC_REQUEST });
yield take(GET_API_DOC_SUCCESS);
@@ -311,7 +310,6 @@ function* handle_USER_SETTINGS_GET_INITIAL_STATE_REQUEST(action) {
activeActivityDescription: oldDesc,
activeIAPP: IAPPID,
recordSets: recordSets,
- recordsExpanded: recordsExpanded
}
});
} catch (e) {