Hello, I need an algorithm for ranking posts in Social Media Website

Castamir

BANNED
Joined
Sep 4, 2019
Messages
1,200
Reaction score
1,058
Hello, I need an algorithm for ranking posts in Social Media Website.

The website uses Wowonder https://demo.wowonder.com script but its ranking is time-based instead of activity based as seen on Blackhatworld.com

Developers in the group please help.
 
Okay but first, can you explain how you want the ranking to be in words? How do you mean activity based?
Do you mean posts with more engagement should rank higer?
Do you mean users more active should rank higher?
Do you want posts to be ranked based on the current user's past activity? (Machine Learning Algorithm)

There could be more... it depends on how exactly u want it to work. So please can you explain better so we can assist better
 
Okay but first, can you explain how you want the ranking to be in words? How do you mean activity based?
Do you mean posts with more engagement should rank higer?
Do you mean users more active should rank higher?
Do you want posts to be ranked based on the current user's past activity? (Machine Learning Algorithm)

There could be more... it depends on how exactly u want it to work. So please can you explain better so we can assist better
Thank you for replying. I appreciate this a lot.

I want any post that got any recent engagement (not number, but how recent) to rise to the top.

>>> Example of Recent Activity Based Ranking Algorithm.

Post A gets published at 11:15am

Post B gets published at 11:16am

Post C gets published at 11:17am

In the absence of any engagement (likes and comments) occurring between 11:18am till 11:20am, the page when refreshed looks like this.

#1 Rank - Post C (since it got published recently)

#2 Rank - Post B

#3 Rank - Post A

NOTE: List of actions counted as an activity "Publishing, comments, likes, shares". So, how recent an activity is, is the most important ranking factor for the post that recieved the activity.

>>> Further Implementation of the Algorithm Illustrating the Note Above

Post B gets a like at 11:22am

Post C gets a share at 11:20am

Post D gets published at 11:21am

Post A gets a comment at 11:19am


The ranking will look as follows based on recent activity (See note above)

#1 - Post B
#2 - Post D
#3 - Post C
#4 - Post A
 
Okay I love the explanation.
In that case the algorithm is quite simple.

Assuming you are using a MySql Database
  • Simply add a new column to the posts table. You can call the new column "last_activity" with DATETIME data type.
  • Now anytime a post gets published or gets a new comment, like and share, you update that last_activity column with the current DATE and TIME. If you are using an Event Based Architecture, this part can easily be done as a plugin.
  • When the News Feed is loaded, simply sort the posts by "last_activity"
That should work the way you want it.
 
Okay I love the explanation.
In that case the algorithm is quite simple.

Assuming you are using a MySql Database
  • Simply add a new column to the posts table. You can call the new column "last_activity" with DATETIME data type.
  • Now anytime a post gets published or gets a new comment, like and share, you update that last_activity column with the current DATE and TIME. If you are using an Event Based Architecture, this part can easily be done as a plugin.
  • When the News Feed is loaded, simply sort the posts by "last_activity"
That should work the way you want it.
Wow, this is brilliant. Thanks for the help.
 
Wow, this is brilliant. Thanks for the help.
Glad I could help...

What do you mean event based architecture.
It's just an Software architecture pattern based on Events. Event-driven architecture (EDA).
Basically, you define events in your system. Example of such Events can Include New Post Event, New Comment Event, New Like etc. These events would be emitted anytime they occur. Then you have Event Subscribers that would subscribe to these Events. A Subscriber can be a function that is called anytime a certain event happens.

The reason you would want to use EDA is because it Encourages Loose Coupling. So for example, if you removed the function that updates the last_activity column, with an EDA, the overall system will still work fine. Because that function is only a subscriber and it is not being called directly from the core code.

In EDA, if the subscriber exists, the subscriber is called, but if it doesn't exist, nothing happens
 
Glad I could help...


It's just an Software architecture pattern based on Events. Event-driven architecture (EDA).
Basically, you define events in your system. Example of such Events can Include New Post Event, New Comment Event, New Like etc. These events would be emitted anytime they occur. Then you have Event Subscribers that would subscribe to these Events. A Subscriber can be a function that is called anytime a certain event happens.

The reason you would want to use EDA is because it Encourages Loose Coupling. So for example, if you removed the function that updates the last_activity column, with an EDA, the overall system will still work fine. Because that function is only a subscriber and it is not being called directly from the core code.

In EDA, if the subscriber exists, the subscriber is called, but if it doesn't exist, nothing happens
Thank you so much.
 
Back
Top