🐛 Fix poll cache

This commit is contained in:
2025-08-05 22:39:39 +08:00
parent 256c6469a6
commit 22101c8280
2 changed files with 6 additions and 5 deletions

View File

@@ -17,7 +17,7 @@ public class Poll : ModelBase
public Instant? EndedAt { get; set; } public Instant? EndedAt { get; set; }
public Guid PublisherId { get; set; } public Guid PublisherId { get; set; }
public Publisher.Publisher Publisher { get; set; } = null!; [JsonIgnore] public Publisher.Publisher? Publisher { get; set; }
} }
public enum PollQuestionType public enum PollQuestionType

View File

@@ -43,12 +43,13 @@ public class PollService(AppDatabase db, ICacheService cache)
var poll = await db.Polls var poll = await db.Polls
.Where(e => e.Id == id) .Where(e => e.Id == id)
.Include(e => e.Questions) .Include(e => e.Questions)
.AsNoTracking()
.FirstOrDefaultAsync(); .FirstOrDefaultAsync();
if (poll is not null) if (poll is null) return null;
{
await cache.SetAsync(cacheKey, poll, TimeSpan.FromMinutes(30)); poll.Publisher = null;
} await cache.SetAsync(cacheKey, poll, TimeSpan.FromMinutes(30));
return poll; return poll;
} }