Scale unique answer tracking

This commit is contained in:
hz
2026-07-13 02:11:54 -05:00
parent 700da4e415
commit f2c59388eb
23 changed files with 1064 additions and 131 deletions
+2 -6
View File
@@ -8,13 +8,9 @@ public class QuestionStore
{
private readonly IMongoCollection<Question> _col;
public QuestionStore(IConfiguration cfg)
public QuestionStore(MongoDatabaseProvider mongo)
{
var cs = cfg["MongoDB:ConnectionString"] ?? "mongodb://127.0.0.1:27017";
var dbName = cfg["MongoDB:DatabaseName"] ?? "GameDb";
var client = new MongoClient(cs);
var db = client.GetDatabase(dbName);
_col = db.GetCollection<Question>("Questions");
_col = mongo.Database.GetCollection<Question>("Questions");
var externalIdIndex = Builders<Question>.IndexKeys.Ascending(q => q.ExternalId);
_col.Indexes.CreateOne(new CreateIndexModel<Question>(externalIdIndex, new CreateIndexOptions { Unique = true }));