Details Lerngruppe, Archiv, Stub Import

This commit is contained in:
2026-08-11 17:54:10 +02:00
parent 7a1f89cd4a
commit fd715dd5a5
11 changed files with 281 additions and 40 deletions
+15
View File
@@ -16,6 +16,7 @@ public class LiteDbContext : IDisposable
{
Connection = ConnectionType.Shared,
});
MigrateExistingData();
EnsureIndexes();
}
@@ -38,11 +39,25 @@ public class LiteDbContext : IDisposable
public void Checkpoint() => _db.Checkpoint();
private void MigrateExistingData()
{
var groups = _db.GetCollection<BsonDocument>("groups");
var missingArchiveState = groups.FindAll()
.Where(g => !g.ContainsKey(nameof(LearningGroup.IsActive)))
.ToList();
foreach (var group in missingArchiveState)
{
group[nameof(LearningGroup.IsActive)] = true;
groups.Update(group);
}
}
private void EnsureIndexes()
{
Students.EnsureIndex(x => x.LastName);
Students.EnsureIndex(x => x.IsActive);
Groups.EnsureIndex(x => x.SchoolYear);
Groups.EnsureIndex(x => x.IsActive);
Enrollments.EnsureIndex(x => x.StudentId);
Enrollments.EnsureIndex(x => x.GroupId);
Enrollments.EnsureIndex(x => x.SchoolYear);