Forum Academy Marketplace Showcase Pricing Features

HELP with distance comparison

hi guys,

I’m struggling with Bubble’s geographic places/addresses here and I’m not sure if my logic is wrong or if it’s a limitation.

Just to give you some short background, my app connects very specific mechanics and product_owners in some cities in Brazil.

Every mechanic has a “max distance” in kilometers and can create plenty “dates_available”. Every availability has a date, price, city_before and city_after.

When a product_owner signs up, he fills the cities he has the product installed.

The challenge

In one of the product_owner’s screen, I need to show to him only the availabilities from the mechanics that are able to visit him. (able to visit means that the distance between product_owner city and mechanic>date_available>any city is < than mechanic’s max_distance.)

To find that, I need to take both city_before and city_after from dates_availability and apply the max_distance from the mechanic who created the availability using these two cities as the center of each radius.

After that I have to compare if at least one of the product_owner’s cities is with in of each radius and show only the availabilities that are true.

I’m trying to search for dates_available in a RG but it doesn’t allow me to grab the max_distance from the mechanic who created that availability so I can proceed to the next step. (as in the picture)

Is my logic wrong? Is there a more efficient way to accomplish this?

Many thanks…