✨ Post featured record
This commit is contained in:
@@ -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,
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user