Skip to content

Commit

Permalink
hotfix(PlanController): fix the filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
yossi-eynav committed Feb 13, 2024
1 parent 2f13371 commit c67691e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions server/api/controller/plan.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ class PlanController extends Controller {
q.orderByRaw = ['distance'];
delete q.order;

if (Config.locationSearch.filterPlansRadiusKm !== null) {
// use ST_Within to filter for plans with centroids within a polygon
// created with ST_Buffer. this makes use of the index on geom_centroid
q.whereRaw = [
Knex.raw(`ST_Within(geom_centroid, ST_Buffer(ST_GeomFromText("${polygon}", 4326), ${Config.locationSearch.filterPlansRadiusKm}*1000/${spatialUnitFactor}))`)
];
}
console.log("Config.locationSearch", Config.locationSearch)

// use ST_Within to filter for plans with centroids within a polygon
// created with ST_Buffer. this makes use of the index on geom_centroid
q.whereRaw = [
Knex.raw(`ST_Within(geom_centroid, ST_Buffer(ST_GeomFromText("${polygon}", 4326), ${Config.locationSearch.filterPlansRadiusKm || 10}*1000/${spatialUnitFactor}))`)
];

// filter out plans that should not be returned in geo search
q.where.geo_search_filter = [false];
Expand Down

0 comments on commit c67691e

Please sign in to comment.