Remove Duplicates from API data in a repeating group

Hi. I’m consuming an API in my bubble app from a source that has instances where data is duplicated. Using this data to display transactions without adding it to the Bubble DB. The data has two fields that can be used to find the duplication. The time stamp and separate unique identifier.

The API is called when the page is loaded and its contents are set as a state on an element on the page. This state is referred to when creating building RGs.

However, separately & strangely, when I set the state, I’m filtering the API data by date so I don’t have to repeat this particular filter. But that filter doesn’t seem to be working as I’m forced to filter by date each time I refer to the state.

For the duplicates, I’m limited in what I’m able to do since I have to get the unique elements and sum them up by a particular field. I’ve tried Unique Items on the state but it doesn’t work.

Help!

Hi, I am having the same issue. Did you end up figuring it out?

Yes. I realized the filtered field wasn’t actually in date format if I recall correctly. What particular issue see you facing? I’ve gone through a lot and might be able to save you some of the headaches I had to go through.

@enyarick
Hi, so basically I have an api call that returns a bunch of nested data (several flights) the flights are organized where there are slices (flight there and flight back) that are composed of segments (a flight from JFK to ATL).

So one slice would have two segments (going and returning). Often, the api will return slices that have several slices that have the same segments (<- problem)

For example: Slice 1 will have: segment 1 (going) and segment 2 (returning)
Slice 2 will have: segment 3 (going) and segment 2 (returning)

and there are ~50 slices per api call

So there will be several instnaces of the same flight being repeated in the repeating group when I only want the original

when slices have the same segments and I display this in a repeating group it will show the same segment/flight listed multiple times in the RG

I would like to find a way that allows me to filter out the repeat flights in the RG , but I cannot for the life of me figure out how.

This is my last (and biggest) issue before I can launch

I think there may be a way using list shifter but I am still trying to figure out processed list.

Hi @enyarick, sorry to bug you but did you have any ideas on how to solve this? I am still stuck on the issue.

Hey! I’m really sorry for going quiet. Battling bubble issues can get you lost in the weeds.

My understanding is you are looking for a way to daisychain the slices so the “returns” don’t show up?

Hi Now worries thank you for helping @enyarick !! I am basically trying to make it so I only get one segment 1 listed in the RG instead of several. I am not sure what daisychain is but I am open to trying it! I already have the returns filtered I just cant filter the duplicate segments.

@enyarick sorry to bug you but do you have any ideas?

Can you process it in a javascript element, then pass the results to your repeating group?

Hi. Sorry for taking time to respond.

What I wound up doing was ignoring fields from the API call that had small differences that were not significant. Then, for the call to have unique elements, I added :unique elements right after the call. That took care of the duplicates.

The idea I had for daisy chaining was just linking unique legs together per flight. Trouble with that is that is I’m not sure what the structure of your data is so that may not work. Try the :unique elements.

Hoping that helps!