Skip to content

Commit

Permalink
fix(ZNTA-2710): use DAO to count textflows
Browse files Browse the repository at this point in the history
  • Loading branch information
djansen-redhat committed Aug 14, 2018
1 parent 56c84af commit d88f660
Showing 1 changed file with 6 additions and 3 deletions.
Expand Up @@ -51,6 +51,7 @@
import org.zanata.config.MTServiceToken;
import org.zanata.config.MTServiceURL;
import org.zanata.config.MTServiceUser;
import org.zanata.dao.ProjectIterationDAO;
import org.zanata.dao.TextFlowDAO;
import org.zanata.dao.TextFlowTargetDAO;
import org.zanata.exception.ZanataServiceException;
Expand Down Expand Up @@ -101,6 +102,7 @@ public class MachineTranslationServiceImpl implements
private TextFlowsToMTDoc textFlowsToMTDoc;
private TextFlowDAO textFlowDAO;
private TextFlowTargetDAO textFlowTargetDAO;
private ProjectIterationDAO projectIterationDAO;
private LocaleService localeService;
private EntityManager entityManager;
private TransactionUtil transactionUtil;
Expand All @@ -119,6 +121,7 @@ public MachineTranslationServiceImpl(@MTServiceURL URI mtServiceURL,
TextFlowsToMTDoc textFlowsToMTDoc,
TextFlowDAO textFlowDAO,
TextFlowTargetDAO textFlowTargetDAO,
ProjectIterationDAO projectIterationDAO,
LocaleService localeService,
EntityManager entityManager,
TransactionUtil transactionUtil,
Expand All @@ -137,6 +140,7 @@ public MachineTranslationServiceImpl(@MTServiceURL URI mtServiceURL,
this.translationService = translationService;
this.versionStateCache = versionStateCache;
this.attributionService = attributionService;
this.projectIterationDAO = projectIterationDAO;
}

@Override
Expand Down Expand Up @@ -211,9 +215,8 @@ public Future<Void> prefillProjectVersionWithMachineTranslation(
return AsyncTaskResult.completed();
}
// Set taskHandle to count the textflows of all documents
taskHandle.setTotalUnits(
documents.values().stream()
.mapToLong(d -> d.getTextFlows().size()).sum());
taskHandle.setTotalUnits(projectIterationDAO
.getTotalMessageCountForIteration(versionId));
HLocale targetLocale = localeService.getByLocaleId(options.getToLocale());

Stopwatch overallStopwatch = Stopwatch.createStarted();
Expand Down

0 comments on commit d88f660

Please sign in to comment.