I am doing a test project to learn about Bubble’s capabilities, and I can’t figure out something.
The test project is a Yelp clone. So basically, I have a parent “Restaurant” object with child “Review” objects. For relevance to this question, each Review object has 2 fields: a numeric Rating and a written Comment.
I want this Yelp clone to be map-focused, and I want the map markers for Restaurants to be color-coded based on the average rating across the child Reviews.
It seems that Bubble’s native Maps will not be able to populate different marker colors (please correct me if wrong), so I’m going to use the Mapbox plugin, which also has a workflow where a list of Restaurants can be populated with custom icons. After consulting with Mapbox, here’s how it will work:
- I will define an Option Set, named “AvgRating” that allows me to define a numeric set of ratings with distinct images (in my case, a colored marker)
- The Restaurant object will have a field that takes this AvgRating Option Set
Putting this together, the Mapbox workflow will list all Restaurants, and then pull the colored marker from the Restaurant’s AvgRating’s image.
That’s great, I can make that work.
HOWEVER >> now I need to know, how can I update the AvgRating field on the Restaurant object, as new child Reviews are added?
Is there a way to do this real time, so in a sense the AvgRating field becomes dynamic, or do I have to do some kind of daily background job/workflow?
ALSO, it’s important to mention that I’m totally open to completely new ways of resolving this, as this is just a learning test for me. As a developer, how I would have done this is a dynamic calculation where an icon is pulled based on a calculation of each parent Restaurant’s average rating across all child Reviews. But I’m not sure this is possible… hence the workaround to define a static AvgRating.