How can I make this more efficient?

Hi guys,
I have created an Open Hours datatype for Venues, 1 for each day of the week with additional details of the venue. There is no easy way to extract and compare time in Bubble so i have to convert the hours to minutes to make comparisons:
image

In repeating groups I show the data like this, and to get the open times the conditional syntax needs to be as follows:

To only view “Open” venues, I have to merge 2 filtered searches and 1 regular search:
image

with additional filters that look like this. The reason I need to filter again is because I have to extract the day from the date to determine if the Open hour is for the current day.
image
image

Now this all works but once I start getting more than 15 venues in the Listshifter list it becomes very slow to apply filters to all these Open Hours.

How I can improve the efficiency of this, is there a better way to find open hours of venues and compare them to the current time to see if they’re open?

Appreciate the help in advance.

Seems like you shouldn’t be storing any dates since these are just arbitrary hours/minutes…

Instead you could store a numeric range field so if you want something open 9AM-5PM, you would store 9 as the minimum, and 17 as the max.
Then when you search for currently open Venues you can do Do a search for Open Hours with the constraint [your new numeric field] containts (point) Current date/time:extract hour then do :each item's Venue after the search

Then some of your other constraints would be Day field = Current date/time:extract day, and another numeric range for minutes.

Then you can delete your date fields, Open today yes/no, and probably a few others

EDIT: might be an issue with the 24hour time extracting hours because if its 5PM it might extract 5 instead of 17 but we can work on that

2 Likes

Just tested it, it will extract the 24 hour time version so yes that should work as I described

1 Like

I think that’s heading in the right direction, but how would this work 9PM to 5AM?

Technically the Venue would be open day 0 (Sunday) hours 21 - 24, then another “Open Hours” thing for day 1 (Monday) with hours 0-5?

I’m under the impression you have like 7 of these “Open hours” Things for one venue if they are open 7 days a week right?

Yes that right, creating more than 7 might be problematic though?

I don’t think so, if you had one for Day 0 from 2-3, then another Day 0 from 4-10 that should be fine.
Even if you accidently did 2-6, and another one 5-10 your repeating group can’t show duplicate Venues so it would just show up once. Although I do suggest if a user sets the open Venue hours you have it check if there’s a conflict before making the Open Hours thing. Just in case some weird stuff happens, I’m not sure if you did the search but then :count if it would actually count it twice or not.

1 Like

Ok this seems like a good approach. What about venues that are open 24/7? Would you have this as a yes/no option or something else?

:thinking:

Probably a yes/no on the Venue itself. Then after the :each item's Venue I described earlier do merged with Do a search for Venues and do the constraint [your 24/7 field] = yes

I’m just trying to dodge the advanced filters because the performance is trash once you get too many Venues (as you’ve seen), this way it’s kind of just all search constraints which should be instant. The only thing to consider now is how you would want to sort all of this… after all the searches you could do :sorted and do alphabetical or something…

Or some apps just do Random sorting to mix things up :joy:

1 Like

Appreciate your input, this seems like a much better approach :slight_smile:

For now I could do the random sort, what’s the best way to do that?

When you do :sorted you can pick Random sorting

If you wanted to sort by “Closing soon” I have no idea and would need to think about that more :laughing: (Probably something with ListShifter or Floppy)

I actually recommend doing some kind of sorting because of the merged with operator it’s going to show all the open venues because of their times, then after all of those it would then show the 24/7 ones grouped together

1 Like

Random will work for now. Later I will apply different levels for free Vs premium

:+1:

Or if someone buys a ticket to the venue have it add 1 to a number field for the Venue, so you can get a rank of most popular ones and sort by that number.

Good luck!

1 Like

In the previous version i was able to show open hours quite easily, but now if i have multiple hour sets it won’t work, eg:
It’s usually 9 PM - 5AM, now its 9PM to 12 Am, 12Am to 5 AM, looks a bit silly lol

Yea I thought about that… I can think more about it tomorrow. Might be a way to store them like I said but display the ranges merged together somehow…

1 Like

I do like your solution so far, so thanks for that. Just need to figure out that part.

I’ve done some testing and the 24 hours can’t really work without the minutes, because if someone closes at 330AM, the 24 hour setup will show closed after 3 as its within the hour. A minute based numeric range doesn’t help as its hard to get the user to be within that specific minute range.

I’d like to still user the numeric range but its going to have to be minutes which means filters will be needed when searching to combine the current times hours+minutes to compare. There may be a reduced amount of filters though.

:thinking: tricky one… I got busy but I will try to think about this one…

I googled for a little bit about storing open/close hours and some people online have some good ideas…