Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the trending algorithm tunable and add number of comments to inputs #472

Merged
merged 2 commits into from
Aug 2, 2024

Conversation

steven-fox
Copy link
Collaborator

@steven-fox steven-fox commented Aug 2, 2024

The purpose of this PR is two-fold:

  1. Make it so that our trending algorithm is dependent on likes_count * comments_count;
  2. Make it so that you can "tune" the algorithm iteratively without additional commits. With this implementation in place, you can establish a few .env vars and then tuning the algo is as simple as modifying the env file and re-caching the config. This is just a quick, simple way to accomplish this and a method I've used in the past. One could also do this via a cache/database lookup, but I wanted to throw this together in literal minutes.

Algo FYI:

  • The likes_bias and comments_bias allows you to alter the relative weighting of those two inputs.
  • The time_bias is important for the "tuning." It basically specifies how time-sensitive you want the algo to be. A smaller number will favor recent posts. I made the default equal to one day's worth of seconds. Just kind of seemed like a good starting place based on my locally seeded data and some Excel calculations. Ideally, we would make this number roughly equal to the number of seconds it takes for the avg post to reach it's maximum trending-input (likes * comments) amount.
    image
    vs (1 hour)
    image
    or (3 days)
    image

@nunomaduro nunomaduro merged commit 3d12d36 into main Aug 2, 2024
@nunomaduro nunomaduro deleted the feat/tunable-trending-algo branch August 2, 2024 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants