🐛 Trying to fix poll answer cache
This commit is contained in:
@@ -48,7 +48,7 @@ public class PollQuestion : ModelBase
|
||||
public class PollOption
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
[Required] [MaxLength(1024)] public string Label { get; set; } = null!;
|
||||
[Required][MaxLength(1024)] public string Label { get; set; } = null!;
|
||||
[MaxLength(4096)] public string? Description { get; set; }
|
||||
public int Order { get; set; } = 0;
|
||||
}
|
||||
@@ -60,5 +60,5 @@ public class PollAnswer : ModelBase
|
||||
|
||||
public Guid AccountId { get; set; }
|
||||
public Guid PollId { get; set; }
|
||||
[JsonIgnore] public Poll Poll { get; set; } = null!;
|
||||
[JsonIgnore] public Poll? Poll { get; set; }
|
||||
}
|
@@ -51,7 +51,10 @@ public class PollService(AppDatabase db, ICacheService cache)
|
||||
|
||||
var answer = await db.PollAnswers
|
||||
.Where(e => e.PollId == pollId && e.AccountId == accountId)
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync();
|
||||
if (answer is not null)
|
||||
answer.Poll = null;
|
||||
|
||||
// Set the answer even it is null, which stands for unanswered
|
||||
await cache.SetAsync(cacheKey, answer, TimeSpan.FromMinutes(30));
|
||||
|
Reference in New Issue
Block a user