Hello - So, I’m plugging away at my test project called “Blood Pressure Buddy”. Here’s how it works, a user signs up and is paired with another person trying to lower their BP. they both log their entries and are compared to each other.
Here’s the problem, I’m having. When I new user is created, I need to assign them to a group.
Here’s how I thought about doing it in plain language.
Create a Group ID field with the user.
When user signs up, identify the highest Group ID number that exists for all users.
If the highest Group ID number only returns 1 of that number (meaning that there’s not a complete pair) then give that number to the new user. For example, if there were 2 1s, 2 2s, but 1 3, the next user would get a 3.
If there are 2 of the highest number (i.e. 2 4s) then assign the new user with a group ID of the next highest number, in this case it would be a 5.
This way all the users are getting a unique group ID, but there’s never more than. 2 users with a specific group ID, so you’ll have unique pairs.
The logic for this seems simply, but I can’t find a way in bubble to assign a group ID in this way during the sign up process.
Is there any way to do this in bubble?
If not, any thoughts on how to structure this so I could do this?
Here’s the screen shot of trying to assign a group ID to a new user.
What about having a data type of group, with a list field of type user? Then when a user signs up you make a change to a group record, with the item to change being the first item with count of users < 2, with the checkbox set to create such a record if it doesn’t already exist. The change, of course, is to add the new user to the user list for the group.
Could you tell more a little more specifically about how to implement this in bubble? It’s easy for me to logic through these in plain language, but translating this into bubble language is still hard at the moment.
It seems you want just 1-1 matching ?
If so you have 2 groups, matched and non-matched users.
Create a field called matched_to type list of users on the user table.
In the signup workflow - if matched_to is empty for the current user then search the user table for the first user that matched_to is empty. Add that user to the matched_to list of the current user. Also add the current user to the found users matched_to list. This way you create a unique pair on signup and each will only have one matched user.
If there is no one to match you just have to wait as the next signup will find you as the first non matched pair and you will be matched. So you can leave a message saying waiting for a match on a popup after signup and on their home page.
My question is, how would I then show the BP data for two unique users, but only if those users are in the same group??
I want to display the data side by side for each user, but only given that they’re paired together.
In order to do this, it seems like I need to create a field for every user that identifies which specific group they are in. This way when I go to display the data, I can user the user data.
For #1 you’re almost there - just add unique_id after :first item and it should be all set. This will add the unique_id of the matching user to the matched_to of the current user. For your second condition I’d also put in unique_id is not current user’s unique_id as I’m not sure if user name is unique or not.
For #2 setup another workflow step after the one above (it has to be after so that the match_to from #1 gets saved in the database). Inside it change the user table. Write matched_to add list Search for Users:first item unique_id (same as above) but in the User conditions put in unique_id = current user’s match_to value also put matched_to is empty just to double check that the user has not be paired previously. This will add the current user’s unique id to the one that you previously matched them with.
So now both will have the unique_id of the user they matched to in match_to. To use it you can just run a search on match_to to display their partner’s stats and progress in a comparison of side by side of data.
You could create a page/group called BP Readings with a content type of Group and display the current user’s Group in it.
Then add two repeating groups (RGs) to the BP Readings page/group side by side. For the first one, the data source could be Do a Search for BP Readings with constraint: user = current user. For the second it should be Do a Search for BP Readings with constraints: a) user <> current user; b) user is in Parent page/group’s Group’s list of users.