digisomni-syndicate / vircadia-metaverse

Metaverse server for Vircadia
https://vircadia.com/
Apache License 2.0
3 stars 7 forks source link

Places queries need rework. #20

Open namark opened 1 year ago

namark commented 1 year ago

The find requests for places and user places endpoints are not properly implemented: https://github.com/digisomni-syndicate/vircadia-metaverse/blob/aae404a8a7ce8247ea2d8c597650ba8614e4ea5b/vircadia_metaverse_v2_api/src/services/place/place.class.ts#L299 https://github.com/digisomni-syndicate/vircadia-metaverse/blob/aae404a8a7ce8247ea2d8c597650ba8614e4ea5b/vircadia_metaverse_v2_api/src/services/place/user-places/user-places.class.ts#L67 The filtering logic requires a cross referencing the domains collection, and this is done by first querying domains with maximum pagination limit (1000), then using that information in the places query filters.

The proper solution would be to use a $lookup aggregation, to join the two collections and then do filtering there. That will also take care of including the domain information in the place entries in the response, which is currently done in typescript.

In the long run we might need to avoid $lookup aggregation by restructuring the database to be more inline with recommended practices.

namark commented 1 year ago

$lookup aggregation is now implemented for places endpoint, but not user-places since the artificial limit is less of a problem there, and restructuring the whole database might still be necessary for performance.