Skip to content

Commit

Permalink
case insensitive search for iapp v2 endpoint, also make sure site_id …
Browse files Browse the repository at this point in the history
…column defaults to site id not short_id
  • Loading branch information
micheal-w-wells committed Oct 16, 2023
1 parent d752963 commit 08980d8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
30 changes: 11 additions & 19 deletions api/src/paths/v2/iapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,51 +461,43 @@ function whereStatement(sqlStatement: SQLStatement, filterObject: any) {
switch (filter.field) {
case 'site_id':
where.append(
`and sites.site_id ${filter.operator === 'CONTAINS' ? 'like' : 'not like'} '%${filter.filter}%' `
`and LOWER((sites.site_id::text)) ${filter.operator === 'CONTAINS' ? 'like' : 'not like'} LOWER('%${filter.filter}%') `
);
break;
case 'site_paper_file_id':
where.append(
`and sites.site_paper_file_id ${filter.operator === 'CONTAINS' ? 'like' : 'not like'} '%${filter.filter}%' `
`and LOWER(sites.site_paper_file_id) ${filter.operator === 'CONTAINS' ? 'like' : 'not like'} LOWER('%${filter.filter}%') `
);
break;
case 'jurisdictions_flattened':
where.append(
`and sites.jurisdictions_flattened ${filter.operator === 'CONTAINS' ? 'like' : 'not like'} '%${filter.filter}%' `
`and LOWER(sites.jurisdictions_flattened) ${filter.operator === 'CONTAINS' ? 'like' : 'not like'} LOWER('%${filter.filter}%') `
);
break;
case 'min_survey':
where.append(
`and sites.min_survey ${filter.operator === 'CONTAINS' ? 'like' : 'not like'} '%${
filter.filter
`and LOWER(sites.min_survey) ${filter.operator === 'CONTAINS' ? 'like' : 'not like'} LOWER('%${ filter.filter
}%' `
);
break;
case 'all_species_on_site':
where.append(
`and sites.all_species_on_site ${filter.operator === 'CONTAINS' ? 'like' : 'not like'} '%${
filter.filter
}%' `
`and LOWER(sites.all_species_on_site) ${filter.operator === 'CONTAINS' ? 'like' : 'not like'} LOWER('%${ filter.filter }%') `
);
break;
case 'max_survey':
where.append(
`and sites.max_survey ${filter.operator === 'CONTAINS' ? 'like' : 'not like'} '%${
filter.filter
}%' `
`and LOWER(sites.max_survey) ${filter.operator === 'CONTAINS' ? 'like' : 'not like'} LOWER('%${ filter.filter }%') `
);
break;
case 'agencies':
where.append(
`and sites.agencies ${filter.operator === 'CONTAINS' ? 'like' : 'not like'} '%${
filter.filter
}%' `
`and LOWER(sites.agencies) ${filter.operator === 'CONTAINS' ? 'like' : 'not like'} LOWER('%${ filter.filter }%') `
);
break;
case 'has_biological_treatments':
where.append(
`and sites.has_biological_treatments ${filter.operator === 'CONTAINS' ? 'is not' : 'is'} null `
);
where.append(
` and LOWER(sites.has_biological_treatments) ${filter.operator === 'CONTAINS' ? 'is not' : 'is'} null `);
break;
case 'has_chemical_treatments':
where.append(
Expand Down Expand Up @@ -535,12 +527,12 @@ function whereStatement(sqlStatement: SQLStatement, filterObject: any) {
break;
case 'regional_district':
where.append(
`and sites.regional_district ${filter.operator === 'CONTAINS' ? 'like' : 'not like'} '%${filter.filter}%' `
`and LOWER(sites.regional_district) ${filter.operator === 'CONTAINS' ? 'like' : 'not like'} LOWER('%${filter.filter}%') `
);
break;
case 'regional_invasive_species_organization':
where.append(
`and sites.regional_invasive_species_organization ${filter.operator === 'CONTAINS' ? 'like' : 'not like'} '%${filter.filter}%' `
`and LOWER(sites.regional_invasive_species_organization) ${filter.operator === 'CONTAINS' ? 'like' : 'not like'} LOWER('%${filter.filter}%') `
);
break;
default:
Expand Down
5 changes: 4 additions & 1 deletion appv2/src/UI/Overlay/Records/RecordSet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export const RecordSet = (props) => {
history.push('/Records');
};

const tableType = userSettingsState?.recordSets?.[props.setID]?.recordSetType;

switch (userSettingsState?.recordSets?.[props.setID]) {
case undefined:
return <></>;
Expand Down Expand Up @@ -101,7 +103,8 @@ export const RecordSet = (props) => {
type: RECORDSET_ADD_FILTER,
payload: {
filterType: 'tableFilter',
field: 'short_id',
// short id if activity record set otherwise site_ID
field: tableType === 'Activity' ? 'short_id' : 'site_id' ,
setID: props.setID,
operator: 'CONTAINS',
blockFetchForNow: true
Expand Down

0 comments on commit 08980d8

Please sign in to comment.