Post featured record

This commit is contained in:
2025-08-12 12:17:26 +08:00
parent 05c6d67c03
commit 616491e6d8
6 changed files with 2055 additions and 2 deletions

View File

@@ -114,6 +114,16 @@ public class PostCollection : ModelBase
public ICollection<Post> Posts { get; set; } = new List<Post>();
}
public class PostFeaturedRecord : ModelBase
{
public Guid Id { get; set; }
public Guid PostId { get; set; }
public Post Post { get; set; } = null!;
public Instant? FeaturedAt { get; set; }
public int SocialCredits { get; set; }
}
public enum PostReactionAttitude
{
Positive,

View File

@@ -763,6 +763,15 @@ public partial class PostService(
featuredIds = reactSocialPoints.Select(e => e.Key).ToList();
await cache.SetAsync(FeaturedPostCacheKey, featuredIds, TimeSpan.FromHours(24));
// Create featured record
var records = reactSocialPoints.Select(e => new PostFeaturedRecord
{
PostId = e.Key,
SocialCredits = e.Value
}).ToList();
db.PostFeaturedRecords.AddRange(records);
await db.SaveChangesAsync();
}
var posts = await db.Posts