Skip to content

Commit

Permalink
Code review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
maallen committed Sep 30, 2024
1 parent 6562763 commit 5fc7c78
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
public interface RepositoryLocaleAIPromptRepository
extends JpaRepository<RepositoryLocaleAIPrompt, Long> {

@Query(
"SELECT rlap.repository.id FROM RepositoryLocaleAIPrompt rlap WHERE rlap.aiPrompt.id = :aiPromptId")
List<Long> findRepositoryIdsByAiPromptId(@Param("aiPromptId") Long aiPromptId);

@Query(
"SELECT count(rlap.id) FROM RepositoryLocaleAIPrompt rlap "
+ "JOIN AIPrompt aip ON rlap.aiPrompt.id = aip.id "
Expand All @@ -24,7 +20,7 @@ public interface RepositoryLocaleAIPromptRepository
"SELECT rlap FROM RepositoryLocaleAIPrompt rlap "
+ "JOIN rlap.aiPrompt aip "
+ "JOIN aip.promptType aipt "
+ "WHERE rlap.repository.id = :repositoryId AND aip.deleted = false AND aipt.name = 'TRANSLATION'")
+ "WHERE rlap.repository.id = :repositoryId AND rlap.disabled = false AND aip.deleted = false AND aipt.name = 'TRANSLATION'")
List<RepositoryLocaleAIPrompt> getActiveTranslationPromptsByRepository(
@Param("repositoryId") Long repositoryId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.box.l10n.mojito.quartz.QuartzJobInfo;
import com.box.l10n.mojito.quartz.QuartzPollableTaskScheduler;
import com.box.l10n.mojito.service.ai.RepositoryLocaleAIPromptRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand All @@ -16,6 +18,8 @@
@ConditionalOnProperty(value = "l10n.ai.translation.enabled", havingValue = "true")
public class AITranslationJobScheduler {

private static Logger logger = LoggerFactory.getLogger(AITranslationJobScheduler.class);

@Autowired RepositoryLocaleAIPromptRepository repositoryLocaleAIPromptRepository;

@Autowired TmTextUnitPendingMTRepository tmTextUnitPendingMTRepository;
Expand All @@ -29,6 +33,7 @@ public void scheduleAITranslationJob(AITranslateJobInput input) {
if (repositoryLocaleAIPromptRepository.findCountOfActiveRepositoryTranslationPrompts(
input.getRepositoryId())
> 0) {
logger.debug("Scheduling AI translation for tmTextUnitId: {}", input.getTmTextUnitId());
persistToPendingMTTable(input);
scheduleQuartzJob(input);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public boolean isTranslatable(TMTextUnit tmTextUnit, Repository repository) {
}

logger.debug(
"Text unit with name: {} should be translated: {}", tmTextUnit.getName(), isTranslatable);
"Text unit with name: {}, should be translated: {}", tmTextUnit.getName(), isTranslatable);
return isTranslatable;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ void updatePushRun(
@Async
void scheduleAITranslation(Long repositoryId, CreateTextUnitsResult createTextUnitsResult) {
for (BranchStateTextUnit branchStateTextUnit : createTextUnitsResult.getCreatedTextUnits()) {
logger.debug(
"Sending tmTextUnitId: {} information to AI Translation scheduler",
branchStateTextUnit.getTmTextUnitId());
AITranslateJobInput aiTranslateJobInput = new AITranslateJobInput();
aiTranslateJobInput.setRepositoryId(repositoryId);
aiTranslateJobInput.setTmTextUnitId(branchStateTextUnit.getTmTextUnitId());
Expand Down

0 comments on commit 5fc7c78

Please sign in to comment.