Add post-answer review and per-question loading
This commit is contained in:
@@ -9,6 +9,7 @@ public class QuestionSearchRequest
|
||||
public int? DifficultyMax { get; set; }
|
||||
public int Limit { get; set; } = 40;
|
||||
public bool SupportsChoicePools { get; set; }
|
||||
public List<string> ExcludeExternalIds { get; set; } = [];
|
||||
}
|
||||
|
||||
public class UpsertQuestionRequest
|
||||
|
||||
@@ -37,11 +37,20 @@ public class QuestionStore
|
||||
filters.Add(builder.Gte(q => q.Difficulty, req.DifficultyMin.Value));
|
||||
if (req.DifficultyMax is not null)
|
||||
filters.Add(builder.Lte(q => q.Difficulty, req.DifficultyMax.Value));
|
||||
var excludedIds = req.ExcludeExternalIds
|
||||
.Where(id => !string.IsNullOrWhiteSpace(id))
|
||||
.Select(id => id.Trim())
|
||||
.Distinct(StringComparer.Ordinal)
|
||||
.ToList();
|
||||
if (excludedIds.Count > 0)
|
||||
filters.Add(builder.Nin(q => q.ExternalId, excludedIds));
|
||||
|
||||
var filter = filters.Count == 0 ? builder.Empty : builder.And(filters);
|
||||
var limit = Math.Clamp(req.Limit, 1, 80);
|
||||
var questions = await _col.Find(filter).Limit(limit).ToListAsync();
|
||||
return questions.OrderBy(_ => Guid.NewGuid()).ToList();
|
||||
return await _col.Aggregate()
|
||||
.Match(filter)
|
||||
.Sample(limit)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<Question?> GetByIdAsync(string id) =>
|
||||
|
||||
Reference in New Issue
Block a user