From 79a31ae060810d41a833a379bf2f1b43e67c1872 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 6 Sep 2025 11:31:41 +0800 Subject: [PATCH] :alembic: Change the algorithm of ranking posts --- DysonNetwork.Sphere/Activity/ActivityService.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/DysonNetwork.Sphere/Activity/ActivityService.cs b/DysonNetwork.Sphere/Activity/ActivityService.cs index 0f188e9..a27b0c1 100644 --- a/DysonNetwork.Sphere/Activity/ActivityService.cs +++ b/DysonNetwork.Sphere/Activity/ActivityService.cs @@ -19,11 +19,13 @@ public class ActivityService( { private static double CalculateHotRank(Post.Post post, Instant now) { - var score = post.Upvotes - post.Downvotes + post.RepliesCount; + var performanceScore = post.Upvotes - post.Downvotes + post.RepliesCount; var postTime = post.PublishedAt ?? post.CreatedAt; - var hours = (now - postTime).TotalHours; + var timeScore = (now - postTime).TotalMinutes; // Add 1 to score to prevent negative results for posts with more downvotes than upvotes - return (score + 1) / Math.Pow(hours + 1.5, 2.0); + // Time dominates ranking, performance adjusts within similar timeframes. + var performanceWeight = Math.Log(performanceScore + 5); // smooth adjustment, median ~4-5 + return performanceWeight / Math.Pow(timeScore + 1.5, 1.5); } public async Task> GetActivitiesForAnyone(