How do I best create a feed system

Hi everyone,
I need, for some sort of social network I’m working on, to have a “feed” page where users can see whatever happened during the last day/week.
The feed contains items of related to new inscriptions, “offers” and group joining,
and the user can see them either because a friend is concerned, or someone in a group they are in already or even because they just leave nearby.
I am really stuck with this, if anyone has experience creating a feed like this, please :sob:

Here’s what I’ve came up with:

Option 1 :
On every event I want to track’s workflow, I create a “feed-item” thing and calculate which users are concerned (the sum of the Current User’s friends list, the Current User’s Groupes’s Members list and the “Do a search for users that don’t leave too far”)
Then, every user when they load their feed page just has a “Do a search for feed-item” : “users-concerned contains Current User”
But there might be up to 100 even 200 users seeing each individual notifications, and each user might have to load 50-100 notifications when they open their app. should I be afraid it takes years to load ?

Option 2 :
Every “feed-item” that could be called an “event” is stored in the related user, or at least has a reference to it, and when another user log in, I search for all users he should see the events of (friends, groups and distance) and retreive all their last events through 3 differents “do a search for” and then sort them by date ?

And none of this option handles the fact that I need to show the source of the notifications (Wheter it is “A friend of you did this” or “One of your neighbor (650m) did that”

Anyway… I have been pretty stuck on this for a while, thanks a lot for reading through,
keep safe and have a good day!

Hey @stern.solal, interesting use case

I would personally go with Option 2, seems like it would take less time to load

I’m thinking each User could have a list of Connections (refers to other users, either Friend or within the same Group). I would structure it like this:

  • a data type “Connections”, with two fields: User (of type User) and Type (an Option Set, to define if that Connection is a Friend or part of the same Group)
  • in User, a field “Connections”, which is a list of Connections
  • in User, a field “Feed Items”, which is a list of Feed Items for that User

In your RG to show all Feed Items, you could do a Search for Feed Items, with the following constraints:

  • Feed Item’s Creator is in Current User’s Connections
  • Feed Item’s Creator’s location is within X kms/miles of Current User’s location

Don’t forget to tick the checkbox ‘Ignore empty constraints’

You could have a text to show this Feed Item’s Creator’s Type

Hope that helps

1 Like

What about creating a dedicated table “feed-items” which should have at least 3 fields:

User who created the item
List of users who should see the feed item

For both your options it seems like it will take a long time to load everything if you have enough interactions.

With this solution you could load all the feed items for a specific user with a single search operation.

1 Like

Thanks a lot !!
It makes perfect sense now that I read it; I will probably do exactly every step as you said and I’m a bit sad I hadn’t figured it out myself (but this forum is so full of good people, I am amazed :+1: )
Thanks again for this big reply, have a good day.

1 Like

It looks good too, thank you for replying !
I’m still wondering (as for the first answer now that I think of it) if having for a constraint a sentence like “List contains XXX” with a very huge list doesn’t make the query very slow… Guess I’ll found out if my project encounter sucess.
Anyway, have a good day !

Welcome, glad I could help!

Hey man, it would be awesome if you did a video on this. lol I’m going through the same thing right now.