Hi folks,
I’m building my first bubble.io app and I’m coming towards the final steps in a user journey where a community of users are swapping items (in this case aquarium corals).
The journey involves users proposing items to swap from their inventory and then the recipient is asked to confirm the swap.
All that works, but I get stuck when trying to clean-up the database. When a swap is confirmed it will likely mean other swaps which contain overlapping inventory but are yet to be confirmed will no longer be viable.
I have included a diagram to try and explain the situation. I am struggling to work out how to combine the two inventories and use that to search for swaps with any item in either inventory. Even just searching 1 inventory against all the other swaps has escaped me.
Any tips would be most welcome, thank you.
I’m assuming you have a Swap data type that organizes the items and users involved. The most helpful field to include here would be a list of items. That way, when a swap is confirmed, you can more easily search for other swaps where their list intersects with the confirmed list.
For example:
Confirmed Swap’s list field contains Coral A and Coral J.
You’d run a “make a change to a list of things” action –
- Thing = Swap
- Source = Search for Swaps (status = pending) :filtered :advanced (This Swap’s list intersects with the confirmed Swap’s list :count > 0)
- Change: status = canceled
That advanced filter is how you’d find Swaps with intersecting lists. There has to be at least 1 intersecting coral. So another Swap has to involve only A or J or both to be returned in the search.
Another search approach you could test for efficiency:
- Search for Swaps (status = pending, list contains confirmed swap’s first item) merged with Search for Swaps (status = pending, list contains confirmed swap’s second item)
The first approach uses an advanced filter which you want to use sparingly, but the second approach means 2 searches. Try either out.
Cheers,
Gaby
Coaching No Code Apps
1 Like
Thank you for your help, just revealing the ‘advanced’ option helped me find that option I had read about but not seen (spoiler alert its at the bottom of the list).
While I haven’t managed to get the expected behaviour (it is just matching the confirmed swap) I do feel like I am armed with enough support to work it out.
I didn’t want to leave a reply any longer to say thanks. I will report back once I have it figured out.
1 Like