-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add datafile and corpus update consumers
Ensure that not all filenames change in testing
- Loading branch information
1 parent
01693e3
commit f153cb8
Showing
6 changed files
with
97 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/Serval/src/Serval.Translation/Consumers/CorpusUpdatedConsumer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
namespace Serval.Translation.Consumers; | ||
|
||
public class CorpusUpdatedConsumer(IEngineService engineService) : IConsumer<CorpusUpdated> | ||
{ | ||
private readonly IEngineService _engineService = engineService; | ||
|
||
public async Task Consume(ConsumeContext<CorpusUpdated> context) | ||
{ | ||
await _engineService.UpdateCorpusFilesAsync( | ||
context.Message.CorpusId, | ||
context.Message.Files.Select(Map).ToList(), | ||
context.CancellationToken | ||
); | ||
} | ||
|
||
private static CorpusFile Map(CorpusFileResult corpusFile) | ||
{ | ||
return new CorpusFile | ||
{ | ||
Id = corpusFile.File.DataFileId, | ||
TextId = corpusFile.TextId, | ||
Filename = corpusFile.File.Filename, | ||
Format = corpusFile.File.Format, | ||
}; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Serval/src/Serval.Translation/Consumers/DataFileUpdatedConsumer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace Serval.Translation.Consumers; | ||
|
||
public class DataFileUpdatedConsumer(IEngineService engineService) : IConsumer<DataFileUpdated> | ||
{ | ||
private readonly IEngineService _engineService = engineService; | ||
|
||
public async Task Consume(ConsumeContext<DataFileUpdated> context) | ||
{ | ||
await _engineService.UpdateDataFileFilenameFilesAsync( | ||
context.Message.DataFileId, | ||
context.Message.Filename, | ||
context.CancellationToken | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters