Skip to content

Commit

Permalink
If 0-sense words end up in the database, don't send them to the frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
imnasnainaec committed Nov 13, 2023
1 parent c7aaa71 commit 474ca1c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Backend/Repositories/WordRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public WordRepository(IWordContext collectionSettings)
/// <summary> Finds all <see cref="Word"/>s with specified projectId </summary>
public async Task<List<Word>> GetAllWords(string projectId)
{
return await _wordDatabase.Words.Find(w => w.ProjectId == projectId).ToListAsync();
// A variant in FLEx can export as an entry without any senses.
// We don't want to show those in The Combine (or edit/delete/merge them).
return await _wordDatabase.Words.Find(w => w.ProjectId == projectId && w.Senses.Count > 0).ToListAsync();
}

/// <summary> Finds <see cref="Word"/> with specified wordId and projectId </summary>
Expand Down Expand Up @@ -127,7 +129,10 @@ public async Task<Word> Add(Word word)
/// <summary> Checks if Frontier is nonempty for specified <see cref="Project"/> </summary>
public async Task<bool> IsFrontierNonempty(string projectId)
{
var word = await _wordDatabase.Frontier.Find(w => w.ProjectId == projectId).FirstOrDefaultAsync();
// A variant in FLEx can export as an entry without any senses.
// We don't want to show those in The Combine (or edit/delete/merge them).
var word = await _wordDatabase.Frontier.Find(
w => w.ProjectId == projectId && w.Senses.Count > 0).FirstOrDefaultAsync();
return word is not null;
}

Expand All @@ -142,14 +147,19 @@ public async Task<bool> IsInFrontier(string projectId, string wordId)
/// <summary> Finds all <see cref="Word"/>s in the Frontier for specified <see cref="Project"/> </summary>
public async Task<List<Word>> GetFrontier(string projectId)
{
return await _wordDatabase.Frontier.Find(w => w.ProjectId == projectId).ToListAsync();
// A variant in FLEx can export as an entry without any senses.
// We don't want to show those in The Combine (or edit/delete/merge them).
return await _wordDatabase.Frontier.Find(
w => w.ProjectId == projectId && w.Senses.Count > 0).ToListAsync();
}

/// <summary> Finds all <see cref="Word"/>s in Frontier of specified project with specified vern </summary>
public async Task<List<Word>> GetFrontierWithVernacular(string projectId, string vernacular)
{
// A variant in FLEx can export as an entry without any senses.
// We don't want to show those in The Combine (or edit/delete/merge them).
return await _wordDatabase.Frontier.Find(
w => w.ProjectId == projectId && w.Vernacular == vernacular).ToListAsync();
w => w.ProjectId == projectId && w.Vernacular == vernacular && w.Senses.Count > 0).ToListAsync();
}

/// <summary> Adds a <see cref="Word"/> only to the Frontier </summary>
Expand Down

0 comments on commit 474ca1c

Please sign in to comment.