From bbc4950839787eee2d7c3dae63367fd60221c720 Mon Sep 17 00:00:00 2001 From: pratishta Date: Tue, 30 Apr 2024 12:06:25 -0400 Subject: [PATCH] Force fake null block to compare for radius filter --- server/src/project/geometry/geometry.service.ts | 2 -- server/src/project/project.service.ts | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/server/src/project/geometry/geometry.service.ts b/server/src/project/geometry/geometry.service.ts index 31379bb0..a0b60216 100644 --- a/server/src/project/geometry/geometry.service.ts +++ b/server/src/project/geometry/geometry.service.ts @@ -360,8 +360,6 @@ export class GeometryService { async getBlocksFromRadiusQuery(x, y, radius) { const queryForBlocks = QUERIES.blocksWithinRadius(x, y, radius); const distinctBlocks = `SELECT DISTINCT(block) FROM (${queryForBlocks}) blocksWithinRadius`; - // console.log("distinctBlocks", distinctBlocks); - // console.log("distinctblocks records", await this.carto.fetchCarto(queryForBlocks, "json", "post")) const blocks = await this.carto.fetchCarto(distinctBlocks, "json", "post"); // note: DTM stores blocks with the borough diff --git a/server/src/project/project.service.ts b/server/src/project/project.service.ts index b2b93494..bcd848e5 100644 --- a/server/src/project/project.service.ts +++ b/server/src/project/project.service.ts @@ -250,8 +250,8 @@ export const generateFromTemplate = (query, template) => { }; function generateProjectsFilterString(query) { - // Special handling for 'block' query, which must be explicitly ignored if empty - // otherwise, unmapped projects will be excluded from the results + // if blocks_in_radius is empty while the radius_filter is on, force api + // to match a non-existant block to return no projects. Otherwise delete attribute const radius_filter = query.distance_from_point && query.radius_from_point; if (!Object.keys(query.blocks_in_radius).length) { radius_filter ? query.blocks_in_radius = ['000000'] : delete query.blocks_in_radius