Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MergeDups] Restore removal of redundant audio #2890

Merged
merged 2 commits into from
Jan 19, 2024
Merged
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
19 changes: 12 additions & 7 deletions Backend/Services/MergeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,27 @@ private async Task<Word> MergePrepParent(string projectId, MergeWords mergeWords
parent.ProjectId = projectId;
parent.History = new List<string>();

// Add child to history.
foreach (var childSource in mergeWords.Children)
{
// Add child to history.
parent.History.Add(childSource.SrcWordId);

if (childSource.GetAudio)
{
var child = await _wordRepo.GetWord(projectId, childSource.SrcWordId);
if (child is null)
// Add child's audio.
var child = await _wordRepo.GetWord(projectId, childSource.SrcWordId)
?? throw new KeyNotFoundException($"Unable to locate word: ${childSource.SrcWordId}");
child.Audio.ForEach(pro =>
{
throw new KeyNotFoundException($"Unable to locate word: ${childSource.SrcWordId}");
}
parent.Audio.AddRange(child.Audio);
if (parent.Audio.All(p => p.FileName != pro.FileName))
{
parent.Audio.Add(pro);
}
});
}
}

// Remove duplicates.
// Remove history duplicates.
parent.History = parent.History.Distinct().ToList();
return parent;
}
Expand Down