Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/LfClassicData/LfClassicLexboxApiProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
73 changes: 3 additions & 70 deletions backend/LfClassicData/LfClassicMiniLcmApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,13 @@

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<Entities.Entry> Entries => dbContext.Entries(projectCode);
public IAsyncEnumerable<ComplexFormType> GetComplexFormTypes()
{
return AsyncEnumerable.Empty<ComplexFormType>();
}

public Task<ComplexFormType?> GetComplexFormType(Guid id)
{
return Task.FromResult<ComplexFormType?>(null);
}

public IAsyncEnumerable<MorphType> GetMorphTypes()
{
return AsyncEnumerable.Empty<MorphType>();
}

public Task<MorphType?> GetMorphType(Guid id)
{
return Task.FromResult<MorphType?>(null);
}

public Task<MorphType?> GetMorphType(MorphTypeKind kind)
{
return Task.FromResult<MorphType?>(null);
}

private Dictionary<Guid, PartOfSpeech>? _partsOfSpeechCacheByGuid = null;

Check warning on line 22 in backend/LfClassicData/LfClassicMiniLcmApi.cs

View workflow job for this annotation

GitHub Actions / Build API / publish-api

The field 'LfClassicMiniLcmApi._partsOfSpeechCacheByGuid' is assigned but its value is never used

Check warning on line 22 in backend/LfClassicData/LfClassicMiniLcmApi.cs

View workflow job for this annotation

GitHub Actions / Build API / publish-api

The field 'LfClassicMiniLcmApi._partsOfSpeechCacheByGuid' is assigned but its value is never used

Check warning on line 22 in backend/LfClassicData/LfClassicMiniLcmApi.cs

View workflow job for this annotation

GitHub Actions / GHA integration tests / dotnet

The field 'LfClassicMiniLcmApi._partsOfSpeechCacheByGuid' is assigned but its value is never used

Check warning on line 22 in backend/LfClassicData/LfClassicMiniLcmApi.cs

View workflow job for this annotation

GitHub Actions / GHA integration tests / dotnet

The field 'LfClassicMiniLcmApi._partsOfSpeechCacheByGuid' is assigned but its value is never used
private Dictionary<string, PartOfSpeech>? _partsOfSpeechCacheByStringKey = null;

public async Task<WritingSystems> GetWritingSystems()
Expand Down Expand Up @@ -80,17 +58,6 @@
};
}

public async Task<WritingSystem?> 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<string?> PickDefaultVernacularWritingSystem()
{
var cacheKey = $"LfClassic|DefaultVernacular|{projectCode}";
Expand All @@ -117,33 +84,14 @@
}
}

public IAsyncEnumerable<Publication> GetPublications()
{
return AsyncEnumerable.Empty<Publication>();
}

public async Task<PartOfSpeech?> GetPartOfSpeech(Guid id)
{
if (_partsOfSpeechCacheByGuid is null)
{
_partsOfSpeechCacheByGuid = await GetPartsOfSpeech().ToDictionaryAsync(pos => pos.Id);
}
return _partsOfSpeechCacheByGuid.GetValueOrDefault(id);
}

public Task<Publication?> GetPublication(Guid id)
{
return Task.FromResult<Publication?>(null);
}

public async ValueTask<PartOfSpeech?> GetPartOfSpeech(string key)
{
if (_partsOfSpeechCacheByStringKey is null)
{
_partsOfSpeechCacheByStringKey = await GetPartsOfSpeech().ToDictionaryAsync(pos => pos.Name["__key"]);
}
return _partsOfSpeechCacheByStringKey.GetValueOrDefault(key);
}
}

public async IAsyncEnumerable<SemanticDomain> GetSemanticDomains()
{
Expand All @@ -155,11 +103,6 @@
}
}

public async Task<SemanticDomain?> GetSemanticDomain(Guid id)
{
return await GetSemanticDomains().FirstOrDefaultAsync(semdom => semdom.Id == id);
}

public async Task<int> CountEntries(string? query = null, FilterQueryOptions? options = null)
{
// not efficient, but this will likely never get used
Expand Down Expand Up @@ -432,11 +375,6 @@
return await ToSense(entryId, sense);
}

public Task<Sense?> GetSense(Guid id)
{
throw new NotSupportedException("Getting a sense by ID without the entry ID is not supported in LfClassicMiniLcmApi");
}

public async Task<ExampleSentence?> GetExampleSentence(Guid entryId, Guid senseId, Guid id)
{
var entry = await Entries.Find(e => e.Guid == entryId).FirstOrDefaultAsync();
Expand All @@ -458,9 +396,4 @@
if (picture is null) return null;
return ToPicture(sense.Guid, picture);
}

public Task<int> GetEntryIndex(Guid entryId, string? query = null, IndexQueryOptions? options = null)
{
throw new NotImplementedException();
}
}
Loading