Mix awarded score into ranks

This commit is contained in:
2025-09-08 23:45:57 +08:00
parent c2b49e6642
commit ab2bdcc7ca
2 changed files with 12 additions and 5 deletions

View File

@@ -848,12 +848,19 @@ public partial class PostService(
g => g.Count()
);
// Load awardsScores for postsInPeriod
var awardsScores = await db.Posts
.Where(p => postsInPeriod.Contains(p.Id))
.ToDictionaryAsync(p => p.Id, p => p.AwardedScore);
var reactSocialPoints = postsInPeriod
.Select(postId => new
{
PostId = postId,
Count = (reactionScores.TryGetValue(postId, out var rScore) ? rScore : 0) +
(repliesCounts.TryGetValue(postId, out var repCount) ? repCount : 0)
Count =
(reactionScores.TryGetValue(postId, out var rScore) ? rScore : 0)
+ (repliesCounts.TryGetValue(postId, out var repCount) ? repCount : 0)
+ (awardsScores.TryGetValue(postId, out var awardScore) ? (int)(awardScore / 10) : 0)
})
.OrderByDescending(e => e.Count)
.Take(5)
@@ -877,7 +884,7 @@ public partial class PostService(
SocialCredits = e.Value
}).ToList();
if (records.Any())
if (records.Count != 0)
{
db.PostFeaturedRecords.AddRange(records);
await db.SaveChangesAsync();