Forum Academy Marketplace Showcase Pricing Features

Performing a Looping Function on a list

Hi all,

We’re having some issues running a ranking system on a dynamic list of database entries.
Our setup is as follows:

Data Type: Sessions
The user performs a search query (an input form similar to Eventbrite where they choose a date and time from a date/time input) where we need to perform a calculation on the fly that gets all Sessions and ranks them on the fly using a point scoring system based on:

  • How far away the session is from the selected date (in terms of days)
  • How far away the session is from the selected time (in 30 minute intervals)

We’d then want to sort the returned sessions from low to high to show the closest matches to the user selected date/time in a repeatingGroup for the user to see.

Seems simple, but we haven’t yet found a simple way to do this that doesn’t touch the database excessively causing too much load time, or a way to carry the data through from one page (the input form) to the search_results page where we display the ranked sessions.

Very keen to hear your ideas

Thanks,
Reece

1 Like

Hey @help ,
Need some clarification so that i could help you.

  1. what are the sessions here??
    any subsciption sessions or login session or anything else which might have expiry date and time?
  2. what do the date/time picker represents?
    difference or range of date and time or anything else.
  3. what data you want in RG?
    the sessions which have date and time(expiry or any) after those date and time in the date/time picker or anything else.

just trying to be more clear. because i think i have the solution over this.

1 Like

Hey help, did you try Keith’s listshifter plugin? If not, maybe you can achieve what you want using the listshifter element + PROCESS step from that plugin.

1 Like

Thank you - we’ll take a look at that

Sarthak,

Hi, I am working with Reece and will try to answer your questions:

“what are the sessions here??” - let’s change the word to avoid confusion. Let’s say “Lessons”.

I would like to restate the problem:

  • There are scheduled lessons stored in our database.
  • The user is typing in some search terms; "Yoga, Wednesday, 7pm
  • We want to show the nearest scheduled lessons we have that match that search
  • We score “Near” by how close in time, how close in day, and whether it is the same sort of day or not (weekday or weekend). Distance = 1 for each 30 minutes, 2 for each day difference AND 3 distance points for NOT the same day type
  • So, the difference between “Yoga, Wednesday 7pm” <===> “Yoga, Thursday 6.30pm” is 1 point for the 30 minutes, 2 points for the 1 day difference, and no points for day type (both are weekdays)
  • To achieve this we need to loop through all the lessons in the database and score their distance from the search terms
  • Actually, we create temporary rows in our database for this purpose, with fields, SEARCH_ID, LESSON_ID, SCORE - and loop through these rows and score each lesson

Therefore, the question is:
How do we loop through the rows in the database to add the score for each lesson?

I know the guys have already tried Listshifter and an RG, but apparently it has not delivered the speed we were looking for. Right now, the problem appears to be the time it takes Bubble to update the database each time a cell in the RG is updated.

I think @help may be able to offer more info on this.

1 Like