Skip to content

Commit

Permalink
Merge branch 'main' into delete-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jfeuerstein authored Oct 18, 2023
2 parents a0dd79b + 6c37021 commit e5df728
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
23 changes: 22 additions & 1 deletion backend/src/customers/controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,26 @@ const getAllDocsByClusterIDs = async (
return datas;
};


/**
* Finds all clusters within specified coordinates
* @param lower_left coordinates of lower left binding of location range
* @param upper_right coordinates of upper right binding of location range
* @returns list of cluster IDs that fall within location range
*/
const getClustersByLocation = async (
lower_left: number[],
upper_right: number[]
) =>
ClusterModel.find({
$and: [
{ "location.0": { $gte: lower_left[0] } },
{ "location.0": { $lte: upper_right[0] } },
{ "location.1": { $gte: lower_left[1] } },
{ "location.1": { $lte: upper_right[1] } }
]
})

export default {
getClusters,
insertCluster,
Expand All @@ -160,5 +180,6 @@ export default {
getDataByNetId,
insertData,
deleteData,
getAllDocsByClusterIDs,
getClustersByLocation,
getAllDocsByClusterIDs
};
16 changes: 15 additions & 1 deletion backend/src/customers/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,18 @@ docRouter.get("/clusterData/", async (req, res) => {
.send(successJson(await DocController.getAllDocsByClusterIDs(clusterIds, minDate, maxDate)));
});

export default docRouter;
/**
* Gets all cluster IDs in location range [lower_left, upper_right]
*/
docRouter.post("/get-clusters-in-range/", async (req, res) => {
const { lower_left, upper_right } = req.body;
res
.status(200)
.send(
successJson(
await DocController.getClustersByLocation(lower_left, upper_right)
)
);
});

export default docRouter;

0 comments on commit e5df728

Please sign in to comment.