Algorithm of most relevant wall posts

221 views Asked by At

I am about to develop a wall which fetches a lot of wall posts from different users. I have a global table called "edu_posts" containing wall posts, and comments to these.

I wish to create some kind of system to focus on bringing the most relevant content up for the user.

I wish feedback / alternatives methods / etc for my current solution I thought of, which is as following:

Simple rating system:

  1. Create a list of relevant user_ids: The database exists of different tables like: followers, posts, messages, likes (from posts and comments). Then the system search for every rows where the author_id is the current users ID. We then retrieve the receiver_id, and put them into an array. The retriever_id is probably the person who the current user tries to communicate with and/or thinks is interesting - at least he either followed, commented/liked his post, etc. The build of the array is: key => the user id, value => the number of times the reciever_id has appeared. Then you will end up with a list, like the following: $userlist = array(12 => 9, 55 => 8, 7 => 5, 56 => 3) // etc etc (so basically: ID 12 has appeared 9 times, ID 55 8 times, and so on) Now we have achieved the list of relevant user_ids.
  2. Add ratings to the posts_array: I retrieve all wall posts and comments from the database, and they are outputted in an array like this: See screenshotThen I will compare my $userlist array with each field: author_id (for the post), author_id (for the comments), author_id (for the likes). Lets say, that in post 30 (above printed example) the user id: 12 exists 3 times (2 times in comments, and 1 time in likes) then the rating is 3 * 9 (nine, because the user_id 12 has appeared 9 times in our $userslist), and then we add this number (3 * 9): 27 to the ratings field, in the $posts_array.
  3. Sorting the posts_array: Then all we basically do, is to sort the $posts_array compared to the ratings field.

Did it make sense? Do you understand my trouble? I hope I am clear enough. I understand that this is a very hard question to answer, and that there really isn't any real answer. I just need to evaluate the different methods which exists, as above example will be a pretty heavy SQL (to fetch all different relevant tables, and containing data) and PHP operation.

Many thanks in advance!

0

There are 0 answers