🐛 Bug fixes on web article

This commit is contained in:
LittleSheep 2025-07-01 22:35:46 +08:00
parent fb8fc69920
commit 71fcc26534
2 changed files with 3 additions and 6 deletions

View File

@ -43,17 +43,14 @@ public class ActivityService(
if (debugInclude.Contains("articles") || Random.Shared.NextDouble() < 0.2)
{
var recentArticlesQuery = db.WebArticles
.Include(a => a.Feed)
.Take(20); // Get a larger pool for randomization
// Apply random ordering 50% of the time
if (Random.Shared.NextDouble() < 0.5)
{
recentArticlesQuery = recentArticlesQuery.OrderBy(_ => EF.Functions.Random());
}
else
{
recentArticlesQuery = recentArticlesQuery.OrderByDescending(a => a.PublishedAt);
}
var recentArticles = await recentArticlesQuery.Take(5).ToListAsync();

View File

@ -8,8 +8,8 @@ public class WebArticle : ModelBase
{
public Guid Id { get; set; } = Guid.NewGuid();
[MaxLength(4096)] public string Title { get; set; }
[MaxLength(8192)] public string Url { get; set; }
[MaxLength(4096)] public string Title { get; set; } = null!;
[MaxLength(8192)] public string Url { get; set; } = null!;
[MaxLength(4096)] public string? Author { get; set; }
[Column(TypeName = "jsonb")] public Dictionary<string, object>? Meta { get; set; }