Forum Documentation Showcase Pricing Learn more

Date Range Issue - Filtering Range in a Range


#1

Not%20Working

Can anyone see why this is not working? It is driving me insane. I have been working on this too long and can’t figure it out.

I am trying to filter out technicians that are not available during the specific date range of an event.

Each technician can have a list of dates that they are unavailable so i don’t want them showing up in the dropdown. For some reason they keep showing up anyways. What is wrong with my filter?

Thanks in advance.


#2

Hey @J805,

Not positive here, but I don’t think your first expression is evaluating to a valid date range. When I use a valid date range, I don’t see the “doesn’t contain” option. It also looks like that first expression is a List that needs to be narrowed down to one Event Range. Am I seeing this wrong?

Also, you might want to be looking at an overlap instead of contains for your use case. Using contains means the second range has to be completely contained within the first range, while overlaps allows for them to be partially overlapping.

That being said, I don’t think there is a “doesn’t overlap” or “doesn’t contain” option for date ranges, so to filter out those with no overlap, you might have to use “is before” OR “is after” to include only those folks without an overlap.



Looking to accelerate your app development?

Let me turn
:thinking: :tired_face: :confounded:

into
:grinning: :sunglasses: :woman_student:

Development through Coaching at https://uniqueideas.com or schedule a free intro session :gift:

Ken Truesdale
LinkedIn


#3

Yes, you are correct, there is a LIST of dates that it needs to check. I will check out the “is before” OR “is after” to see if that works. Thanks for the suggestion.


#4

I do this sort of thing quite often… the issue is, it is hard to describe what you need to do.

You have a list of Technicians, each of whom has a list of “booked dates” on them. You have a user-defined range of times that the user would like to have a Technician come and “handle their business” (as it were).

You need to iterate over the list of Technicians, but also iterate over each technician’s list of booked dates.

Your dropdown is a list of “available technicians”.

An individual Technician is AVAILABLE if:

  1. There are no individual date/times for which the Technician is UNavailable within the user-selected range. In Bubble terms, this is:

Technician's Dates Unavailable:filtered (Advanced: User's range contains point This Date) is empty

You are constructing your user’s date range on-the-fly, so this becomes:

Technician's Dates Unavailable: filtered (Advanced: Parent group's schedule/event/appointment's Event End<-- range -->Parent group's schedule/event/appointment's Event Start contains point This Date) is empty

(And, at this point, we are re-thinking our field labels! But that’s cool.)

  1. But we do not have just one Technician. We have a list of Technicians. The list of ALL Technicians in the universe is:

Do a Search for… Technicians

  1. So, what we must do is :filter the list of all Technicians in the universe by the criteria #1. In Bubble terms this is:

Do a Search for… Technicians:filtered

  1. What’s the :filtered condition? The filter described in #1. So this becomes:

Do a Search for... Technicians:filtered (Advanced: This Technician's Dates Unavailable:filtered (Advanced: User's range contains point This Date) is empty)

Building this will pop up multiple Advanced filter dialogs. The way to build it is to create:

Do a Search for... Technicians:filtered

… first. THEN, click on that :filtered. Create the Advanced condition there.

… then, in the dialog for that Advanced condition, build:

This Technician's Dates Unavailable:filtered

… then drilldown on THAT :filtered. Create the second Advanced condition there:

Parent group's schedule/event/appointment's Event End<-- range -->Parent group's schedule/event/appointment's Event Start contains point This Date is empty

It’s entirely possible I’ve noted something wrong here as I’m just doing this off the top of my head. However, I think you see now how to think about this and construct it. You were just thinking “one level down”… you need to “pop up” a level and start with the list of all Technicians (Do a Search for… Technicians) and filter that.


#5

Ok. I see. I guess that is probably where it looked like it was working but I was getting stuck. I try to avoid searches if at all possible but maybe in this case it is something I need to do. I guess one search function is not too bad.

Thanks for the detailed explanation. I’m just glad I understood it. Thanks. I will try it out tomorrow and let you know what happens. :slight_smile:


#6

The Search function is a necessary evil. Note however that you could constrain that search by orthogonal criteria. (Is the technician in this service area? for example).

But don’t be afraid to snag the list of all Technicians. Bubble is way more performant than you think it is. It downloads data like a mother… grabber.

Would you think twice about grabbing the list of all Technicians for your dropdown? Probably not. Any subsequent filtering you do only serves to slow things down.

You could also move all of this to the server by building an API endpoint in your app and then calling the endpoint from your app. (See my video about the Amazon product search API for a discussion of that strange-sounding idea and how you set it up.)

Caveat: Bubble’s server is probably not faster than the user’s Browser, unless you are paying for a bunch of extra capacity, or the Technician object is very large.

If you REALLY think that you’re going to have zillions of Technicians and their data object is very large, rethink the organization of your Technician object. Make it smaller. Or just make a TechnicianAvailabilty object that’s a proxy for the larger Technician object.

But all of this is putting carts before horses. Just make it work first. Optimize after that.


#7

Haha. Ya. I have learned a lot since my first app. How to do less searches is one thing I have learned. So I guess doing a search once in a while is ok. But ya, gotta get this working first. :slight_smile: