From 117d2f8194ccb6a8a5296743b08b0a7bc5974c79 Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Mon, 6 Jul 2026 13:58:37 +0700 Subject: [PATCH] Refactor LfClassicMiniLcmApi, it no longer implements IMiniLcmApi --- .../LfClassicLexboxApiProvider.cs | 2 +- backend/LfClassicData/LfClassicMiniLcmApi.cs | 73 +------------------ 2 files changed, 4 insertions(+), 71 deletions(-) diff --git a/backend/LfClassicData/LfClassicLexboxApiProvider.cs b/backend/LfClassicData/LfClassicLexboxApiProvider.cs index d0550672bf..8672056ac3 100644 --- a/backend/LfClassicData/LfClassicLexboxApiProvider.cs +++ b/backend/LfClassicData/LfClassicLexboxApiProvider.cs @@ -5,7 +5,7 @@ namespace LfClassicData; public class LfClassicLexboxApiProvider(ProjectDbContext dbContext, SystemDbContext systemDbContext, IMemoryCache memoryCache) { - public IMiniLcmReadApi GetProjectApi(string projectCode) + public LfClassicMiniLcmApi GetProjectApi(string projectCode) { return new LfClassicMiniLcmApi(projectCode, dbContext, systemDbContext, memoryCache); } diff --git a/backend/LfClassicData/LfClassicMiniLcmApi.cs b/backend/LfClassicData/LfClassicMiniLcmApi.cs index a9352a0e0d..62c5782d48 100644 --- a/backend/LfClassicData/LfClassicMiniLcmApi.cs +++ b/backend/LfClassicData/LfClassicMiniLcmApi.cs @@ -13,33 +13,11 @@ namespace LfClassicData; -public class LfClassicMiniLcmApi(string projectCode, ProjectDbContext dbContext, SystemDbContext systemDbContext, IMemoryCache memoryCache) : IMiniLcmReadApi +//doesn't actually implement IMiniLcmApi, because there's not much more we're doing with this, and we don't want to have to keep adding methods that do nothing. +public class LfClassicMiniLcmApi(string projectCode, ProjectDbContext dbContext, SystemDbContext systemDbContext, IMemoryCache memoryCache) { private IMongoCollection Entries => dbContext.Entries(projectCode); - public IAsyncEnumerable GetComplexFormTypes() - { - return AsyncEnumerable.Empty(); - } - - public Task GetComplexFormType(Guid id) - { - return Task.FromResult(null); - } - - public IAsyncEnumerable GetMorphTypes() - { - return AsyncEnumerable.Empty(); - } - - public Task GetMorphType(Guid id) - { - return Task.FromResult(null); - } - public Task GetMorphType(MorphTypeKind kind) - { - return Task.FromResult(null); - } private Dictionary? _partsOfSpeechCacheByGuid = null; private Dictionary? _partsOfSpeechCacheByStringKey = null; @@ -80,17 +58,6 @@ public async Task GetWritingSystems() }; } - public async Task GetWritingSystem(WritingSystemId id, WritingSystemType type) - { - var ws = await GetWritingSystems(); - return type switch - { - WritingSystemType.Vernacular => ws.Vernacular.FirstOrDefault(w => w.WsId == id), - WritingSystemType.Analysis => ws.Analysis.FirstOrDefault(w => w.WsId == id), - _ => throw new ArgumentOutOfRangeException(nameof(type), type, null) - }; - } - public async Task PickDefaultVernacularWritingSystem() { var cacheKey = $"LfClassic|DefaultVernacular|{projectCode}"; @@ -117,25 +84,6 @@ public async IAsyncEnumerable GetPartsOfSpeech() } } - public IAsyncEnumerable GetPublications() - { - return AsyncEnumerable.Empty(); - } - - public async Task GetPartOfSpeech(Guid id) - { - if (_partsOfSpeechCacheByGuid is null) - { - _partsOfSpeechCacheByGuid = await GetPartsOfSpeech().ToDictionaryAsync(pos => pos.Id); - } - return _partsOfSpeechCacheByGuid.GetValueOrDefault(id); - } - - public Task GetPublication(Guid id) - { - return Task.FromResult(null); - } - public async ValueTask GetPartOfSpeech(string key) { if (_partsOfSpeechCacheByStringKey is null) @@ -143,7 +91,7 @@ public IAsyncEnumerable GetPublications() _partsOfSpeechCacheByStringKey = await GetPartsOfSpeech().ToDictionaryAsync(pos => pos.Name["__key"]); } return _partsOfSpeechCacheByStringKey.GetValueOrDefault(key); - } + } public async IAsyncEnumerable GetSemanticDomains() { @@ -155,11 +103,6 @@ public async IAsyncEnumerable GetSemanticDomains() } } - public async Task GetSemanticDomain(Guid id) - { - return await GetSemanticDomains().FirstOrDefaultAsync(semdom => semdom.Id == id); - } - public async Task CountEntries(string? query = null, FilterQueryOptions? options = null) { // not efficient, but this will likely never get used @@ -432,11 +375,6 @@ private static SemanticDomain ToSemanticDomain(Entities.OptionListItem item) return await ToSense(entryId, sense); } - public Task GetSense(Guid id) - { - throw new NotSupportedException("Getting a sense by ID without the entry ID is not supported in LfClassicMiniLcmApi"); - } - public async Task GetExampleSentence(Guid entryId, Guid senseId, Guid id) { var entry = await Entries.Find(e => e.Guid == entryId).FirstOrDefaultAsync(); @@ -458,9 +396,4 @@ private static SemanticDomain ToSemanticDomain(Entities.OptionListItem item) if (picture is null) return null; return ToPicture(sense.Guid, picture); } - - public Task GetEntryIndex(Guid entryId, string? query = null, IndexQueryOptions? options = null) - { - throw new NotImplementedException(); - } }