File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,29 @@ public async Task<int> CreateRequest(TranslateAbleSubtitle translateAbleSubtitle
130130
131131 private async Task < int > EnqueueRequest ( TranslationRequest translationRequest )
132132 {
133+ if ( translationRequest . SubtitleToTranslate != null )
134+ {
135+ var existing = await _dbContext . TranslationRequests
136+ . Where ( activeRequest =>
137+ activeRequest . SubtitleToTranslate == translationRequest . SubtitleToTranslate &&
138+ activeRequest . TargetLanguage == translationRequest . TargetLanguage &&
139+ new [ ]
140+ {
141+ TranslationStatus . Pending ,
142+ TranslationStatus . InProgress
143+ } . Contains ( activeRequest . Status ) )
144+ . Select ( activeRequest => new { activeRequest . Id } )
145+ . FirstOrDefaultAsync ( ) ;
146+
147+ if ( existing != null )
148+ {
149+ _logger . LogInformation (
150+ "Duplicate translation request skipped for '{Subtitle}' -> '{Language}' (existing id {Id})." ,
151+ translationRequest . SubtitleToTranslate , translationRequest . TargetLanguage , existing . Id ) ;
152+ return existing . Id ;
153+ }
154+ }
155+
133156 // Create a new TranslationRequest to not keep ID and JobID
134157 var translationRequestCopy = new TranslationRequest
135158 {
You can’t perform that action at this time.
0 commit comments